summaryrefslogtreecommitdiff
blob: 6ae0dcd1b54299a32acbbcb68e0d9f8f1d328af3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
#
# Gentoo-specific netplug script 
#
# This file gets called by netplug when it wants to bring an interface
# up or down.
#

IFACE="$1"
ACTION="$2"

if grep -q initng /proc/1/cmdline 
then
    EXEC="/sbin/ngc"
    INITNG="yes"
else
    EXEC="/etc/init.d/net.${IFACE}"
    INITNG="no"
fi

case "${ACTION}" in
    in)
	if [ "${INITNG}" = "yes" ]
	then
	    ARGS="-u net/${IFACE}"
	else
	    ARGS="--quiet start"
	fi
	;;
    out)
	if [ "${INITNG}" = "yes" ]
	then
	    ARGS="-d net/${IFACE}"
	else
	    ARGS="--quiet stop"
	fi
	;;
    probe)
	# Do nothing as we should already be up
	;;
    *)
	echo "$0: wrong arguments" >&2
	echo "Call with <interface> <in|out|probe>" >&2
	exit 1
	;;
esac

export IN_BACKGROUND=true

if [ -x "${EXEC}" ]
then
    ${EXEC} ${ARGS}
    exit 0
else
    logger -t netplug "Error: Couldn't configure ${IFACE}, no ${EXEC} !"
    exit 1
fi

# vim: set ts=4