]> git.ipfire.org Git - thirdparty/dhcpcd.git/commitdiff
Support buggy FreeBSD rc system out of the box.
authorRoy Marples <roy@marples.name>
Sat, 12 Mar 2016 10:52:41 +0000 (10:52 +0000)
committerRoy Marples <roy@marples.name>
Sat, 12 Mar 2016 10:52:41 +0000 (10:52 +0000)
Makefile
configure
dhcpcd-run-hooks.in

index 337a4388c00b2f48646d3c980435079564cde24f..b960a120bd5bc8b6d77c59bc166d369108a11525 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -46,6 +46,7 @@ SED_HOOKDIR=          -e 's:@HOOKDIR@:${HOOKDIR}:g'
 SED_SERVICEEXISTS=     -e 's:@SERVICEEXISTS@:${SERVICEEXISTS}:g'
 SED_SERVICECMD=                -e 's:@SERVICECMD@:${SERVICECMD}:g'
 SED_SERVICESTATUS=     -e 's:@SERVICESTATUS@:${SERVICESTATUS}:g'
+SED_STATUSARG=         -e 's:@STATUSARG@:${STATUSARG}:g'
 SED_SCRIPT=            -e 's:@SCRIPT@:${SCRIPT}:g'
 SED_SYS=               -e 's:@SYSCONFDIR@:${SYSCONFDIR}:g'
 
@@ -66,10 +67,11 @@ CLEANFILES+=        *.tar.xz
 
 .SUFFIXES:     .in
 
-.in:
+.in: Makefile config.mk
        ${SED} ${SED_RUNDIR} ${SED_DBDIR} ${SED_LIBDIR} ${SED_HOOKDIR} \
                ${SED_SYS} ${SED_SCRIPT} ${SED_DATADIR} \
                ${SED_SERVICEEXISTS} ${SED_SERVICECMD} ${SED_SERVICESTATUS} \
+               ${SED_STATUSARG} \
                $< > $@
 
 all: config.h ${PROG} ${SCRIPTS} ${MAN5} ${MAN8}
@@ -78,7 +80,7 @@ all: config.h ${PROG} ${SCRIPTS} ${MAN5} ${MAN8}
 dev:
        cd dev && ${MAKE}
 
-.c.o:
+.c.o: Makefile config.mk
        ${CC} ${CFLAGS} ${CPPFLAGS} -c $< -o $@
 
 CLEANFILES+=   dhcpcd-embedded.h dhcpcd-embedded.c
index 9c7de89d363c1b86c4eed7291b8754685483e9cd..d046ac606267460d162d676a94cf2ca8cf65574e 100755 (executable)
--- a/configure
+++ b/configure
@@ -24,6 +24,7 @@ STATIC=
 DEVS=
 EMBEDDED=
 POLL=
+STATUSARG=
 
 for x do
        opt=${x%%=*}
@@ -78,6 +79,7 @@ for x do
        --serviceexists) SERVICEEXISTS=$var;;
        --servicecmd) SERVICECMD=$var;;
        --servicestatus) SERVICESTATUS=$var;;
+       --statusarg) STATUSARG=$var;;
        --infodir|--includedir) ;; # ignore autotools
        --disable-maintainer-mode|--disable-dependency-tracking) ;;
        --disable-silent-rules) ;;
@@ -1252,6 +1254,12 @@ SERVICESTATUS=$(echo "$SERVICESTATUS" | $SED \
        -e 's:\$:\\\\\$\$:g' \
 )
 echo "SERVICESTATUS=   $SERVICESTATUS" >>config.mk
+if [ -z "$STATUSARG" ]; then
+       case "$OS" in
+       freebsd*)       STATUSARG="onestatus";;
+       esac
+fi
+echo "STATUSARG=       $STATUSARG" >>config.mk
 
 HOOKS=
 if ! $HOOKSET; then
@@ -1357,6 +1365,7 @@ echo "   MANDIR =         $MANDIR"
 echo "   DATADIR =             $DATADIR"
 echo "   HOOKSCRIPTS = $HOOKS"
 echo "   EGHOOKSCRIPTS =       $EGHOOKS"
+echo "   STATUSARG =           $STATUSARG"
 echo
 
 rm -f dhcpcd tests/test
index 7ad1afa1ed8935a2b9ef092d9a591d4c2d9d5503..a8f3ad905b3094bcf6b71b75104cf855712dae4c 100644 (file)
@@ -260,7 +260,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
                _service_exists="/bin/systemctl --quiet is-enabled \$1.service"
                _service_status="/bin/systemctl --quiet is-active \$1.service"
@@ -280,6 +281,9 @@ detect_init()
        elif [ -x /sbin/service ]; then
                _service_exists="/sbin/service \$1 >/dev/null 2>&1"
                _service_cmd="/sbin/service \$1 \$2"
+       elif [ -x /usr/sbin/service ]; then
+               _service_exists="/usr/sbin/service \$1 $status >/dev/null 2>&1"
+               _service_cmd="/usr/sbin/service \$1 \$2"
        elif [ -x /bin/sv ]; then
                _service_exists="/bin/sv status \1 >/dev/null 2>&1"
                _service_cmd="/bin/sv \$1 \$2"
@@ -289,19 +293,20 @@ detect_init()
        elif [ -e /etc/slackware-version -a -d /etc/rc.d ]; then
                _service_exists="[ -x /etc/rc.d/rc.\$1 ]"
                _service_cmd="/etc/rc.d/rc.\$1 \$2"
-               _service_status="/etc/rc.d/rc.\$1 status 1>/dev/null 2>&1"
+               _service_status="/etc/rc.d/rc.\$1 status >/dev/null 2>&1"
        else
                for x in /etc/init.d/rc.d /etc/rc.d /etc/init.d; do
                        if [ -d $x ]; then
                                _service_exists="[ -x $x/\$1 ]"
                                _service_cmd="$x/\$1 \$2"
+                               _service_status="$x/\$1 $status >/dev/null 2>&1"
                                break
                        fi
                done
                if [ -e /etc/arch-release ]; then
                        _service_status="[ -e /var/run/daemons/\$1 ]"
                elif [ "$x" = "/etc/rc.d" -a -e /etc/rc.d/rc.subr ]; then
-                       _service_status="$x/\$1 check 1>/dev/null 2>&1"
+                       _service_status="$x/\$1 check >/dev/null 2>&1"
                fi
        fi