summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRoy Marples <roy@marples.name>2016-03-12 08:32:49 +0000
committerRoy Marples <roy@marples.name>2016-03-12 08:32:49 +0000
commit9e4d761b0134980d23cba35e3d69894f70f83965 (patch)
tree63c6a4cfa6cd4fe6abb6171f797adbf6b120af7f
parent3ab089aa0ebd00b693ff90e0e58b3934fde67f6c (diff)
downloadopenresolv-3.8.0.tar.xz
For FreeBSD, the status argument needs to be onestatus.openresolv-3.8.0
-rw-r--r--Makefile6
-rwxr-xr-xconfigure15
-rw-r--r--resolvconf.in13
3 files changed, 28 insertions, 6 deletions
diff --git a/Makefile b/Makefile
index e23d5b7..dbc0673 100644
--- 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:
diff --git a/configure b/configure
index cbc615d..b430b20 100755
--- 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
diff --git a/resolvconf.in b/resolvconf.in
index 4c956eb..f77c134 100644
--- a/resolvconf.in
+++ b/resolvconf.in
@@ -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