systemctl (part of systemd) is noisy and returns non zero for non existant
authorRoy Marples <roy@marples.name>
Tue, 23 Feb 2016 10:10:07 +0000 (10:10 +0000)
committerRoy Marples <roy@marples.name>
Tue, 23 Feb 2016 10:10:07 +0000 (10:10 +0000)
services with the try-restart command.
As such, we need to test for the service being active before restarting it.
Fixes [d1049584dc].

configure

index 190ee71a9f92646fc57c1828a2980b546908b17d..2065794abce8255eeb013dc027b06b8f8aa7a640 100755 (executable)
--- a/configure
+++ b/configure
@@ -129,14 +129,17 @@ done
 if [ -z "$RESTARTCMD" ]; then
        printf "Checking for systemd ... "
        if [ -x /bin/systemctl ]; then
-               RESTARTCMD="/bin/systemctl try-restart \1"
+               RESTARTCMD="/bin/systemctl"
                echo "yes"
        elif [ -x /usr/bin/systemctl ]; then
-               RESTARTCMD="/usr/bin/systemctl try-restart \1"
+               RESTARTCMD="/usr/bin/systemctl"
                echo "yes"
        else
                echo "no"
        fi
+       if [ -n "$RESTARTCMD"]; then
+               RESTARTCMD="if $RESTARTCMD --quiet is-active \1.service; then $RESTARTCMD restart \1.service; fi"
+       fi
 fi
 
 # Arch upgraded to systemd, so this check has to be just after systemd