X-Git-Url: http://gitweb.pimeys.fr/?p=scripts-20-100.git;a=blobdiff_plain;f=populate_forward.sh;h=70d86eef057b9a5db6439dc4719c6d0289f6aa1b;hp=b492c9c610e7492a5141dba482b52499f8000fe9;hb=HEAD;hpb=7f26c0abefaf1bc5ae75075600c70e2e2c2b95ce diff --git a/populate_forward.sh b/populate_forward.sh index b492c9c..70d86ee 100755 --- a/populate_forward.sh +++ b/populate_forward.sh @@ -2,17 +2,18 @@ # Remplir le fichier forward -USER=legallic - -FILE=/home/${USER}/forwards if [ $EUID -eq 0 ] then + USER=${SUDO_USER} + HOMEDIR=$(getent passwd ${USER} | cut -d ":" -f 6) + FILE=${HOMEDIR}/forwards + touch ${FILE} chown ${USER}:users ${FILE} chmod 600 ${FILE} - find /home -mindepth 1 -maxdepth 1 -type d | sort | \ + find /home -mindepth 2 -maxdepth 2 -type d | sort | \ while read -r dossier; do if test -f ${dossier}/.forward;