]>
Commit | Line | Data |
---|---|---|
305ab4a5 AM |
1 | #!/bin/sh |
2 | # | |
3 | # ifplugd ifplugd | |
4 | # | |
5 | # chkconfig: 345 16 84 | |
6 | # | |
7 | # description: ifplugd | |
8 | ||
9 | ||
10 | # Source function library | |
11 | . /etc/rc.d/init.d/functions | |
12 | ||
13 | # Get network config | |
14 | . /etc/sysconfig/network | |
15 | ||
16 | # Get service config | |
17 | [ -f /etc/sysconfig/ifplugd ] && . /etc/sysconfig/ifplugd | |
18 | ||
19 | # Check that networking is up. | |
20 | if is_yes "${NETWORKING}"; then | |
21 | if [ ! -f /var/lock/subsys/network -a "$1" != stop -a "$1" != status -a "$1" != init ]; then | |
22 | msg_network_down ifplugd | |
23 | exit 1 | |
24 | fi | |
25 | else | |
26 | exit 0 | |
27 | fi | |
28 | ||
cd1b0100 | 29 | start() { |
305ab4a5 | 30 | # Check if the service is already running? |
c7e116f3 ER |
31 | if [ ! -f /var/lock/subsys/ifplugd ]; then |
32 | for iface in $INTERFACES; do | |
33 | if [ ! -f /var/lock/subsys/ifplugd.${iface} ]; then | |
34 | msg_starting "Network Interface Plugging Daemon ($iface)" | |
35 | args=$(eval echo \$\{ARGS_${IF}\}) | |
36 | [ -z "$args" ] && args="${ARGS}" | |
37 | daemon /sbin/ifplugd -i ${iface} ${args} | |
38 | RETVAL=$? | |
39 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ifplugd.${iface} | |
40 | else | |
41 | msg_already_running "ifplugd ($iface)" | |
42 | fi | |
43 | done | |
44 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ifplugd | |
45 | else | |
46 | msg_already_running "Network Interface Plugging Daemon" | |
47 | fi | |
cd1b0100 ER |
48 | } |
49 | ||
50 | stop() { | |
c7e116f3 ER |
51 | if [ -f /var/lock/subsys/ifplugd ]; then |
52 | for iface in $INTERFACES; do | |
53 | if [ -f /var/lock/subsys/ifplugd.${iface} ]; then | |
54 | msg_stopping "Network Interface Plugging Daemon ($iface)" | |
55 | daemon /sbin/ifplugd -k -i ${iface} | |
56 | RETVAL=$? | |
57 | else | |
58 | msg_not_running "ifplugd ($iface)" | |
59 | fi | |
60 | done | |
61 | rm -f /var/run/ifplugd.pid /var/lock/subsys/ifplugd* >/dev/null 2>&1 | |
62 | else | |
63 | msg_not_running "Network Interface Plugging Daemon" | |
64 | fi | |
cd1b0100 ER |
65 | } |
66 | ||
cd1b0100 ER |
67 | [ -n "$2" ] && INTERFACES="$2" |
68 | ||
69 | [ -z "$INTERFACES" -o "$INTERFACES" = "auto" ] && INTERFACES=$(awk -F: '/(eth|wlan)/ { print $1 }' /proc/net/dev | xargs) | |
70 | ||
71 | RETVAL=0 | |
72 | # See how we were called. | |
73 | case "$1" in | |
74 | start) | |
75 | start | |
76 | ;; | |
77 | stop) | |
78 | stop | |
79 | ;; | |
c7e116f3 ER |
80 | restart) |
81 | stop | |
82 | start | |
83 | ;; | |
cd1b0100 | 84 | suspend) |
2236ab64 ER |
85 | for iface in $INTERFACES; do |
86 | if [ -f /var/lock/subsys/ifplugd.${iface} ]; then | |
87 | msg_stopping "Network Interface Plugging Daemon (suspending $iface)" | |
88 | daemon /sbin/ifplugd -S -i ${iface} | |
89 | RETVAL=$? | |
90 | else | |
91 | msg_not_running "ifplugd ($iface)" | |
92 | fi | |
93 | done | |
cd1b0100 ER |
94 | ;; |
95 | resume) | |
c7e116f3 ER |
96 | for iface in $INTERFACES; do |
97 | if [ -f /var/lock/subsys/ifplugd.${iface} ]; then | |
98 | msg_starting "Network Interface Plugging Daemon (resuming $iface)" | |
99 | daemon /sbin/ifplugd -R -i ${iface} | |
100 | RETVAL=$? | |
101 | else | |
102 | msg_not_running "ifplugd ($iface)" | |
103 | fi | |
104 | done | |
305ab4a5 AM |
105 | ;; |
106 | status) | |
107 | status /sbin/ifplugd | |
cd1b0100 | 108 | RETVAL=$? |
305ab4a5 | 109 | for iface in $INTERFACES; do |
cd1b0100 ER |
110 | /sbin/ifplugd -c -i $iface |
111 | ret=$? | |
112 | [ $ret -gt 0 ] && RETVAL=$ret | |
305ab4a5 | 113 | done |
305ab4a5 | 114 | ;; |
41ec72b6 | 115 | reload|force-reload) |
2236ab64 ER |
116 | if [ -f /var/lock/subsys/ifplugd ]; then |
117 | stop | |
118 | sleep 2 | |
119 | start | |
120 | RETVAL=$? | |
121 | else | |
122 | msg_not_running ifplugd | |
123 | exit 7 | |
124 | fi | |
41ec72b6 | 125 | ;; |
305ab4a5 | 126 | *) |
78b1de35 | 127 | msg_usage "$0 {start|stop|restart|reload|suspend|resume|force-reload|status}" |
305ab4a5 AM |
128 | exit 3 |
129 | esac | |
130 | ||
131 | exit $RETVAL |