From 25d10962e91d178893d773ec2c7e6aaf5415227f Mon Sep 17 00:00:00 2001 From: Don Armstrong Date: Wed, 5 Apr 2006 00:52:49 +0000 Subject: [PATCH] add joeyh's loadcron --- loadcron | 46 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100755 loadcron diff --git a/loadcron b/loadcron new file mode 100755 index 0000000..5700cc1 --- /dev/null +++ b/loadcron @@ -0,0 +1,46 @@ +#!/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 -- 2.39.2