From: Nicolas Boisselier Date: Tue, 18 Nov 2014 00:41:37 +0000 (+0000) Subject: cron for osx X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=5caa132a8fc3a80a90c588c1165d0586a738f050;p=nb.git cron for osx --- diff --git a/bin/nb-install b/bin/nb-install index 1fc38357..c3131d57 100755 --- a/bin/nb-install +++ b/bin/nb-install @@ -3,6 +3,7 @@ declare -r NAME="$(basename "${0}")" declare install="rsync -au --force" + case "$@" in *-h*|*-help*) exec echo "Usage: $NAME [-v] [-n]";; esac case "$@" in *-v*) install="$install -v";; esac case "$@" in *-n*) install="$install -n";; esac @@ -11,12 +12,34 @@ function verbose() { printf '> %s\n' "$@" } +function crond2tab() { + local src="$1" +} + # # Cron # if [ -d /etc/cron.d ]; then - verbose "Install /etc/cron.d/nb" - $install "$NB_ROOT/etc/cron/nb" /etc/cron.d/nb + if [ -n "$(diff -q $NB_ROOT/etc/cron/nb /etc/cron.d/nb)" ]; then + verbose "Install /etc/cron.d/nb" + $install "$NB_ROOT/etc/cron/nb" /etc/cron.d/nb + fi + +else + + crontab -l > /tmp/nb-crontab.orig + ( + crontab -l | grep -v nb-update + # Delete user + perl -ane '/^PATH/ and print; /^[\*\d]/ or next; print join(" ",@F[0..4,6..$#F])."\n"' $NB_ROOT/etc/cron/nb + ) > /tmp/nb-crontab.new + + if [ -n "$(diff -q /tmp/nb-crontab.orig /tmp/nb-crontab.new)" ]; then + verbose "Install /etc/cron.d/nb" + crontab /tmp/nb-crontab.new + fi + rm -f /tmp/nb-crontab.* + fi #