#! /bin/bash
#======================================================================
# Copyright (c) 1997 Daniele Giacomini daniele@pluto.linux.it
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# This program is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# General Public License for more details.
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
#======================================================================
# .SPEGNIMI
#
# Questo script esegue semplicemente uno shutdown e in questo senso
# pu essere eseguito solo dall'utente root.
# Questo script viene avviato automaticamente quando si effettua
# il login con il nome SPEGNIMI che non richiede password.
# Per questo, il file /etc/passwd contiene la riga seguente:
#
# SPEGNIMI::0:0:Spegnimento:/tmp:/etc/script/.SPEGNIMI
#
# In pratica, ogni utente pu eseguire lo shutdown facendo il
# login come utente SPEGNIMI, eventualmente attraverso ``rlogin'':
#
#   rlogin -l SPEGNIMI `hostname`
#
# Nello stesso modo si pu fare attraverso la rete da un altro
# computer:
#
#   rlogin -l SPEGNIMI <nome-del-computer>
#
#======================================================================

#======================================================================
# Inizio.
#======================================================================

    #------------------------------------------------------------------
    # Verifica la presenza del file SPEGNIMI.OK
    #------------------------------------------------------------------
    if [ -f /etc/script/data/SPEGNIMI.OK ]
    then
        #--------------------------------------------------------------
        # Il file esiste e si pu spegnere.
        # Esegue lo shutdown con una attesa di 10 secondi.
        #--------------------------------------------------------------
	sleep 10s
        shutdown -h now
    else
        #--------------------------------------------------------------
        # L'operazione di spegnimento non  consentita.
        #--------------------------------------------------------------
        echo "L'operazione richiesta di spegnimento non  consentita!"
    fi

#======================================================================
# Fine.
#======================================================================
