For FreeBSD, the status argument needs to be onestatus. openresolv-3.8.0
authorRoy Marples <roy@marples.name>
Sat, 12 Mar 2016 08:32:49 +0000 (08:32 +0000)
committerRoy Marples <roy@marples.name>
Sat, 12 Mar 2016 08:32:49 +0000 (08:32 +0000)
Makefile
configure
resolvconf.in

index e23d5b7084211d7e233b5296e6bd528489591d0d..dbc0673fd2527e93f12fd6fb6b25ef49e4542c78 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -32,6 +32,7 @@ SED_VARDIR=           -e 's:@VARDIR@:${VARDIR}:g'
 SED_RCDIR=             -e 's:@RCDIR@:${RCDIR}:g'
 SED_RESTARTCMD=                -e 's:@RESTARTCMD@:${RESTARTCMD}:g'
 SED_RCDIR=             -e 's:@RCDIR@:${RCDIR}:g'
+SED_STATUSARG=         -e 's:@STATUSARG@:${STATUSARG}:g'
 
 DISTPREFIX?=   ${PKG}-${VERSION}
 DISTFILEGZ?=   ${DISTPREFIX}.tar.gz
@@ -42,9 +43,10 @@ FOSSILID?=   current
 
 all: ${TARGET}
 
-.in:
+.in: Makefile ${CONFIG_MK}
        ${SED}  ${SED_SBINDIR} ${SED_SYSCONFDIR} ${SED_LIBEXECDIR} \
-               ${SED_VARDIR} ${SED_RCDIR} ${SED_RESTARTCMD} ${SED_RCDIR} \
+               ${SED_VARDIR} \
+               ${SED_RCDIR} ${SED_RESTARTCMD} ${SED_RCDIR} ${SED_STATUSARG} \
                $< > $@
 
 clean:
index cbc615de72e8145cf30e476e0d1226accc18dcdd..b430b20fc344d450fdfb7bac3e344e85e6536709 100755 (executable)
--- a/configure
+++ b/configure
@@ -8,6 +8,7 @@ HOST=
 TARGET=
 RESTARTCMD=
 RCDIR=
+STATUSARG=
 
 for x do
        opt=${x%%=*}
@@ -34,6 +35,7 @@ for x do
        --libdir) LIBDIR=$var;;
        --restartcmd) RESTARTCMD=$var;;
        --rcdir) RCDIR=$var;;
+       --statusarg) STATUSARG=$var;;
        --includedir) eval INCLUDEDIR="$INCLUDEDIR${INCLUDEDIR:+ }$var";;
        --datadir|--infodir) ;; # ignore autotools
        --disable-maintainer-mode|--disable-dependency-tracking) ;;
@@ -118,7 +120,17 @@ echo "Configuring openresolv for ... $OS"
 rm -rf $CONFIG_MK
 echo "# $OS" >$CONFIG_MK
 
-for x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR RESTARTCMD RCDIR; do
+# On FreeBSD, /etc/init.d/foo status returns 0 if foo is not enabled
+# regardless of if it's not running.
+# So we force onestatus to work around this silly bug.
+if [ -z "$STATUSARG" ]; then
+       case "$OS" in
+       freebsd*)       STATUSARG="onestatus";;
+       esac
+fi
+
+for x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR RESTARTCMD RCDIR STATUSARG
+do
        eval v=\$$x
        # Make files look nice for import
        l=$((10 - ${#x}))
@@ -136,4 +148,5 @@ echo "   MANDIR =           $MANDIR"
 echo
 echo "   RESTARTCMD =          $RESTARTCMD"
 echo "   RCDIR =               $RCDIR"
+echo "   STATUSARG =           $STATUSARG"
 echo
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