From: Roy Marples Date: Sat, 12 Mar 2016 10:52:41 +0000 (+0000) Subject: Support buggy FreeBSD rc system out of the box. X-Git-Tag: v6.10.2~25 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c2d0c13e72ea9ca20ad09ba03ec7cc4710369aad;p=thirdparty%2Fdhcpcd.git Support buggy FreeBSD rc system out of the box. --- diff --git a/Makefile b/Makefile index 337a4388..b960a120 100644 --- 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 diff --git a/configure b/configure index 9c7de89d..d046ac60 100755 --- 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 diff --git a/dhcpcd-run-hooks.in b/dhcpcd-run-hooks.in index 7ad1afa1..a8f3ad90 100644 --- a/dhcpcd-run-hooks.in +++ b/dhcpcd-run-hooks.in @@ -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