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.
This commit is contained in:
Ian Goodacre
2025-03-11 10:25:59 +00:00
committed by Igor
parent 19b0a062a7
commit 28df43da15

View File

@@ -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