From: Nicolas Boisselier Date: Tue, 10 Mar 2015 23:23:30 +0000 (+0000) Subject: nb-update:cron X-Git-Url: https://git.nbdom.net/?a=commitdiff_plain;h=547de54f1c52ef53a86d8ef090459cef93269386;p=nb.git nb-update:cron --- diff --git a/bin/nb-install b/bin/nb-install index 363c35f5..a95d2cc3 100755 --- a/bin/nb-install +++ b/bin/nb-install @@ -7,14 +7,14 @@ . "${BASH_SOURCE%/*}/../etc/profile.sh" || exit declare -r NAME="$(basename "${0}")" declare TMP=/tmp/$NAME.$$ -declare install="rsync -au --force" +declare INSTALL="rsync -au --force" # # Args # 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 +case "$@" in *-v*) INSTALL="$INSTALL -v";; esac +case "$@" in *-n*) INSTALL="$INSTALL -n";; esac # # Functions @@ -23,10 +23,6 @@ function verbose() { printf '> %s\n' "$@" } -function crond2tab() { - local src="$1" -} - function fdiff() { [ -e "$1" ] || return 0 [ -e "$2" ] || return 0 @@ -41,16 +37,17 @@ if [ -d /etc/cron.d ]; then if fdiff "$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 + $INSTALL "$NB_ROOT/etc/cron/nb" /etc/cron.d/nb fi else crontab -l > $TMP.crontab.orig.orig ( - crontab -l | grep -vE 'nb-update|^PATH' # Delete user - perl -ane '/^PATH/ and print; /^[\*\d]/ or next; print join(" ",@F[0..4,6..$#F])."\n"' $NB_ROOT/etc/cron/nb + perl -ane '/^(NB_LOG|SHELL|PATH)/ and print; /^[\*\d]/ or next; print join(" ",@F[0..4,6..$#F])."\n"' $NB_ROOT/etc/cron/nb + #perl -ane '/^\s*(#|$)/ and next; print ( scalar(@F>7) ? $_ : join(" ",@F[0..4,6..$#F])."\n" ); BEGIN{print "#>NB\n"} ;END {print "#]nb)' ) > $TMP.crontab.orig.new if fdiff $TMP.crontab.orig.orig $TMP.crontab.orig.new; then @@ -68,7 +65,7 @@ if [ -d /etc/profile.d ]; then if fdiff $TMP.profile /etc/profile.d/nb-profile.sh; then verbose "Install /etc/profile.d/nb-profile.sh" - $install -c $TMP.profile /etc/profile.d/nb-profile.sh + $INSTALL -c $TMP.profile /etc/profile.d/nb-profile.sh chmod 755 /etc/profile.d/nb-profile.sh fi