summaryrefslogtreecommitdiffstats
path: root/contrib/openresolv/configure
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/openresolv/configure')
-rw-r--r--contrib/openresolv/configure135
1 files changed, 87 insertions, 48 deletions
diff --git a/contrib/openresolv/configure b/contrib/openresolv/configure
index 39bdddb..190ee71 100644
--- a/contrib/openresolv/configure
+++ b/contrib/openresolv/configure
@@ -9,7 +9,7 @@ TARGET=
RESTARTCMD=
RCDIR=
-for x; do
+for x do
opt=${x%%=*}
var=${x#*=}
case "$opt" in
@@ -18,7 +18,7 @@ for x; do
--debug) DEBUG=$var;;
--disable-debug) DEBUG=no;;
--enable-debug) DEBUG=yes;;
- --prefix) prefix=$var;;
+ --prefix) PREFIX=$var;;
--sysconfdir) SYSCONFDIR=$var;;
--bindir|--sbindir) SBINDIR=$var;;
--libexecdir) LIBEXECDIR=$var;;
@@ -41,68 +41,76 @@ for x; do
esac
done
+if [ -z "$LIBEXECDIR" ]; then
+ printf "Checking for directory /libexec ... "
+ if [ -d /libexec ]; then
+ echo "yes"
+ LIBEXECDIR=$PREFIX/libexec/resolvconf
+ else
+ echo "no"
+ LIBEXECDIR=$PREFIX/lib/resolvconf
+ fi
+fi
+if [ -z "$RUNDIR" ]; then
+ printf "Checking for directory /run ... "
+ if [ -d /run ]; then
+ echo "yes"
+ RUNDIR=/run
+ else
+ echo "no"
+ RUNDIR=/var/run
+ fi
+fi
+
: ${SED:=sed}
-: ${PREFIX:=$prefix}
: ${SYSCONFDIR:=$PREFIX/etc}
: ${SBINDIR:=$PREFIX/sbin}
-: ${LIBEXECDIR:=$PREFIX/libexec}
+: ${LIBEXECDIR:=$PREFIX/libexec/resolvconf}
: ${STATEDIR:=/var}
: ${RUNDIR:=$STATEDIR/run}
: ${MANDIR:=${PREFIX:-/usr}/share/man}
eval SYSCONFDIR="$SYSCONFDIR"
eval SBINDIR="$SBINDIR"
-eval LIBEXECDIR="$LIBEXECDIR/resolvconf"
+eval LIBEXECDIR="$LIBEXECDIR"
eval VARDIR="$RUNDIR/resolvconf"
eval MANDIR="$MANDIR"
CONFIG_MK=config.mk
if [ -z "$BUILD" ]; then
- BUILD=`uname -m`-`uname -s | tr '[:upper:]' '[:lower:]'`
-fi
-if [ -z "$HOST" ]; then
- [ -z "$TARGET" ] && TARGET=$BUILD
- HOST=$TARGET
-fi
-if [ -z "$TARGET" ]; then
- [ -z "$HOST" ] && HOST=$BUILD
- TARGET=$HOST
-fi
-
-# Debian and Slackware have linux in different places when dealing with
-# autoconf, so we deal with that here.
-if [ -z "$OS" ]; then
- case "$TARGET" in
- *-linux-*|linux-*|*-linux|linux) OS=linux;;
- esac
+ # autoconf target triplet: cpu-vendor-os
+ BUILD=$(uname -m)-unknown-$(uname -s | tr '[:upper:]' '[:lower:]')
fi
+: ${HOST:=$BUILD}
if [ -z "$OS" ]; then
- # Derive OS from cpu-manufacturer-os-kernel
- CPU=${TARGET%%-*}
- REST=${TARGET#*-}
+ echo "Deriving operating system from ... $HOST"
+ # Derive OS from cpu-vendor-[kernel-]os
+ CPU=${HOST%%-*}
+ REST=${HOST#*-}
if [ "$CPU" != "$REST" ]; then
- MANU=${REST%%-*}
+ VENDOR=${REST%%-*}
REST=${REST#*-}
- if [ "$MANU" != "$REST" ]; then
+ if [ "$VENDOR" != "$REST" ]; then
+ # Use kernel if given, otherwise os
OS=${REST%%-*}
- REST=${REST#*-}
- if [ "$OS" != "$REST" ]; then
- KERNEL=${REST%%-*}
- else
- # 3 tupple
- KERNEL=$OS
- OS=$MANU
- MANU=
- fi
else
# 2 tupple
- OS=$MANU
- MANU=
+ OS=$VENDOR
+ VENDOR=
fi
fi
+
+ # Work with cpu-kernel-os, ie Debian
+ case "$VENDOR" in
+ linux*|kfreebsd*) OS=$VENDOR; VENDOR= ;;
+ esac
+ # Special case
+ case "$OS" in
+ gnu*) OS=hurd;; # No HURD support as yet
+ esac
fi
echo "Configuring openresolv for ... $OS"
@@ -118,17 +126,36 @@ for x in SYSCONFDIR SBINDIR LIBEXECDIR VARDIR MANDIR; do
echo "$x=$t $v" >>$CONFIG_MK
done
-if [ -e /etc/arch-release -a -d /etc/rc.d ]; then
- echo "Overriding service status check for Arch Linux"
- RCDIR=/etc/rc.d
- RESTARTCMD="[ -e /var/run/daemons/\1 ] \&\& /etc/rc.d/\1 restart"
- echo "yes"
+if [ -z "$RESTARTCMD" ]; then
+ printf "Checking for systemd ... "
+ if [ -x /bin/systemctl ]; then
+ RESTARTCMD="/bin/systemctl try-restart \1"
+ echo "yes"
+ elif [ -x /usr/bin/systemctl ]; then
+ RESTARTCMD="/usr/bin/systemctl try-restart \1"
+ echo "yes"
+ else
+ echo "no"
+ fi
+fi
+
+# Arch upgraded to systemd, so this check has to be just after systemd
+# but higher than the others
+if [ -z "$RESTARTCMD" ]; then
+ printf "Checking for Arch ... "
+ if [ -e /etc/arch-release -a -d /etc/rc.d ]; then
+ RCDIR=/etc/rc.d
+ RESTARTCMD="[ -e /var/run/daemons/\1 ] \&\& /etc/rc.d/\1 restart"
+ echo "yes"
+ else
+ echo "no"
+ fi
fi
if [ -z "$RESTARTCMD" ]; then
printf "Checking for OpenRC ... "
if [ -x /sbin/rc-service ]; then
- RESTARTCMD="/sbin/rc-service -e \1 \&\& /sbin/rc-service \1 -- -Ds restart"
+ RESTARTCMD="if /sbin/rc-service -e \1; then /sbin/rc-service \1 -- -Ds restart; fi"
echo "yes"
else
echo "no"
@@ -138,7 +165,7 @@ if [ -z "$RESTARTCMD" ]; then
printf "Checking for invoke-rc.d ... "
if [ -x /usr/sbin/invoke-rc.d ]; then
RCDIR=/etc/init.d
- RESTARTCMD="/usr/sbin/invoke-rc.d --quiet \1 status >/dev/null 2>\&1 \&\& /usr/sbin/invoke-rc.d \1 restart"
+ RESTARTCMD="if /usr/sbin/invoke-rc.d --quiet \1 status >/dev/null 2>\&1; then /usr/sbin/invoke-rc.d \1 restart; fi"
echo "yes"
else
echo "no"
@@ -148,7 +175,19 @@ if [ -z "$RESTARTCMD" ]; then
printf "Checking for service ... "
if [ -x /sbin/service ]; then
RCDIR=/etc/init.d
- RESTARTCMD="/sbin/service \1 \&\& /sbin/service \1 restart"
+ RESTARTCMD="if /sbin/service \1; then /sbin/service \1 restart; fi"
+ echo "yes"
+ else
+ echo "no"
+ fi
+fi
+if [ -z "$RESTARTCMD" ]; then
+ printf "Checking for runit... "
+ if [ -x /bin/sv ]; then
+ RESTARTCMD="/bin/sv try-restart \1"
+ echo "yes"
+ elif [ -x /usr/bin/sv ]; then
+ RESTARTCMD="/usr/bin/sv try-restart \1"
echo "yes"
else
echo "no"
@@ -159,7 +198,7 @@ if [ -z "$RESTARTCMD" ]; then
printf "Checking for $x ... "
if [ -d $x ]; then
RCDIR=$x
- RESTARTCMD="$x/\1 status >/dev/null 2>\&1 \&\& $x/\1 restart"
+ RESTARTCMD="if $x/\1 status >/dev/null 2>\&1; then $x/\1 restart; fi"
echo "yes"
break
else
@@ -169,7 +208,7 @@ if [ -z "$RESTARTCMD" ]; then
fi
if [ -z "$RESTARTCMD" ]; then
- echo "WARNING! No means of interacting with system services detected!"
+ echo "$0: WARNING: No means of interacting with system services detected!"
exit 1
fi
OpenPOWER on IntegriCloud