#
# An existing crontab entry not generated with this script is not overwritten.
-# Copyright (C) 2012 Simon Ruderich
+# Copyright (C) 2012-2013 Simon Ruderich
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
HEADER_WARNING="# WARNING! DO NOT EDIT THIS FILE! #"
-# Don't overwrite existing crontab entries.
+# Don't overwrite existing crontab entries. Not race condition free but that
+# can't be helped.
if crontab -l >/dev/null 2>&1; then
if crontab -l | head -n3 | grep "^$HEADER_WARNING$" >/dev/null; then
:
exit 1
fi
+# `set -e` aborts when `mktemp` fails.
CRONTAB=`mktemp --tmpdir="$DIRECTORY" update-crontab.XXXXXXXXXXXX`
echo "###################################" > "$CRONTAB"