#!/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.
#======================================================================
# ElencoCrea
#
# Genera un file contenente l'elenco dei file del filesystem ``root',
# la cui esistenza deve essere controllata.
# Deve essere eseguito dall'utente ``root''.
#======================================================================

#======================================================================
# Variabili.
#======================================================================

    #------------------------------------------------------------------
    # Il nome del file usato per accogliere l'elenco di file.
    #------------------------------------------------------------------
    ELENCO_FILE="/etc/Elenco"

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

    #------------------------------------------------------------------
    # Verifica la quantita' di argomenti.
    #------------------------------------------------------------------
    if [ $# != 0 ]
    then
        echo "Questo script non utilizza alcun argomento."
        #--------------------------------------------------------------
        # L'esecuzione dello script termina restituendo un valore
        # falso.
        #--------------------------------------------------------------
        exit 1
    fi
    #------------------------------------------------------------------
    # Verifica che l'utente sia 'root'.
    #------------------------------------------------------------------
    if [ $UID != 0 ]
    then
        echo "Questo script pu essere utilizzato solo dall'utente \
'root'."
        #--------------------------------------------------------------
        # L'esecuzione dello script termina restituendo un valore
        # falso.
        #--------------------------------------------------------------
        exit 1
    fi
    #------------------------------------------------------------------
    # Salva la situazione del filesystem globale.
    # Sono esclusi i percorsi ``/tmp'' e ``/proc''.
    #------------------------------------------------------------------
    echo "---------------------------------------------------"
    echo "E' in corso la scansione del filesystem root per "
    echo "determinare la situazione iniziale dei file esistenti."
    echo ""
    echo "Attendere prego..."
    echo "---------------------------------------------------"
    find \
/ -xdev -path "/proc" -prune -o -path "/tmp" -prune -o -print | \
sort > $ELENCO_FILE
    #------------------------------------------------------------------
    # Avvisa l'utente della conclusione dell'operazione.
    #------------------------------------------------------------------
    echo "La scansione e' terminata."

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