Improve shell code.

This commit is contained in:
Darko Poljak 2018-10-09 18:25:35 +02:00
parent 53300b1004
commit 8669ccb9c1

View file

@ -24,7 +24,7 @@ fi
case "$1" in case "$1" in
start) start)
printf "Starting daemontools: " printf "Starting daemontools: "
if [ ! "$(pidof svscan)" ]; then if ! pidof svscan > /dev/null 2>&1; then
printf "svscan " printf "svscan "
env - PATH="$PATH" svscan /service 2>&1 | setuidgid daemon multilog t /var/log/svscan & env - PATH="$PATH" svscan /service 2>&1 | setuidgid daemon multilog t /var/log/svscan &
echo "." echo "."
@ -34,11 +34,16 @@ case "$1" in
;; ;;
stop) stop)
printf "Stopping daemontools: " printf "Stopping daemontools: "
if [ "$(pidof svscan)" ]; then pids="$(pidof svscan)"
if [ -n "${pids}" ]
then
printf "svscan" printf "svscan"
while [ "$(pidof svscan)" ]; do while [ -n "${pids}" ]
kill "$(pidof svscan)" do
printf "." # shellcheck disable=SC2086
kill ${pids}
printf "."
pids="$(pidof svscan)"
done done
fi fi
printf " services" printf " services"