Script finalize per creazione automatica scratch su Zewail

From SmartHPC Wiki
Jump to: navigation, search

Ho creato uno script (/cm/shared/apps/cmgui/zewail-finalize.sh) di "finalize" per Bright che alla fine dell'installazione di un nodo crea automaticamente le scratch o copia un eventuale backup da /home/scratch/$HOSTNAME

Dovrebbe essere possibile usarlo senza modifiche anche sulle altre categorie di nodi.

# Manages scratch dir
mount 10.0.1.250:/HPC/home/chemistry /mnt -t nfs -o nolock
if [ -d /mnt/scratch/$CMD_HOSTNAME ]; then
        echo "Found a scratch backup for $CMD_HOSTNAME, restoring backup"
        rsync -au /mnt/scratch/$CMD_HOSTNAME/scratch/* /localdisk/local/scratch/
else
        # Create scratch dirs in /local/scratch
        if [ ! -d /localdisk/local/scratch ]; then
                mkdir /localdisk/local/scratch
        fi
        # Create scratch dirs from users list
        users_groups=`ls -l /mnt | awk 'NR>1 && $0!~/root/{printf "%s_%s\n", $NF,$4}'`
        for U in $users_groups; do
                user=`echo $U  |awk -v FS="_" '{print $1}'`
                group=`echo $U |awk -v FS="_" '{print $2}'`
                if [ ! -d $user ]; then
                        echo "creating scratch for $user in group $group"
                        let ret=0
                        mkdir /localdisk/local/scratch/$user
                        ret=$?
                        if [ "$ret" -ne 0 ] ; then
                                echo "error creating scratch $user" 
                        fi
                        chown -R /localdisk/local/scratch/$user:$group $user
                        ret=$?
                        if [ "$ret" -ne 0 ] ; then
                                echo "error changing rights for user $user" 
                        fi
                fi
        done
fi
umount /mnt