start tidy makefile
[hband-tools.git] / root-tools / anacron-peruser
blob97bd3c91094fafa5d9af0d204b216ed474f37c72
1 #!/bin/bash
3 set -e
5 peruser_anacrontabs=/var/spool/cron/anacrontabs
6 peruser_anacronspool=/var/spool/anacron/users
7 users=$(members users)
8 users=${users// /$'\n'}
10 install -d $peruser_anacrontabs -m 0711 -o root -g root
11 install -d $peruser_anacronspool -m 0755 -o root -g root
13 getent passwd | while IFS=: read user x uid pgid gecos home shell
15 if grep -qx "$user" <<<"$users"
16 then
17 install -d "$peruser_anacronspool/$user" -m 0770 -o root -g "$pgid"
19 crontab=$peruser_anacrontabs/$user
20 touch "$crontab"
21 chown root:$pgid "$crontab"
22 chmod 0660 "$crontab"
25 cd "$home"
26 sudo -u "$user" anacron -t "$crontab" -S "$peruser_anacronspool/$user"
29 done