aboutsummaryrefslogtreecommitdiff
path: root/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample
diff options
context:
space:
mode:
Diffstat (limited to 'net/isc-dhcp40-server/files/isc-dhcpd.sh.sample')
-rw-r--r--net/isc-dhcp40-server/files/isc-dhcpd.sh.sample69
1 files changed, 57 insertions, 12 deletions
diff --git a/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample b/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample
index bd9f10dbc3fd..17472ab3bb71 100644
--- a/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample
+++ b/net/isc-dhcp40-server/files/isc-dhcpd.sh.sample
@@ -1,32 +1,77 @@
#! /bin/sh
-
+#
# $FreeBSD$
+#
+# Start or stop isc-dhcpd.
+#
+
+rc_file=${0##*/}
+rc_arg=$1
+
+# override these variables in ${PREFIX}/etc/rc.isc-dhcpd.conf
+dhcpd_options= # command option(s)
+dhcpd_ifaces= # ethernet interface(s)
+
+if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/${rc_file}\$"); then
+ echo "${rc_file}: Cannot determine PREFIX." >&2
+ echo "Please use the complete pathname." >&2
+ exit 64
+fi
-OPTIONS=""
-IFACES=""
+rcconf_dir=${PREFIX}/etc
+rcconf_file=rc.${rc_file%.sh}.conf
+rcconf_path=${rcconf_dir}/${rcconf_file}
-if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then
- echo "$0: Cannot determine the PREFIX" >&2
- exit 1
+if [ -f ${rcconf_path} ]; then
+ . ${rcconf_path}
fi
-case "$1" in
+program_dir=${PREFIX}/sbin
+program_file=dhcpd
+program_path=${program_dir}/${program_file}
+
+config_dir=${PREFIX}/etc
+config_file=${program_file}.conf
+config_path=${config_dir}/${config_file}
+
+pid_dir=/var/run
+pid_file=${program_file}.pid
+pid_path=${pid_dir}/${pid_file}
+
+syslog_facility=daemon.err
+
+case "$rc_arg" in
start)
- ${PREFIX}/sbin/dhcpd $OPTIONS $IFACES > /dev/null 2>&1
- echo -n ' dhcpd'
+ if [ ! -x ${program_path} ]; then
+ logger -sp ${syslog_facility} -t ${program_file} \
+ "unable to start: ${program_path} is missing."
+ exit 72
+ fi
+ if [ ! -f ${config_path} ]; then
+ logger -sp ${syslog_facility} -t ${program_file} \
+ "unable to start: ${config_path} is missing."
+ exit 72
+ fi
+ ${program_path} ${dhcpd_options} ${dhcpd_ifaces} &&
+ echo -n " ${program_file}"
;;
stop)
- killall dhcpd
+ if [ -r ${pid_path} ]; then
+ kill $(cat ${pid_path}) 2> /dev/null
+ else
+ killall ${program_file} 2> /dev/null
+ fi
;;
restart)
$0 stop
$0 start
;;
status)
- ps -auxww | egrep '(conserver|console)' | egrep -v "($0|egrep)"
+ ps -auxww | egrep ${program_file} | egrep -v "($0|egrep)"
;;
*)
- echo "usage: ${0##*/} {start|stop|restart|status}" >&2
+ echo "usage: ${rc_file} {start|stop|restart|status}" >&2
+ exit 64
;;
esac