]>
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 | ||
29 | [ -n "$2" ] && INTERFACES="$2" | |
30 | ||
41ec72b6 AM |
31 | [ -z "$INTERFACES" -o "$INTERFACES" = "auto" ] && INTERFACES=$(awk -F: '/(eth|wlan)/ { print $1 }' /proc/net/dev | xargs) |
32 | ||
305ab4a5 AM |
33 | RETVAL=0 |
34 | # See how we were called. | |
35 | case "$1" in | |
36 | start) | |
37 | # Check if the service is already running? | |
41ec72b6 AM |
38 | for iface in $INTERFACES; do |
39 | if [ ! -f /var/lock/subsys/ifplugd.${iface} ]; then | |
40 | msg_starting "Network Interface Plugging Daemon ($iface)" | |
41 | args=$(eval echo \$\{ARGS_${IF}\}) | |
305ab4a5 AM |
42 | [ -z "$args" ] && args="${ARGS}" |
43 | daemon /sbin/ifplugd -i ${iface} ${args} | |
41ec72b6 AM |
44 | RETVAL=$? |
45 | [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ifplugd.${iface} | |
46 | else | |
47 | msg_already_running "ifplugd ($iface)" | |
48 | fi | |
49 | done | |
305ab4a5 AM |
50 | ;; |
51 | stop) | |
41ec72b6 AM |
52 | for iface in $INTERFACES; do |
53 | if [ -f /var/lock/subsys/ifplugd.${iface} ]; then | |
305ab4a5 AM |
54 | msg_stopping "Network Interface Plugging Daemon ($iface)" |
55 | daemon /sbin/ifplugd -k -i ${iface} | |
41ec72b6 AM |
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 | |
305ab4a5 AM |
62 | ;; |
63 | suspend) | |
41ec72b6 AM |
64 | for iface in $INTERFACES; do |
65 | if [ -f /var/lock/subsys/ifplugd.${iface} ]; then | |
305ab4a5 AM |
66 | msg_stopping "Network Interface Plugging Daemon (suspending $iface)" |
67 | daemon /sbin/ifplugd -S -i ${iface} | |
41ec72b6 AM |
68 | RETVAL=$? |
69 | else | |
70 | msg_not_running "ifplugd ($iface)" | |
71 | fi | |
72 | done | |
305ab4a5 AM |
73 | ;; |
74 | resume) | |
41ec72b6 AM |
75 | for iface in $INTERFACES; do |
76 | if [ -f /var/lock/subsys/ifplugd.${iface} ]; then | |
305ab4a5 AM |
77 | msg_starting "Network Interface Plugging Daemon (resuming $iface)" |
78 | daemon /sbin/ifplugd -R -i ${iface} | |
41ec72b6 AM |
79 | RETVAL=$? |
80 | else | |
81 | msg_not_running "ifplugd ($iface)" | |
82 | fi | |
83 | done | |
305ab4a5 | 84 | ;; |
41ec72b6 | 85 | restart) |
305ab4a5 AM |
86 | $0 stop |
87 | $0 start | |
88 | exit $? | |
89 | ;; | |
90 | status) | |
91 | status /sbin/ifplugd | |
92 | for iface in $INTERFACES; do | |
93 | /sbin/ifplugd -c -i ${iface} | |
94 | done | |
95 | exit $? | |
96 | ;; | |
41ec72b6 AM |
97 | reload|force-reload) |
98 | if [ -f /var/lock/subsys/ifplugd ]; then | |
99 | $0 stop | |
100 | sleep 2 | |
101 | $0 start | |
102 | RETVAL=$? | |
103 | else | |
104 | msg_not_running ifplugd >&2 | |
105 | exit 7 | |
106 | fi | |
107 | ;; | |
305ab4a5 | 108 | *) |
41ec72b6 | 109 | msg_usage "$0 {start|stop|restart|reload|force-reload|status}" |
305ab4a5 AM |
110 | exit 3 |
111 | esac | |
112 | ||
113 | exit $RETVAL |