DHCRelay multiple
#!/bin/sh
#
#
### BEGIN INIT INFO
# Provides: isc-dhcp-relay
# Required-Start: $remote_fs $network
# Required-Stop: $remote_fs $network
# Should-Start: $local_fs
# Should-Stop: $local_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: DHCP relay
# Description: Dynamic Host Configuration Protocol Relay
### END INIT INFO
# It is not safe to start if we don't have a default configuration...
if [ ! -f /etc/default/isc-dhcp-relay ]; then
echo "/etc/default/isc-dhcp-relay does not exist! - Aborting..."
echo "Run 'dpkg-reconfigure isc-dhcp-relay' to fix the problem."
exit 1
fi
case "$1" in
start)
for file in `ls /etc/default/isc-dhcp-relay*`; do
SERVERS=""
INTERFACES=""
OPTIONS=""
. $file
file=`basename $file`
echo $file
DHCRELAYPID=/var/run/dhcrelay-$file.pid
OPTIONS="$OPTIONS -pf $DHCRELAYPID"
# Build command line for interfaces (will be passed to dhrelay below.)
IFCMD=""
if test "$INTERFACES" != ""; then
for I in $INTERFACES; do
IFCMD=${IFCMD}"-i "${I}" "
done
fi
start-stop-daemon --start --quiet --pidfile $DHCRELAYPID \
--exec /usr/sbin/dhcrelay -- -q $OPTIONS $IFCMD $SERVERS
done
;;
stop)
for file in `ls /etc/default/isc-dhcp-relay*`; do
file=`basename $file`
echo $file
DHCRELAYPID=/var/run/dhcrelay-$file.pid
start-stop-daemon --stop --quiet --pidfile $DHCRELAYPID
done
;;
restart | force-reload)
$0 stop
sleep 2
$0 start
;;
*)
echo "Usage: /etc/init.d/isc-dhcp-relay {start|stop|restart|force-reload}"
exit 1
esac
exit 0
Du coup, on peut créer plusieurs fichiers dans /etc/default/isc-dhcp-relay, en mettant une extension différente.