summaryrefslogtreecommitdiffstats
path: root/ansible/roles/gsm-tester/files
diff options
context:
space:
mode:
authorPau Espin Pedrol <pespin@sysmocom.de>2019-04-04 16:38:39 +0200
committerPau Espin Pedrol <pespin@sysmocom.de>2019-04-04 16:38:39 +0200
commit6fa6e953424d090626c02f0aeeb204580dc407dc (patch)
treec161acc1a39936723007fda027be438cdf9dbf66 /ansible/roles/gsm-tester/files
parent8233bf7e9a1903fe6c35c2f45b5f48c223a34ead (diff)
ansible: gsm-tester: Install osmo-gsm-tester_netns_setup.sh
Diffstat (limited to 'ansible/roles/gsm-tester/files')
-rwxr-xr-xansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh22
1 files changed, 22 insertions, 0 deletions
diff --git a/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh b/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh
new file mode 100755
index 0000000..1600c44
--- /dev/null
+++ b/ansible/roles/gsm-tester/files/osmo-gsm-tester_netns_setup.sh
@@ -0,0 +1,22 @@
+#!/bin/bash -e
+
+ifname="$1"
+netns="$2"
+shift
+shift
+
+
+
+if [ -f "/var/run/netns/${netns}" ]; then
+ echo "netns $netns already exists"
+else
+ echo "Creating netns $netns"
+ ip netns add "$netns"
+fi
+
+if [ -d "/sys/class/net/${ifname}" ]; then
+ echo "Moving iface $ifname to netns $netns"
+ ip link set $ifname netns $netns
+else
+ ip netns exec $netns ls "/sys/class/net/${ifname}" >/dev/null && echo "iface $ifname already in netns $netns"
+fi