For FreeBSD, the status argument needs to be onestatus.
[openresolv] / resolvconf.in
index 4c956ebb821505f4a207f5cf8486ae6e1d19a976..f77c13425bae6f8c01f0b097b4a03c255af6ae07 100644 (file)
@@ -267,7 +267,8 @@ detect_init()
        # Detect the running init system.
        # As systemd and OpenRC can be installed on top of legacy init
        # systems we try to detect them first.
-       _service_status=
+       local status="@STATUSARG@"
+       : ${status:=status}
        if [ -x /bin/systemctl -a -S /run/systemd/private ]; then
                RESTARTCMD="if /bin/systemctl --quiet is-active; then
        /bin/systemctl restart \$1.service;
@@ -286,9 +287,15 @@ fi"
        /usr/sbin/invoke-rc.d \$1 restart;
 fi"
        elif [ -x /sbin/service ]; then
+               # Old RedHat
                RCDIR=/etc/init.d
                RESTARTCMD="if /sbin/service \$1; then
-/sbin/service \$1 restart;
+       /sbin/service \$1 restart;
+fi"
+       elif [ -x /usr/sbin/service ]; then
+               # Could be FreeBSD
+               RESTARTCMD="if /usr/sbin/service \$1 $status 1>/dev/null 2>&1; then
+       /usr/sbin/service \$1 restart;
 fi"
        elif [ -x /bin/sv ]; then
                RESTARTCMD="/bin/sv try-restart \$1"
@@ -311,7 +318,7 @@ fi"
        else
                for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
                        [ -d $x ] || continue
-                       RESTARTCMD="if $x/\$1 status 1>/dev/null 2>&1; then
+                       RESTARTCMD="if $x/\$1 $status 1>/dev/null 2>&1; then
        $x/\$1 restart;
 fi"
                        break