2
# $Id: ifplugd.init.in 43 2003-09-13 11:25:11Z lennart $
4
# This file is part of ifplugd.
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.
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
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.
22
# Required-Start: $network $remote_fs
23
# Required-Stop: $network $remote_fs
24
# Default-Start: 2 3 4 5
26
# Short-Description: Brings up/down network automatically
27
# Description: Brings networks interfaces up and down automatically when
28
# the cable is removed / inserted
32
CFG=/etc/default/$DAEMON_NAME
33
DESC="Network Interface Plugging Daemon"
34
IFPLUGD=/usr/sbin/$DAEMON_NAME
35
test -x $IFPLUGD || exit 0
37
if [ `id -u` != "0" ] && [ "$1" = "start" -o "$1" = "stop" ] ; then
38
echo "You must be root to start, stop or restart ifplugd."
47
[ $# -ne 0 ] && INTERFACES="$@"
50
for IFPATH in /sys/class/net/* ; do
51
IFNAME="${IFPATH#/sys/class/net/}"
53
[ -e "$IFPATH/device" ] || continue
55
if [ -f "$IFPATH/type" ] ; then
56
grep --quiet '^1$' "$IFPATH/type" || continue
67
[ "x$INTERFACES" = "xauto" -o "x$INTERFACES" = "xall" ] && INTERFACES="$(all_interfaces)"
69
. /lib/lsb/init-functions
73
[ "$INTERFACES" ] || exit 0
74
log_action_begin_msg "$DESC"
75
for IF in $INTERFACES ; do
76
if [ ! -e /sys/class/net/$IF ] || \
77
$IFPLUGD -c -i $IF >/dev/null ; then
78
log_action_cont_msg "skip $IF"
81
log_action_cont_msg "start $IF"
82
IF1=$(echo $IF | sed "s/-/_/")
83
A=$(eval echo \$\{ARGS_${IF1}\})
84
[ -z "$A" ] && A="$ARGS"
90
[ "$INTERFACES" ] || exit 0
91
log_action_begin_msg "$DESC"
92
for IF in $INTERFACES ; do
93
if [ ! -e /sys/class/net/$IF ] || \
94
! $IFPLUGD -c -i $IF >/dev/null ; then
95
log_action_cont_msg "skip $IF"
98
log_action_cont_msg "stop $IF"
99
$IFPLUGD -k --wait-on-kill -i $IF
104
[ "$INTERFACES" -o "$HOTPLUG_INTERFACES" ] || exit 0
105
for IF in $INTERFACES $HOTPLUG_INTERFACES ; do
106
if [ ! -e /sys/class/net/$IF ] ; then
107
log_action_msg "$IF: device $IF is either not present or not functional"
110
log_begin_msg "$IF: "
115
[ "$INTERFACES" -o "$HOTPLUG_INTERFACES" ] || exit 0
116
log_action_begin_msg "$DESC"
117
for IF in $INTERFACES $HOTPLUG_INTERFACES ; do
118
if [ ! -e /sys/class/net/$IF ] || \
119
! $IFPLUGD -c -i $IF >/dev/null ; then
120
log_action_cont_msg "skip $IF"
123
log_action_cont_msg "suspend $IF"
129
[ "$INTERFACES" -o "$HOTPLUG_INTERFACES" ] || exit 0
130
log_action_begin_msg "$DESC"
131
for IF in $INTERFACES $HOTPLUG_INTERFACES ; do
132
if [ ! -e /sys/class/net/$IF ] || \
133
! $IFPLUGD -c -i $IF >/dev/null ; then
134
log_action_cont_msg "skip $IF"
137
log_action_cont_msg "resume $IF"
142
force-reload|restart)
143
[ "$INTERFACES" ] || exit 0
149
echo "Usage: $0 {start|stop|restart|force-reload|status|suspend|resume}"