From 28df43da15593b8755d5907d7711186e4dfdf9f2 Mon Sep 17 00:00:00 2001 From: Ian Goodacre Date: Tue, 11 Mar 2025 10:25:59 +0000 Subject: [PATCH] Improve armbian-firstlogin script Avoid waiting for the NetworkManager-wait-online or systemd-networkd-wait-online service to complete in the midst of prompting for root account password. --- .../common/usr/lib/armbian/armbian-firstlogin | 63 ++++++++++++++----- 1 file changed, 47 insertions(+), 16 deletions(-) diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin index 176f0f427..521732816 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin +++ b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin @@ -662,6 +662,52 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then echo -e "\nWaiting for system to finish booting ..." systemctl is-system-running --wait > /dev/null + # enable networkManager-wait-online.service + # When NM is used the NetworkManager-wait-online.service must be enabled so that network-online.target is not reached until + # NetworkManager has brought up all the interfaces. Service units that require the network to be up before starting rely + # on network-online.target working correctly otherwise they will likely fail on boot + # Same goes for systemd-networkd stack + # https://github.com/armbian/build/issues/7896 + if + systemctl is-enabled --quiet NetworkManager && + systemctl is-enabled --quiet systemd-networkd + then + echo "Both NetworkManager and systemd-networkd services are enabled." + echo "This is known to cause problems with network startup." + # If no display manager was found, assume this is a server + # with network managed by systemd-networkd. Otherwise, assume + # it is a workstation with network managed by NetworkManager. + if [[ "${desktop_dm}" == "none" ]]; then + echo "No Display Manager detected: NetworkManager will be disabled" + systemctl stop NetworkManager + systemctl disable NetworkManager + else + echo "${desktop_dm} Display Manager detected: systemd-networkd will be disabled" + systemctl stop systemd-networkd + systemctl disable systemd-networkd + fi + fi + + if + systemctl is-enabled --quiet NetworkManager && + ! systemctl is-enabled --quiet NetworkManager-wait-online + then + systemctl enable NetworkManager-wait-online + # @TODO: determine if there is any value in starting it now + echo "Waiting for network startup to complete..." + systemctl start NetworkManager-wait-online + fi + + if + systemctl is-enabled --quiet systemd-networkd && + ! systemctl is-enabled --quiet systemd-networkd-wait-online + then + systemctl enable systemd-networkd-wait-online + # @TODO: determine if there is any value in starting it now + echo "Waiting for network startup to complete..." + systemctl start systemd-networkd-wait-online + fi + # enable hiDPI support if [[ "$(cut -d, -f1 < /sys/class/graphics/fb0/virtual_size 2> /dev/null)" -gt 1920 ]]; then # lightdm @@ -706,21 +752,6 @@ if [[ -f /root/.not_logged_in_yet && -n $(tty) ]]; then fi fi - # enable networkManager-wait-online.service - # When NM is used the NetworkManager-wait-online.service must be enabled so that network-online.target is not reached until - # NetworkManager has brought up all the interfaces. Service units that require the network to be up before starting rely - # on network-online.target working correctly otherwise they will likely fail on boot - # Same goes for systemd-networkd stack - # https://github.com/armbian/build/issues/7896 - if systemctl is-active --quiet NetworkManager; then - systemctl enable NetworkManager-wait-online.service - systemctl start NetworkManager-wait-online.service - fi - if systemctl is-active --quiet systemd-networkd; then - systemctl enable systemd-networkd-wait-online.service - systemctl start systemd-networkd-wait-online.service - fi - # only allow one login. Once you enter root password, kill others. loginfrom=$(who am i | awk '{print $2}') who -la | grep root | grep -v "$loginfrom" | awk '{print $7}' | xargs --no-run-if-empty kill -9 @@ -961,4 +992,4 @@ fi # Run provisioning script if exists if [[ -f /root/provisioning.sh ]]; then . /root/provisioning.sh -fi \ No newline at end of file +fi