kill pltap-ovs on create-bridge timeout
[sliver-openvswitch.git] / debian / ifupdown.sh
1 #! /bin/sh
2
3 # Copyright (c) 2012 Nicira, Inc.
4 #
5 # Licensed under the Apache License, Version 2.0 (the "License");
6 # you may not use this file except in compliance with the License.
7 # You may obtain a copy of the License at:
8 #
9 #     http://www.apache.org/licenses/LICENSE-2.0
10 #
11 # Unless required by applicable law or agreed to in writing, software
12 # distributed under the License is distributed on an "AS IS" BASIS,
13 # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 # See the License for the specific language governing permissions and
15 # limitations under the License.
16
17 # Have a look at /usr/share/doc/openvswitch-switch/README.Debian
18 # for more information about configuring the /etc/network/interfaces.
19
20 if [ -z "${IF_OVS_TYPE}" ]; then
21     exit 0
22 fi
23
24 ovs_vsctl() {
25     ovs-vsctl --timeout=5 "$@"
26 }
27
28 if (ovs_vsctl --version) > /dev/null 2>&1; then :; else
29     exit 0
30 fi
31
32 if [ "${MODE}" = "start" ]; then
33     eval OVS_EXTRA=\"${IF_OVS_EXTRA}\"
34
35     case "${IF_OVS_TYPE}" in
36         OVSBridge)
37                 ovs_vsctl -- --may-exist add-br "${IFACE}" ${IF_OVS_OPTIONS}\
38                          ${OVS_EXTRA+-- $OVS_EXTRA}
39
40                 if [ ! -z "${IF_OVS_PORTS}" ]; then
41                     ifup --allow="${IFACE}" ${IF_OVS_PORTS}
42                 fi
43                 ;;
44         OVSPort)
45                 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
46                     "${IFACE}" ${IF_OVS_OPTIONS} \
47                     ${OVS_EXTRA+-- $OVS_EXTRA}
48
49                 ifconfig "${IFACE}" up
50                 ;;
51         OVSIntPort)
52                 ovs_vsctl -- --may-exist add-port "${IF_OVS_BRIDGE}"\
53                     "${IFACE}" ${IF_OVS_OPTIONS} -- set Interface "${IFACE}"\
54                     type=internal ${OVS_EXTRA+-- $OVS_EXTRA}
55
56                 ifconfig "${IFACE}" up
57                 ;;
58         OVSBond)
59                 ovs_vsctl -- --fake-iface add-bond "${IF_OVS_BRIDGE}"\
60                     "${IFACE}" ${IF_OVS_BONDS} ${IF_OVS_OPTIONS} \
61                     ${OVS_EXTRA+-- $OVS_EXTRA}
62
63                 ifconfig "${IFACE}" up
64                 ;;
65         *)
66                 exit 0
67                 ;;
68     esac
69 elif [ "${MODE}" = "stop" ]; then
70     case "${IF_OVS_TYPE}" in
71         OVSBridge)
72                 if [ ! -z "${IF_OVS_PORTS}" ]; then
73                     ifdown --allow="${IFACE}" ${IF_OVS_PORTS}
74                 fi
75
76                 ovs_vsctl -- --if-exists del-br "${IFACE}"
77                 ;;
78         OVSPort|OVSIntPort|OVSBond)
79                 ovs_vsctl -- --if-exists del-port "${IF_OVS_BRIDGE}" "${IFACE}"
80                 ;;
81         *)
82                 exit 0
83                 ;;
84     esac
85 fi
86
87 exit 0