From 9fe1f9172253a689eaf2db05a6cefe3bd81782a8 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sat, 10 Mar 2018 12:10:02 +0000 Subject: [PATCH] Initial dynamic eth0 configuration --- src/freedombone-utils-network | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/freedombone-utils-network b/src/freedombone-utils-network index 95d6ba89..a6e91ea9 100755 --- a/src/freedombone-utils-network +++ b/src/freedombone-utils-network @@ -54,21 +54,33 @@ function install_static_network { if [[ $INSTALLING_ON_BBB == "yes" ]]; then return fi - if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then - return - fi echo '# This file describes the network interfaces available on your system' > /etc/network/interfaces echo '# and how to activate them. For more information, see interfaces(5).' >> /etc/network/interfaces echo 'source /etc/network/interfaces.d/*' >> /etc/network/interfaces + if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then + + { echo 'auto eth0'; + echo 'iface eth0 inet dhcp'; } > /etc/network/interfaces.d/dynamic + + if [ -f /etc/network/interfaces.d/static ]; then + rm /etc/network/interfaces.d/static + fi + + mark_completed "${FUNCNAME[0]}" + return + fi + { echo 'auto eth0'; echo 'iface eth0 inet static'; echo " address $LOCAL_NETWORK_STATIC_IP_ADDRESS"; echo ' netmask 255.255.255.0'; echo " gateway $ROUTER_IP_ADDRESS"; } > /etc/network/interfaces.d/static - mark_completed "${FUNCNAME[0]}" + if [ -f /etc/network/interfaces.d/dynamic ]; then + rm /etc/network/interfaces.d/dynamic + fi } function get_external_ipv4_address {