From 6802e20a1d7e820ce252a0aa6f0cb82f64947db8 Mon Sep 17 00:00:00 2001 From: Sunil Mohan Adapa Date: Wed, 4 Oct 2017 13:22:43 +0530 Subject: [PATCH] networks: Activate the newly created connections When network-manager restarts, it leaves the existing connections intact. When it start again, it somehow restores that active connection. So, restarting network-manager is not a solution to activate all newly created connections. Explicitly activate all connections and don't restart network-manager. Do connection activation in background so that failed activation does not lead to failed setup of remaining connections. Signed-off-by: Sunil Mohan Adapa Signed-off-by: Joseph Nuthalpati --- actions/networks | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/actions/networks b/actions/networks index f888d3c0c..1874c4c01 100755 --- a/actions/networks +++ b/actions/networks @@ -14,6 +14,11 @@ function get-interfaces { NO_OF_WIRELESS_IFACES=$(echo $WIRELESS_IFACES | wc -w) } +function activate-connection { + connection_name="$1" + nohup nmcli con up "$connection_name" &>/dev/null & +} + function configure-regular-interface { local interface="$1" local zone="$2" @@ -23,6 +28,7 @@ function configure-regular-interface { nmcli con add con-name "$connection_name" ifname "$interface" type ethernet nmcli con modify "$connection_name" connection.autoconnect TRUE nmcli con modify "$connection_name" connection.zone "$zone" + activate-connection "$connection_name" echo "Configured interface '$interface' for '$zone' use as '$connection_name'." } @@ -44,6 +50,8 @@ function configure-shared-interface { # - Add firewall rules for NATing from this interface nmcli con modify "$connection_name" ipv4.method shared + activate-connection "$connection_name" + echo "Configured interface '$interface' for shared use as '$connection_name'." } @@ -60,6 +68,7 @@ function configure-wireless-interface { nmcli con modify "$connection_name" wifi.mode ap nmcli con modify "$connection_name" wifi-sec.key-mgmt wpa-psk nmcli con modify "$connection_name" wifi-sec.psk "$secret" + activate-connection "$connection_name" echo "Configured interface '$interface' for shared use as '$connection_name'." } @@ -132,10 +141,6 @@ function setup { if [ -f "/var/lib/freedombox/is-freedombox-disk-image" ] then setup - # Restart network-manager so that the connections created will be activated. - # On a fresh disk image, this means the default network manager connections - # will be ignored and newly created connections will be activated. - systemctl restart network-manager else echo "Not a FreedomBox disk image. Skipping network configuration." fi