
When refreshing a snap, set-br-ex could fail because the iptables rules that it sets were already setup. We now exit zero if this is true, which prevents us from breaking on upgrades. Change-Id: Ibfee98cabfa3e35bf53dbd191de2cf46f3709a51
25 lines
646 B
Bash
Executable File
25 lines
646 B
Bash
Executable File
#!/bin/bash
|
|
#
|
|
# Oneshot daemon which creates a networking bridge.
|
|
#
|
|
# Creates br-ex, and sets up an ip address for it. We put this in a
|
|
# oneshot so that the ip address persists after reboot, without
|
|
# needing to add networking entries to the host system. (We want this
|
|
# to work well when we turn off classic confinement.)
|
|
|
|
set -ex
|
|
|
|
extcidr=$(snapctl get config.network.ext-cidr)
|
|
|
|
# Create external integration bridge
|
|
ovs-vsctl --retry --may-exist add-br br-ex
|
|
|
|
# Configure br-ex
|
|
ip address add $extcidr dev br-ex || :
|
|
ip link set br-ex up || :
|
|
|
|
sudo iptables -w -t nat -A POSTROUTING -s $extcidr ! \
|
|
-d $extcidr -j MASQUERADE || :
|
|
|
|
exit 0
|