. "${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
printf '> %s\n' "$@"
}
-function crond2tab() {
- local src="$1"
-}
-
function fdiff() {
[ -e "$1" ] || return 0
[ -e "$2" ] || return 0
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\n"}' $src
+ crontab -l | grep -vE 'nb-update|^(PATH|NB_LOG|SHELL|#[<>]nb)'
) > $TMP.crontab.orig.new
if fdiff $TMP.crontab.orig.orig $TMP.crontab.orig.new; 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