1af714d69b60584e5c6f38d7349addb0aeecb218
[packages/trusty/cirros-testvm.git] / cirros-testvm / src-cirros / buildroot-2015.05 / package / netplug / netplug-script
1 #!/bin/sh
2 #
3 # netplug - policy agent for netplugd
4 #
5 # Copyright 2003 Key Research, Inc.
6 #
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License, version 2, as
9 # published by the Free Software Foundation.  You are forbidden from
10 # redistributing or modifying it under the terms of any other license,
11 # including other versions of the GNU General Public License.
12 #
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # General Public License for more details.
17
18
19 PATH=/usr/bin:/bin:/usr/sbin:/sbin
20 export PATH
21
22 dev="$1"
23 action="$2"
24
25 case "$action" in
26 in)
27     if [ -x /sbin/ifup ]; then
28         exec /sbin/ifup $dev
29     else
30         echo "Please teach me how to plug in an interface!" 1>&2
31         exit 1
32     fi
33     ;;
34 out)
35     if [ -x /sbin/ifdown ]; then
36         # At least on Fedora Core 1, the call to ip addr flush infloops
37         # /sbin/ifdown $dev && exec /sbin/ip addr flush $dev
38         exec /sbin/ifdown $dev
39     else
40         echo "Please teach me how to unplug an interface!" 1>&2
41         exit 1
42     fi
43     ;;
44 probe)
45     # exec /sbin/ip link set $dev up >/dev/null 2>&1
46     if [ -x /sbin/ifconfig ]; then
47         exec /sbin/ifconfig $dev up >/dev/null 2>&1
48     else
49         echo "Failed to probe an interface!" 1>&2
50         exit 1
51     fi
52     ;;
53 *)
54     echo "I have been called with a funny action of '%s'!" 1>&2
55     exit 1
56     ;;
57 esac