summaryrefslogtreecommitdiff
path: root/docker/openvswitch/openvswitch-db-server/ovs_ensure_configured.sh
blob: c91f87172c2cf428c8d123835ba398d31bf8eae8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash

bridge=$1
port=$2

ip link show $port
if [[ $? -ne 0 ]]; then
    # fail when device doesn't exist
    exit 1
fi

ovs-vsctl br-exists $bridge
if [[ $? -eq 2 ]]; then
    changed=changed
    ovs-vsctl --no-wait add-br $bridge
fi

if [[ ! $(ovs-vsctl list-ports $bridge) =~ $(echo "\<$port\>") ]]; then
    changed=changed
    ovs-vsctl --no-wait add-port $bridge $port
fi

echo $changed