Modification : vm_{host,hosted,remote} -> {host,local,remote}/ .
[lhc/ateliers.git] / local / runit-configure
diff --git a/local/runit-configure b/local/runit-configure
new file mode 100755 (executable)
index 0000000..06cb218
--- /dev/null
@@ -0,0 +1,44 @@
+#!/bin/sh -eu
+# SYNTAX: $sv [...] -- $sv_options
+tool=$(readlink -e "${0%/*}/..")
+. "$tool"/local/lib.sh
+
+"$tool"/local/apt-get-install runit
+if test $# = 0
+ then
+       set +x
+       sudo sv status \
+        $(sudo find /etc/sv \
+        -mindepth 1 -maxdepth 1 -type d \
+        -printf '%p\n' | sort)
+ else
+       services=
+       while [ $# -gt 0 ]
+        do case $1 in
+                (--) shift; break;;
+                (*) services="$services ${1#etc/sv/}"; shift;;
+                esac
+        done
+       #for sv in $(sudo find /etc/sv \
+       # -mindepth 1 -maxdepth 1 -type d \
+       # -false $(printf -- '-or -name %s\n' $services) \
+       # -printf '%f\n')
+       # do
+       #       case $(sudo sv stop "$sv" | tee /dev/stderr) in
+       #        (*": runsv not running") true;;
+       #        (*": unable to open supervise/ok: file does not exist") true;;
+       #        ("ok: down:"*) true;;
+       #        (*) false;;
+       #        esac
+       # done
+       for sv in $(find "$tool"/etc/sv \
+        -mindepth 1 -maxdepth 1 -type d \
+        -false $(printf -- '-or -name %s\n' $services) \
+        -printf '%f\n')
+        do
+               "$tool"/local/runit-sv-configure "$sv" "$@"
+               "$tool"/local/runit-sv-start     "$sv"
+        done
+       #sleep 3
+       #sudo find -L /etc/service -type l -delete
+ fi