[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#779890: udhcpd: Support for multiple interfaces/udhcpd processes



Grr, final bit of confirmation has a shell quirk show up.  I suspect
there likely should be more backslashes on the sed command, but the
attached is what is confirmed to work.


-- 
(\___(\___(\______          --=> 8-) EHM <=--          ______/)___/)___/)
 \BS (    |         EHeM+sigmsg@m5p.com  PGP 87145445         |    )   /
  \_CS\   |  _____  -O #include <stddisclaimer.h> O-   _____  |   /  _/
8A19\___\_|_/58D2 7E3D DDF4 7BA6 <-PGP-> 41D1 B375 37D0 8714\_|_/___/5445


#! /bin/sh
#
# Written by Miquel van Smoorenburg <miquels@cistron.nl>.
# Modified for Debian GNU/Linux by Ian Murdock <imurdock@gnu.ai.mit.edu>
# and Axel Beckert <abe@deuxchevaux.org>.
# Adjusted for use as an ifupdown hook script by Elliott Mitchell
# <ehem+debian@m5p.com>.
#
### BEGIN INIT INFO
# Provides:          udhcpd
# Required-Start:    $remote_fs $syslog
# Required-Stop:     $remote_fs $syslog
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Start busybox udhcpd at boot time
### END INIT INFO

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/udhcpd
NAME=udhcpd
DESC="very small Busybox based DHCP server"
DHCPD_OPTS="-S" # Additional options given to the server

test -x $DAEMON || exit 0

case "${IF_DHCPD_ENABLE}" in
	udhcpd)
		# *we* and not some other DHCP server are enabled
	;;
	true|yes|1)
		# the DHCP server is enabled
	;;
	*)
		exit 0
	;;
esac

# Include defaults if available
[ -e /etc/default/udhcpd ] && . /etc/default/udhcpd

set -e

# Base location of configuration if relative path is given
[ -z "${DHCPD_CONFIG_DIR}" ] && DHCPD_CONFIG_DIR=/etc

# Has a configuration file been explicitly specified?  Optionally add directory
if [ -n "${IF_DHCPD_CONFIG}" ]
then	if [ "${IF_DHCPD_CONFIG}" = "${IF_DHCPD_CONFIG#/}" ]
	then	IF_DHCPD_CONFIG=${DHCPD_CONFIG_DIR}/${IF_DHCPD_CONFIG}
	fi
# Probe the location, first try ifupdown's logical name, then physical name
elif [ -e "${DHCPD_CONFIG_DIR}/udhcpd.${LOGICAL}.conf" ]
then	IF_DHCPD_CONFIG="${DHCPD_CONFIG_DIR}/udhcpd.${LOGICAL}.conf"
elif [ -e "${DHCPD_CONFIG_DIR}/udhcpd.${IFACE}.conf" ]
then	IF_DHCPD_CONFIG="${DHCPD_CONFIG_DIR}/udhcpd.${IFACE}.conf"
else	IF_DHCPD_CONFIG="${DHCPD_CONFIG_DIR}/udhcpd.conf"
fi

# Has the .pid file been specified?  Is it relative?
if [ -n "${IF_DHCPD_PIDFILE}" ]
then	if [ "${IF_DHCPD_PIDFILE}" = "${IF_DHCPD_PIDFILE#/}" ]
	then	IF_DHCPD_PIDFILE=/run/${IF_DHCPD_PIDFILE}
	fi
# Look for the .pid file in the configuration file
else	if grep -q -E -e^\[\[:space:]]\*pidfile\[\[:space:]] ${IF_DHCPD_CONFIG}
	then	IF_DHCPD_PIDFILE=`grep -E -e^\[\\\[:space:]]\*pidfile\[\\\[:space:]] ${IF_DHCPD_CONFIG} | sed -es/^\[\\\[:space:]]\*pidfile\[\\\[:space:]]\\\\+//`
	else	IF_DHCPD_PIDFILE=/run/udhcpd.pid
	fi
fi

# This works better for us
[ "${VERBOSITY}" = 0 ] && VERBOSITY=""

case "$MODE" in
	start)
		[ -n "${VERBOSITY}" ] && echo -n "Starting $DESC: "
		start-stop-daemon --start ${VERBOSITY:+--verbose} \
			--pidfile ${IF_DHCPD_PIDFILE} --oknodo --exec $DAEMON \
			-- ${IF_DHCPD_OPTS:-${DHCPD_OPTS}} ${IF_DHCPD_CONFIG}
		[ -n "${VERBOSITY}" ] && echo "$NAME."
	;;
	stop)
		[ -n "${VERBOSITY}" ] && echo -n "Stopping $DESC: "
		start-stop-daemon --stop ${VERBOSITY:+--verbose} \
			--pidfile ${IF_DHCPD_PIDFILE} --oknodo --exec $DAEMON
		[ -n "${VERBOSITY}" ] && echo "$NAME."
	;;
	*)
		echo "Usage: $0 {start|stop}" >&2
		exit 1
	;;
esac

exit 0

Reply to: