-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathvswitch_bridge.sh
58 lines (55 loc) · 1.1 KB
/
vswitch_bridge.sh
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
#!/bin/bash
start() {
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
STATUS="$(ovs-vsctl show | grep ovs_eth1)"
if [ "$STATUS" != "" ]
then
echo "Trying to enable bridging"
ovs-vsctl del-br ovs_eth1
ovs-vsctl add-port ovs_eth0 eth1
#rm $DIR/Latest-bridge-date.txt
date > $DIR/Latest-bridge-date.txt
for i in {1..5}
do
sleep 20
STATUS="$(ovs-vsctl show | grep ovs_eth1)"
if [ "$STATUS" != "" ]
then
echo "Run " $i+1 " times" >> $DIR/Latest-bridge-date.txt
ovs-vsctl del-br ovs_eth1
ovs-vsctl add-port ovs_eth0 eth1
else
exit 1
fi
done
STATUS="$(ovs-vsctl show | grep ovs_eth1)"
if [ "$STATUS" != "" ]
then
echo "Failed to bridge ports. Please check your settings." >> $DIR/Latest-bridge-date.txt
exit -1
fi
else
echo "$STATUS"
echo "Nothing to do. Exiting..."
fi
}
stop() {
echo "Not implemented yet. A restart will help."
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
stop
start
;;
*)
echo "This script enable bridging between eth0 and eth1 with vSwitch"
echo "Usage: $0 {start|stop|restart}" >&2
exit 1
;;
esac