mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-05-27 10:44:33 +00:00
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 <sunil@medhas.org> Signed-off-by: Joseph Nuthalpati <njoseph@thoughtworks.com>
This commit is contained in:
parent
82bb718a53
commit
6802e20a1d
@ -14,6 +14,11 @@ function get-interfaces {
|
|||||||
NO_OF_WIRELESS_IFACES=$(echo $WIRELESS_IFACES | wc -w)
|
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 {
|
function configure-regular-interface {
|
||||||
local interface="$1"
|
local interface="$1"
|
||||||
local zone="$2"
|
local zone="$2"
|
||||||
@ -23,6 +28,7 @@ function configure-regular-interface {
|
|||||||
nmcli con add con-name "$connection_name" ifname "$interface" type ethernet
|
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.autoconnect TRUE
|
||||||
nmcli con modify "$connection_name" connection.zone "$zone"
|
nmcli con modify "$connection_name" connection.zone "$zone"
|
||||||
|
activate-connection "$connection_name"
|
||||||
|
|
||||||
echo "Configured interface '$interface' for '$zone' use as '$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
|
# - Add firewall rules for NATing from this interface
|
||||||
nmcli con modify "$connection_name" ipv4.method shared
|
nmcli con modify "$connection_name" ipv4.method shared
|
||||||
|
|
||||||
|
activate-connection "$connection_name"
|
||||||
|
|
||||||
echo "Configured interface '$interface' for shared use as '$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.mode ap
|
||||||
nmcli con modify "$connection_name" wifi-sec.key-mgmt wpa-psk
|
nmcli con modify "$connection_name" wifi-sec.key-mgmt wpa-psk
|
||||||
nmcli con modify "$connection_name" wifi-sec.psk "$secret"
|
nmcli con modify "$connection_name" wifi-sec.psk "$secret"
|
||||||
|
activate-connection "$connection_name"
|
||||||
|
|
||||||
echo "Configured interface '$interface' for shared use as '$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" ]
|
if [ -f "/var/lib/freedombox/is-freedombox-disk-image" ]
|
||||||
then
|
then
|
||||||
setup
|
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
|
else
|
||||||
echo "Not a FreedomBox disk image. Skipping network configuration."
|
echo "Not a FreedomBox disk image. Skipping network configuration."
|
||||||
fi
|
fi
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user