=== modified file 'sbin/runsvdirboot' --- sbin/runsvdirboot 2017-05-16 14:02:16 +0000 +++ sbin/runsvdirboot 2015-12-08 10:54:51 +0000 @@ -15,7 +15,6 @@ --default STATE put services in a state by default: "up" - turn services on "down" - turn services off - "new-down" - turn services that weren't initialized yet off "keep" - keep the current state -u --up PATTERN turn on services with name matching PATTERN -d --down PATTERN turn off services with name matching PATTERN @@ -23,6 +22,12 @@ exit 0 fi +DEFAULT=${${STATE[-1]}:-down} +if [[ $DEFAULT != (up|down|keep) ]]; then + printf >&2 "Invalid default state: '%s'\n" $STATE + exit 2 +fi + [[ -r /etc/zsh/zlogin ]] && source /etc/zsh/zlogin [[ -r /etc/zsh/zprofile ]] && source /etc/zsh/zprofile @@ -31,16 +36,11 @@ mkdir -p ${SVDIR} -DEFAULT=${${STATE[-1]}:-new-down} -case $DEFAULT in - (up) zsvgen --all-up;; - (down) zsvgen --all-down;; - (new-down) zsvgen --new-down;; - (keep);; - (*) - printf >&2 "Invalid default state: '%s'\n" $STATE - exit 2 - ;; + +if [[ $DEFAULT == up ]]; then + zsvgen --all-up +elif [[ $DEFAULT == down ]]; then + zsvgen --all-down fi for flag pat in "$UP[@]"; do === modified file 'sbin/zsvgen' --- sbin/zsvgen 2017-05-16 14:02:16 +0000 +++ sbin/zsvgen 2016-07-14 21:37:55 +0000 @@ -9,7 +9,6 @@ h=H -help=H \ -all-up=ALL_UP \ -all-down=ALL_DOWN \ - -new-down=NEW_DOWN \ -lock+:=LOCK \ f+:=F -filter+:=F @@ -22,19 +21,10 @@ --lock TIMEOUT perform locking on ZSVDIR --all-up turn all (filtered) services on --all-down turn all (filtered) services off - --new-down turn all (filtered) services that haven't been - initialized yet off END exit 0 fi -if (( $#ALL_UP + $#ALL_DOWN + $#NEW_DOWN > 1 )); then - printf '%s\n' "Only one of following options is allowed:" \ - " --all-up --all-down --new-down" - exit 2 - -fi - if [[ -n $1 ]]; then exec >>$1 2>&1 shift @@ -62,7 +52,7 @@ if (($#LOCK)); then LOCK_TIMEOUT=$LOCK[-1] if ! [[ $LOCK_TIMEOUT =~ '^[0-9]+$' ]]; then - printf 'Incorrect lock timeout: "%s"\n' $LOCK_TIMEOUT + printf 'Incorrect lock timeout: "%s"' $LOCK_TIMEOUT exit 2 fi exec 3> ${ZSVDIR}.lock @@ -109,19 +99,12 @@ fi zsv_eval $ZSVDIR/$name zsv_dir=$zsv_svdir/$name + mkdir -p $zsv_dir $ZSVDIR/_ovr/$name - if (($#NEW_DOWN)); then - if [[ -d $ZSVDIR/_ovr/$name ]]; then - mkdir -p $zsv_dir $ZSVDIR/_ovr/$name - touch $ZSVDIR/_ovr/$name/down - fi - else - mkdir -p $zsv_dir $ZSVDIR/_ovr/$name - if (($#ALL_UP)); then - [[ -e $ZSVDIR/_ovr/$name/down ]] && rm $ZSVDIR/_ovr/$name/down - elif (($#ALL_DOWN)); then - touch $ZSVDIR/_ovr/$name/down - fi + if (($#ALL_UP)); then + [[ -e $ZSVDIR/_ovr/$name/down ]] && rm $ZSVDIR/_ovr/$name/down + elif (($#ALL_DOWN)); then + touch $ZSVDIR/_ovr/$name/down fi # flags