]>
Commit | Line | Data |
---|---|---|
332ceb62 | 1 | #!/bin/sh |
a5333732 | 2 | # DHCP relay agent |
332ceb62 | 3 | # |
31822625 | 4 | # chkconfig: 345 80 20 |
a5333732 | 5 | # description: DHCP relay agent |
332ceb62 | 6 | |
7 | # Source function library. | |
8 | . /etc/rc.d/init.d/functions | |
9 | ||
3b314dfa JR |
10 | # Source networking configuration. |
11 | . /etc/sysconfig/network | |
12 | ||
13 | # Demon specified configuration. | |
9ce40d98 | 14 | OPTIONS="" |
3b314dfa | 15 | . /etc/sysconfig/dhcp-relay |
332ceb62 | 16 | |
3b314dfa | 17 | # Check that networking is up. |
dfbb7f59 | 18 | if is_yes "${NETWORKING}"; then |
d91f786f | 19 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status ]; then |
dfbb7f59 | 20 | msg_network_down "DHCP realay" |
21 | exit 1 | |
22 | fi | |
23 | else | |
24 | exit 0 | |
3b314dfa | 25 | fi |
332ceb62 | 26 | |
9ce40d98 JK |
27 | if [ -n "DHCP_RELAY_INTERFACES" ]; then |
28 | for iface in $DHCP_RELAY_INTERFACES ; do | |
29 | OPTIONS="$OPTIONS -i $iface" | |
30 | done | |
dde046a6 | 31 | fi |
32 | ||
915cd150 | 33 | RETVAL=0 |
332ceb62 | 34 | # See how we were called. |
35 | case "$1" in | |
36 | start) | |
a5333732 | 37 | # Check if the service is already running? |
6dfd82ed | 38 | if [ ! -f /var/lock/subsys/dhcp-relay ]; then |
a5333732 | 39 | msg_starting "DHCP relay" |
40 | daemon dhcrelay $OPTIONS $DHCP_SERVERS_IP | |
41 | RETVAL=$? | |
6dfd82ed | 42 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/dhcp-relay |
a5333732 | 43 | else |
badf1526 | 44 | msg_already_running "DHCP relay" |
13f26ef2 | 45 | fi |
332ceb62 | 46 | ;; |
47 | stop) | |
915cd150 | 48 | if [ -f /var/lock/subsys/dhcp-relay ]; then |
49 | msg_stopping "DHCP relay" | |
50 | killproc dhcrelay | |
51 | rm -f /var/lock/subsys/dhcp-relay | |
52 | else | |
53 | msg_not_running "DHCP relay" | |
54 | fi | |
332ceb62 | 55 | ;; |
915cd150 | 56 | restart|force-reload) |
332ceb62 | 57 | $0 stop |
58 | $0 start | |
915cd150 | 59 | exit $? |
332ceb62 | 60 | ;; |
61 | status) | |
ddd9a79d | 62 | status dhcrelay |
915cd150 | 63 | exit $? |
332ceb62 | 64 | ;; |
65 | *) | |
915cd150 | 66 | msg_usage "$0 {start|stop|restart|force-reload|status}" |
67 | exit 3 | |
332ceb62 | 68 | esac |
69 | ||
a5333732 | 70 | exit $RETVAL |