]> git.pld-linux.org Git - packages/ifplugd.git/blob - ifplugd.init
- removed reload: it should work without stopping the service; resume/suspend to...
[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|force-reload)
90         $0 stop
91         sleep 2
92         $0 start
93         exit $?
94         ;;
95   status)
96         status /sbin/ifplugd
97         for iface in $INTERFACES; do
98             /sbin/ifplugd -c -i ${iface}
99         done
100         exit $?
101         ;;
102   *)
103         msg_usage "$0 {start|stop|restart|force-reload|status|resume|suspend}"
104         exit 3
105 esac
106
107 exit $RETVAL
This page took 0.048787 seconds and 3 git commands to generate.