1 | #!/bin/bash |
---|
2 | # $Id: ifplugd.init.in,v 1.3 2005-09-09 17:52:09 ghudson Exp $ |
---|
3 | |
---|
4 | # This file is part of ifplugd. |
---|
5 | # |
---|
6 | # ifplugd is free software; you can redistribute it and/or modify it under |
---|
7 | # the terms of the GNU General Public License as published by the Free |
---|
8 | # Software Foundation; either version 2 of the License, or (at your |
---|
9 | # option) any later version. |
---|
10 | # |
---|
11 | # ifplugd is distributed in the hope that it will be useful, but WITHOUT |
---|
12 | # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
---|
13 | # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
---|
14 | # for more details. |
---|
15 | # |
---|
16 | # You should have received a copy of the GNU General Public License |
---|
17 | # along with ifplugd; if not, write to the Free Software Foundation, |
---|
18 | # Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. |
---|
19 | |
---|
20 | # ifplugd Brings up/down network automatically |
---|
21 | # |
---|
22 | # chkconfig: 2345 11 89 |
---|
23 | # description: Brings networks interfaces up and down automatically when \ |
---|
24 | # the cable is removed / inserted |
---|
25 | # |
---|
26 | # processname: @sbindir@/ifplugd |
---|
27 | # config: @sysconfdir@/ifplugd/ifplugd.conf |
---|
28 | |
---|
29 | # |
---|
30 | # Source the Athena configuration. |
---|
31 | # |
---|
32 | if [ -f /etc/athena/rc.conf ]; then |
---|
33 | . /etc/athena/rc.conf |
---|
34 | [ true = "$DISCONNECTABLE" ] || exit 0 |
---|
35 | fi |
---|
36 | |
---|
37 | CFG=@sysconfdir@/ifplugd/ifplugd.conf |
---|
38 | |
---|
39 | IFPLUGD=@sbindir@/ifplugd |
---|
40 | test -x $IFPLUGD || exit 0 |
---|
41 | |
---|
42 | if [ `id -u` != "0" ] && [ "$1" = "start" -o "$1" = "stop" ] ; then |
---|
43 | echo "You must be root to start, stop or restart ifplugd." |
---|
44 | exit 1 |
---|
45 | fi |
---|
46 | |
---|
47 | [ -f $CFG ] && . $CFG |
---|
48 | |
---|
49 | VERB="$1" |
---|
50 | shift |
---|
51 | |
---|
52 | [ "x$*" != "x" ] && INTERFACES="$*" |
---|
53 | |
---|
54 | [ "x$INTERFACES" = "xauto" ] && INTERFACES="`cat /proc/net/dev | awk '{ print $1 }' | egrep '^(eth|wlan)' | cut -d: -f1`" |
---|
55 | |
---|
56 | case "$VERB" in |
---|
57 | start) |
---|
58 | echo -n "Starting Network Interface Plugging Daemon:" |
---|
59 | for IF in $INTERFACES ; do |
---|
60 | A="`eval echo \$\{ARGS_${IF}\}`" |
---|
61 | [ -z "$A" ] && A="$ARGS" |
---|
62 | $IFPLUGD -i $IF $A |
---|
63 | echo -n " $IF" |
---|
64 | done |
---|
65 | echo "." |
---|
66 | ;; |
---|
67 | stop) |
---|
68 | echo -n "Stopping Network Interface Plugging Daemon:" |
---|
69 | for IF in $INTERFACES ; do |
---|
70 | $IFPLUGD -k -i $IF |
---|
71 | echo -n " $IF" |
---|
72 | done |
---|
73 | echo "." |
---|
74 | ;; |
---|
75 | status) |
---|
76 | for IF in $INTERFACES ; do |
---|
77 | $IFPLUGD -c -i $IF |
---|
78 | done |
---|
79 | ;; |
---|
80 | suspend) |
---|
81 | echo -n "Suspending Network Interface Plugging Daemon:" |
---|
82 | for IF in $INTERFACES ; do |
---|
83 | $IFPLUGD -S -i $IF |
---|
84 | echo -n " $IF" |
---|
85 | done |
---|
86 | echo "." |
---|
87 | ;; |
---|
88 | resume) |
---|
89 | echo -n "Resuming Network Interface Plugging Daemon:" |
---|
90 | for IF in $INTERFACES ; do |
---|
91 | $IFPLUGD -R -i $IF |
---|
92 | echo -n " $IF" |
---|
93 | done |
---|
94 | echo "." |
---|
95 | ;; |
---|
96 | force-reload|restart) |
---|
97 | $0 stop $INTERFACES |
---|
98 | sleep 3 |
---|
99 | $0 start $INTERFACES |
---|
100 | ;; |
---|
101 | *) |
---|
102 | echo "Usage: $0 {start|stop|restart|force-reload|status|suspend|resume}" |
---|
103 | exit 1 |
---|
104 | esac |
---|
105 | |
---|
106 | exit 0 |
---|