From 54b3daf9d436ed887021a139c2a137a3f0912eae Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Sun, 29 Nov 2015 15:28:12 +0000 Subject: [PATCH] Default to no static local IP address, but have the option to set one --- src/freedombone | 11 +++++-- src/freedombone-config | 75 +++++++++++++++++++++++++----------------- 2 files changed, 54 insertions(+), 32 deletions(-) diff --git a/src/freedombone b/src/freedombone index 084bbccf..1533c72a 100755 --- a/src/freedombone +++ b/src/freedombone @@ -101,7 +101,8 @@ CPU_CORES=1 IPV6_NETWORK='2001:470:26:307' # The static IP address of the system within the local network -LOCAL_NETWORK_STATIC_IP_ADDRESS="192.168.1.60" +# By default the IP address is dynamic within your LAN +LOCAL_NETWORK_STATIC_IP_ADDRESS= # IP address of the router (gateway) ROUTER_IP_ADDRESS="192.168.1.254" @@ -1291,6 +1292,9 @@ function install_not_on_BBB { 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 @@ -6975,7 +6979,10 @@ function configure_email { echo "dc_readhost=''" >> /etc/exim4/update-exim4.conf.conf echo "dc_relay_domains=''" >> /etc/exim4/update-exim4.conf.conf echo "dc_minimaldns='false'" >> /etc/exim4/update-exim4.conf.conf - RELAY_NETS=$(echo $LOCAL_NETWORK_STATIC_IP_ADDRESS | awk -F '.' '{print $1 "." $2 "." $3 ".0/24"}') + RELAY_NETS='192.168.1.0/24' + if [ $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then + RELAY_NETS=$(echo $LOCAL_NETWORK_STATIC_IP_ADDRESS | awk -F '.' '{print $1 "." $2 "." $3 ".0/24"}') + fi echo "dc_relay_nets='$RELAY_NETS'" >> /etc/exim4/update-exim4.conf.conf echo "dc_smarthost=''" >> /etc/exim4/update-exim4.conf.conf echo "CFILEMODE='644'" >> /etc/exim4/update-exim4.conf.conf diff --git a/src/freedombone-config b/src/freedombone-config index b5cef14d..ccd5d626 100755 --- a/src/freedombone-config +++ b/src/freedombone-config @@ -180,8 +180,10 @@ function save_configuration_file { echo "MY_NAME=$MY_NAME" >> $CONFIGURATION_FILE fi echo "MY_EMAIL_ADDRESS=$MY_EMAIL_ADDRESS" >> $CONFIGURATION_FILE - echo "LOCAL_NETWORK_STATIC_IP_ADDRESS=$LOCAL_NETWORK_STATIC_IP_ADDRESS" >> $CONFIGURATION_FILE - echo "ROUTER_IP_ADDRESS=$ROUTER_IP_ADDRESS" >> $CONFIGURATION_FILE + if [ $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then + echo "LOCAL_NETWORK_STATIC_IP_ADDRESS=$LOCAL_NETWORK_STATIC_IP_ADDRESS" >> $CONFIGURATION_FILE + echo "ROUTER_IP_ADDRESS=$ROUTER_IP_ADDRESS" >> $CONFIGURATION_FILE + fi if [ $ENABLE_CJDNS ]; then echo "ENABLE_CJDNS=$ENABLE_CJDNS" >> $CONFIGURATION_FILE fi @@ -657,10 +659,10 @@ function interactive_configuration { fi if [ -d /home/$GENERIC_IMAGE_USERNAME ]; then - if [ ! -f $IMAGE_PASSWORD_FILE ]; then - echo 'Cannot find the password file for the admin user' - exit 62753 - fi + if [ ! -f $IMAGE_PASSWORD_FILE ]; then + echo 'Cannot find the password file for the admin user' + exit 62753 + fi # when installing from an image which comes with a known default user account selected_username= while [ ! $selected_username ] @@ -1091,34 +1093,47 @@ function interactive_configuration { save_configuration_file fi - if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then - LOCAL_NETWORK_STATIC_IP_ADDRESS=$(grep 'LOCAL_NETWORK_STATIC_IP_ADDRESS' temp.cfg | awk -F '=' '{print $2}') - if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then - LOCAL_NETWORK_STATIC_IP_ADDRESS='192.168..' - fi - fi - if [ ! $ROUTER_IP_ADDRESS ]; then - ROUTER_IP_ADDRESS=$(grep 'ROUTER_IP_ADDRESS' temp.cfg | awk -F '=' '{print $2}') - if [ ! $ROUTER_IP_ADDRESS ]; then - ROUTER_IP_ADDRESS='192.168..' - fi - fi - data=$(tempfile 2>/dev/null) - trap "rm -f $data" 0 1 2 5 15 - dialog --backtitle $"Freedombone Configuration" \ - --title $"Local Network Configuration" \ - --form $"\nPlease enter the IP addresses:" 11 55 3 \ - $"This system:" 1 1 "$LOCAL_NETWORK_STATIC_IP_ADDRESS" 1 16 16 15 \ - $"Internet router:" 2 1 "$ROUTER_IP_ADDRESS" 2 16 16 15 \ - 2> $data + SET_STATIC_IP="no" + dialog --title $"Static local IP address" \ + --backtitle $"Freedombone Configuration" \ + --defaultno \ + --yesno $"\nDo you want to set a static local IP address for this system?\n\nFor example, 192.168.1.10" 10 60 sel=$? case $sel in - 1) exit 1;; + 0) SET_STATIC_IP="yes";; 255) exit 1;; esac - LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p) - ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p) - save_configuration_file + + if [[ $SET_STATIC_IP == "yes" ]]; then + if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then + LOCAL_NETWORK_STATIC_IP_ADDRESS=$(grep 'LOCAL_NETWORK_STATIC_IP_ADDRESS' temp.cfg | awk -F '=' '{print $2}') + if [ ! $LOCAL_NETWORK_STATIC_IP_ADDRESS ]; then + LOCAL_NETWORK_STATIC_IP_ADDRESS='192.168..' + fi + fi + if [ ! $ROUTER_IP_ADDRESS ]; then + ROUTER_IP_ADDRESS=$(grep 'ROUTER_IP_ADDRESS' temp.cfg | awk -F '=' '{print $2}') + if [ ! $ROUTER_IP_ADDRESS ]; then + ROUTER_IP_ADDRESS='192.168..' + fi + fi + data=$(tempfile 2>/dev/null) + trap "rm -f $data" 0 1 2 5 15 + dialog --backtitle $"Freedombone Configuration" \ + --title $"Local Network Configuration" \ + --form $"\nPlease enter the IP addresses:" 11 55 3 \ + $"This system:" 1 1 "$LOCAL_NETWORK_STATIC_IP_ADDRESS" 1 16 16 15 \ + $"Internet router:" 2 1 "$ROUTER_IP_ADDRESS" 2 16 16 15 \ + 2> $data + sel=$? + case $sel in + 1) exit 1;; + 255) exit 1;; + esac + LOCAL_NETWORK_STATIC_IP_ADDRESS=$(cat $data | sed -n 1p) + ROUTER_IP_ADDRESS=$(cat $data | sed -n 2p) + save_configuration_file + fi if [[ $SYSTEM_TYPE == "$VARIANT_WRITER" || $SYSTEM_TYPE == "$VARIANT_FULL" ]]; then WIKI_DETAILS_COMPLETE=