diff --git a/s6/service b/s6/service index e8c526b..730c405 100755 --- a/s6/service +++ b/s6/service @@ -1,8 +1,9 @@ #!/bin/bash # This script patches all service commands into the appropriate s6- commands # pi-hole upstream scripts need a 'service' interface. why not systemd? docker said so. + start() { - s6-svc -wu -u -T2500 /var/run/s6/services/$service + restart } stop() { @@ -12,16 +13,18 @@ stop() { restart() { local pid - # Get the PID of the service we are asking to restart - pid=$(pgrep $service) + # Get the PID(s) of the service we are asking to restart + mapfile -t pids < <(pgrep $service) # Only attempt to stop the service if it is already running - if [ -n "$pid" ]; then + if [ "${#pids[@]}" -gt 0 ]; then stop - # Loop until we are certain that the process has been stopped - while test -d /proc/$pid; do - sleep 0.2 + for pid in "${pids[@]}"; do + # Loop until we are certain that the process has been stopped + while test -d /proc/$pid; do + sleep 0.2 + done done fi @@ -30,7 +33,7 @@ restart() { # Only attempt to start the service if it is not already running if [ -z "$pid" ]; then - start + s6-svc -wu -u -T2500 /var/run/s6/services/$service fi }