+rule_runit_configure () { # SYNTAX: $sv
+ rule apt_get_install runit
+ local -; set +f
+ sudo find /etc/sv -mindepth 1 -maxdepth 1 -type d -name "${1:-*}" -exec \
+ /bin/sh -efux -c 'case $(sv stop "$1") in
+ (*": runsv not running") true;;
+ (*": unable to open supervise/ok: file does not exist") true;;
+ ("ok: down:"*) true;;
+ (*) false;;
+ esac' '' {} +
+ set -$- ${1-"$tool"/etc/sv/*}
+ while test -n "$*"
+ do local first=yes
+ for sv in "$@"
+ do sv=${sv##*/}
+ case $first in
+ (yes) shift $#; first=;;
+ esac
+ rule _runit_sv_configure "$sv"
+ rule runit_sv_restart "$sv"
+ done
+ done
+ sudo find -L /etc/service -type l -delete
+ }
+rule__runit_sv_configure () { # SYNTAX: $sv
+ local sv="$1"
+ sudo install -d -m 770 -o root -g root \
+ /etc/sv/"$sv"
+ sudo install -m 770 -o root -g root \
+ "$tool"/etc/sv/"$sv"/run \
+ /etc/sv/"$sv"/run
+ if test -e "$tool"/etc/sv/"$sv"/log/run
+ then
+ sudo install -d -m 770 -o root -g root \
+ /etc/sv/"$sv"/log
+ sudo install -m 770 -o root -g root \
+ "$tool"/etc/sv/"$sv"/log/run \
+ /etc/sv/"$sv"/log/run
+ fi
+ local continue=
+ test ! -r "$tool"/etc/sv/"$sv"/configure.sh ||
+ . "$tool"/etc/sv/"$sv"/configure.sh
+ case $continue in
+ (yes) continue;;
+ esac
+ sudo ln -fns \
+ ../sv/"$sv" \
+ /etc/service/"$sv"
+ }
+rule_runit_sv_restart () { # SYNTAX: $sv
+ local sv="$1"
+ while true
+ do case $(sudo sv restart "$sv") in
+ ("fail: $sv: runsv not running") sleep 1;;
+ ("warning: $sv: unable to open supervise/ok: file does not exists") sleep 1;;
+ (*) break;;
+ esac
+ done
+ }
+rule_shorewall_configure () {
+ # DOC: http://shorewall.net/Introduction.html
+ local -; set +f
+ rule apt_get_install shorewall
+ sudo install -m 644 -o root -g root /dev/stdin \
+ /etc/default/shorewall <<-EOF
+ INITLOG=/dev/null
+ OPTIONS=""
+ RESTARTOPTIONS=""
+ SAFESTOP=0
+ STARTOPTIONS=""
+ startup=1
+ EOF
+ local conf
+ for conf in "$tool"/etc/shorewall/*
+ do conf=${conf#"$tool"/etc/shorewall/}
+ sudo test ! -f "$tool"/etc/shorewall/"$conf" ||
+ sudo install -m 640 -o root -g root \
+ "$tool"/etc/shorewall/"$conf" \
+ /etc/shorewall/"$conf"
+ done
+ sudo install -d -m 750 -o root -g root \
+ /etc/shorewall/macro.d
+ for conf in "$tool"/etc/shorewall/macro.d/*
+ do conf=${conf#"$tool"/etc/shorewall/macro.d/}
+ sudo test ! -f "$tool"/etc/shorewall/macro.d/"$conf" ||
+ sudo install -m 640 -o root -g root \
+ "$tool"/etc/shorewall/macro.d/"$conf" \
+ /etc/shorewall/macro.d/"$conf"
+ done
+ sudo install -d -m 750 -o root -g root \
+ /etc/shorewall/action.d
+ #for conf in "$tool"/etc/shorewall/action.d/*
+ # do conf=${conf#"$tool"/etc/shorewall/action.d/}
+ # sudo test ! -f "$tool"/etc/shorewall/action.d/"$conf" ||
+ # sudo install -m 640 -o root -g root \
+ # "$tool"/etc/shorewall/action.d/"$conf" \
+ # /etc/shorewall/action.d/"$conf"
+ # done
+ #sudo shorewall safe-restart
+ }