forked from greearb/dhcp-ct
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdhcrelay.init
121 lines (103 loc) · 2.45 KB
/
dhcrelay.init
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/sh
#
### BEGIN INIT INFO
# Provides: dhcrelay
# Default-Start:
# Default-Stop:
# Should-Start:
# Required-Start: $network
# Required-Stop:
# Short-Description: Start and stop the DHCP relay server
# Description: dhcrelay provides the Dynamic Host Configuration Protocol (DHCP)
# relay server. This is required when your DHCP server is on
# another network segment from the clients.
### END INIT INFO
#
# The fields below are left around for legacy tools (will remove later).
#
# chkconfig: - 65 35
# description: dhcrelay provides a relay for Dynamic Host Control Protocol.
# processname: dhcrelay
# # pidfile: /var/run/dhcrelay.pid
. /etc/rc.d/init.d/functions
RETVAL=0
prog=dhcrelay
exec=/usr/sbin/dhcrelay
lockfile=/var/lock/subsys/dhcrelay
pidfile=/var/run/dhcrelay.pid
config=/etc/sysconfig/dhcrelay
# The dhcrelay daemon uses the sysconfig file for configuration information.
# There is no native configuration file for this program and you must specify
# its settings on the command line.
[ -f /etc/sysconfig/dhcrelay ] && . /etc/sysconfig/dhcrelay
configtest() {
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
[ -z "$DHCPSERVERS" ] && exit 6
return 0
}
rh_status() {
status $exec
}
rh_status_q() {
rh_status >/dev/null 2>&1
}
start() {
[ `id -u` -eq 0 ] || exit 4
[ -x $exec ] || exit 5
[ -f $config ] || exit 6
rh_status_q && return 0
echo -n $"Starting $prog: "
daemon $exec $DHCRELAYARGS $([ -n "$INTERFACES" ] && for int in $INTERFACES ; do echo -n " -i $int" ; done) $DHCPSERVERS 2>/dev/null
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch $lockfile
return $RETVAL
}
stop() {
[ `id -u` -eq 0 ] || exit 4
rh_status_q || return 0
echo -n $"Shutting down $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && rm -f $lockfile
return $RETVAL
}
usage() {
echo $"Usage: $0 {start|stop|restart|force-reload|condrestart|try-restart|configtest|status}"
}
if [ $# -gt 1 ]; then
exit 2
fi
case "$1" in
start)
start
;;
stop)
stop
;;
restart|force-reload)
stop ; start
;;
condrestart|try-restart)
rh_status_q || exit 0
stop ; start
;;
reload)
usage
# unimplemented feature
exit 3
;;
configtest)
configtest
;;
status)
rh_status
;;
*)
usage
exit 2
;;
esac
exit $?