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