]> gitweb.pimeys.fr Git - scripts-20-100.git/blob - populate_forward.sh
[update_myscripts] bde-fallback plus clair que bde2
[scripts-20-100.git] / populate_forward.sh
1 #!/bin/bash
2
3 # Remplir le fichier forward
4
5
6 if [ $EUID -eq 0 ]
7 then
8 USER=${SUDO_USER}
9 HOMEDIR=$(getent passwd ${USER} | cut -d ":" -f 6)
10 FILE=${HOMEDIR}/forwards
11
12 touch ${FILE}
13 chown ${USER}:users ${FILE}
14 chmod 600 ${FILE}
15
16 find /home -mindepth 2 -maxdepth 2 -type d | sort | \
17 while read -r dossier;
18 do
19 if test -f ${dossier}/.forward;
20 then
21 echo -n "${dossier/\/home\//} : ";
22 cat ${dossier}/.forward
23 fi
24 done > ${FILE}
25
26 else
27 echo "À exécuter en root !"
28 fi