]> gitweb.pimeys.fr Git - scripts-20-100.git/commitdiff
[populate_foward] Proprification suite au changement des homes
authorVincent Le Gallic <legallic@crans.org>
Mon, 8 Sep 2014 14:35:47 +0000 (16:35 +0200)
committerVincent Le Gallic <legallic@crans.org>
Mon, 8 Sep 2014 14:35:47 +0000 (16:35 +0200)
populate_forward.sh

index b492c9c610e7492a5141dba482b52499f8000fe9..70d86eef057b9a5db6439dc4719c6d0289f6aa1b 100755 (executable)
@@ -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;