2 # Construct a crontab based on files in ~/.cron and load it into cron.
3 # The file ~/.cron/username/fqdn is appended to the common file in the same
4 # directory. Note that the common file may have "$HOME" in it, as in
5 # "PATH=$HOME/bin". cron is too dumb to deal with that, so the expansion is
6 # handled by this script.
9 which crontab
>/dev
/null
2>&1 ||
exit 0
11 WARNING
="# Automatically generated by loadcron; edit ~/.cron/ files instead."
13 if [ ! -z "`crontab -l`" ] && ! crontab
-l |
grep -q "$WARNING"; then
14 if [ "$1" != "-f" ]; then
15 echo "loadcron: Current crontab was not generated by loadcron; not changing." >&2
16 echo "loadcron: Use loadcron -f to override"
19 crontab
-l > $HOME/tmp
/oldcrontab
20 echo "loadcron: Old crontab is backed up to $HOME/tmp/oldcrontab"
24 dir
=$HOME/.cron-stage
/`whoami`
25 if [ -d "$dir" ]; then
26 hostfile
="$dir/`hostname -f`"
27 if [ ! -e "$hostfile" ]; then
28 echo "loadcron: $hostfile does not exist, not loading" >&2
35 if [ -e "$dir/common" ]; then
36 echo "# From $dir/common:"
37 sed "s!\$HOME!$HOME!" < "$dir/common"
40 hostfile
="$dir/`hostname -f`"
41 if [ -e "$hostfile" ]; then
42 echo "# From $hostfile:"