]> git.pld-linux.org Git - packages/ifplugd.git/blob - ifplugd.init
- killed trailing spaces/tabs
[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 [ -z "$INTERFACES" -o "$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         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}\})
42                 [ -z "$args" ] && args="${ARGS}"
43                 daemon /sbin/ifplugd -i ${iface} ${args}
44                 RETVAL=$?
45                 [ $RETVAL -eq 0 ] && touch /var/lock/subsys/ifplugd.${iface}
46             else
47                 msg_already_running "ifplugd ($iface)"
48             fi
49         done
50         ;;
51   stop)
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         ;;
63   suspend)
64         for iface in $INTERFACES; do
65             if [ -f /var/lock/subsys/ifplugd.${iface} ]; then
66                 msg_stopping "Network Interface Plugging Daemon (suspending $iface)"
67                 daemon /sbin/ifplugd -S -i ${iface}
68                 RETVAL=$?
69             else
70                 msg_not_running "ifplugd ($iface)"
71             fi
72         done
73         ;;
74    resume)
75         for iface in $INTERFACES; do
76             if [ -f /var/lock/subsys/ifplugd.${iface} ]; then
77                 msg_starting "Network Interface Plugging Daemon (resuming $iface)"
78                 daemon /sbin/ifplugd -R -i ${iface}
79                 RETVAL=$?
80             else
81                 msg_not_running "ifplugd ($iface)"
82             fi
83         done
84         ;;
85   restart)
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         ;;
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         ;;
108   *)
109         msg_usage "$0 {start|stop|restart|reload|force-reload|status}"
110         exit 3
111 esac
112
113 exit $RETVAL
This page took 0.067076 seconds and 3 git commands to generate.