summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJonas Smedegaard <dr@jones.dk>2018-04-16 19:43:15 +0200
committerJonas Smedegaard <dr@jones.dk>2018-04-16 19:43:15 +0200
commitdb1d1b048c5aba8f4d60a108250c5497a5ed8bef (patch)
treec32b98e8d1c2926fea1ec0ec993e7dc3e069a7e6
parent322dd849f7c154b2cc64efee14e4ad49c0050dfd (diff)
Use dhcp by default, and skip firewall setup unless installed.
-rwxr-xr-xskel/multistrap-hooks/completion_80_rootscript_net.sh31
1 files changed, 25 insertions, 6 deletions
diff --git a/skel/multistrap-hooks/completion_80_rootscript_net.sh b/skel/multistrap-hooks/completion_80_rootscript_net.sh
index be78fba..9578319 100755
--- a/skel/multistrap-hooks/completion_80_rootscript_net.sh
+++ b/skel/multistrap-hooks/completion_80_rootscript_net.sh
@@ -19,15 +19,34 @@ cat <<'EOF' > "$fs/root/init-network-settings"
set -eu
set -x
-# Add static-IP internal first-port ethernet connection
-nmcli connection add type ethernet con-name eth0-static ifname eth0 ip4 192.168.1.1 ipv4.method manual autoconnect on connection.zone internal
+address=${1:-}
-# Add dynamic-IP external wildcard ethernet connection
+apn=${2:-}
+
+# Setup main ethernet connection as internal
+if [ -n "$address" ]; then
+ nmcli connection add type ethernet con-name eth0-static ifname eth0 ip4 $address ipv4.method manual autoconnect on connection.zone internal
+else
+ nmcli connection add type ethernet con-name eth0-dhcp ifname eth0 autoconnect on connection.zone internal
+fi
+
+# Setup any other ethernet connection as external
nmcli connection add type ethernet con-name dhcp ifname '*' autoconnect on connection.zone external
-# Add dynamic-IP external WWAN connection (hardcoded provider for now)
-nmcli connection add ifname '' autoconnect yes type gsm apn data.tre.dk connection.id gsm-tre.dk-noauth connection.zone external gsm.password-flags 1
-#nmcli connection add ifname '' autoconnect yes type gsm apn internet connection.id gsm-internet-noauth connection.zone external gsm.password-flags 1
+# Setup WWAN connection
+# Known working APN values:
+# * data.tre.dk
+# * internet
+# See /usr/share/mobile-broadband-provider-info/serviceproviders.xml
+if [ -n "$apn" ]; then
+ nmcli connection add ifname '' autoconnect yes type gsm apn $apn connection.id gsm-$apn-noauth connection.zone external gsm.password-flags 1
+fi
+
+# Done with non-firewall setup
+if [ ! -x /usr/sbin/firewalld ]; then
+ echo 'Network settings applied succesfully!'
+ exit 0
+fi
# Permit mosh from anywhere:
firewall-cmd --permanent --zone external --add-service mosh