--- /dev/null
+#!/bin/sh
+# Construct a crontab based on files in ~/.cron and load it into cron.
+# The file ~/.cron/username/fqdn is appended to the common file in the same
+# directory. Note that the common file may have "$HOME" in it, as in
+# "PATH=$HOME/bin". cron is too dumb to deal with that, so the expansion is
+# handled by this script.
+set -e
+
+WARNING="# Automatically generated by loadcron; edit ~/.cron/ files instead."
+
+if [ ! -z "`crontab -l`" ] && ! crontab -l | grep -q "$WARNING"; then
+ if [ "$1" != "-f" ]; then
+ echo "loadcron: Current crontab was not generated by loadcron; not changing." >&2
+ echo "loadcron: Use loadcron -f to override"
+ exit
+ else
+ crontab -l > $HOME/tmp/oldcrontab
+ echo "loadcron: Old crontab is backed up to $HOME/tmp/oldcrontab"
+ fi
+fi
+
+dir=$HOME/.cron/`whoami`
+if [ -d "$dir" ]; then
+ (
+ echo "$WARNING"
+ echo
+ if [ -e "$dir/common" ]; then
+ echo "# From $dir/common:"
+ sed "s!\$HOME!$HOME!" < "$dir/common"
+ echo
+ fi
+ hostfile="$dir/`hostname -f`"
+ if [ -e "$hostfile" ]; then
+ echo "# From $hostfile:"
+ cat "$hostfile"
+ echo
+ fi
+ # debian-edu crontab
+ debianedufile=/org/alioth.debian.org/chroot/home/groups/debian-edu/cronjobs/crontab.alioth
+ if [ "$(hostname)" = "haydn" ] && [ -e "$debianedufile" ]; then
+ echo "# From $debianedufile:"
+ cat "$debianedufile"
+ echo
+ fi
+ ) | crontab -
+fi