]> git.sven.stormbind.net Git - sven/scripts.git/commitdiff
add a workaround to bring up lokal host only virtualbox interfaces
authorSven Hoexter <sven@stormbind.net>
Fri, 26 May 2017 13:16:25 +0000 (15:16 +0200)
committerSven Hoexter <sven@stormbind.net>
Fri, 26 May 2017 13:16:25 +0000 (15:16 +0200)
home/fix-vbox-net.sh [new file with mode: 0755]

diff --git a/home/fix-vbox-net.sh b/home/fix-vbox-net.sh
new file mode 100755 (executable)
index 0000000..bc58a85
--- /dev/null
@@ -0,0 +1,18 @@
+#!/bin/bash
+VBoxManage list hostonlyifs |
+    while IFS= read -r line; do
+       if [[ ${line} =~ ^Name ]]; then
+           lastIf=$(echo ${line} | cut -d' ' -f 2)
+       fi
+
+       if [[ ${line} =~ ^IPAddress ]]; then
+           lastIfIP=$(echo ${line} | cut -d' ' -f 2)
+       fi
+
+       if [[ ${line} =~ ^NetworkMask ]]; then
+           lastIfNetM=$(echo ${line} | cut -d' ' -f 2)
+           sudo ip link set up dev ${lastIf}
+           sudo ip a a ${lastIfIP}/${lastIfNetM} dev ${lastIf}
+           unset -v lastIf lastIfIP lastIfNetM
+       fi
+    done