diff --git a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin index 21d2a45389cf..b9bda297aa2a 100755 --- a/packages/bsp/common/usr/lib/armbian/armbian-firstlogin +++ b/packages/bsp/common/usr/lib/armbian/armbian-firstlogin @@ -786,6 +786,14 @@ set_user_icon() { if [[ -f /root/.not_logged_in_yet ]] && tty -s; then + # tty1, the serial console and an early ssh login all start the setup at once. + # Let the first one own it, or they race each other through the prompts. + exec 9> /run/armbian-firstlogin.lock || exit 1 + if ! flock -n 9; then + echo -e "\nFirst login setup is already running in another session.\n" + exit 0 + fi + . /root/.not_logged_in_yet # override configuration from URL @@ -926,18 +934,6 @@ if [[ -f /root/.not_logged_in_yet ]] && tty -s; then fi fi - # Get current session identifiers - current_tty=$(tty | sed 's:/dev/::') # e.g., "tty1" - current_pid=$$ - - # Kill ONLY other active root SHELL sessions (not login processes) - ps -u root -o pid,tty,comm | - awk -v me="$current_tty" -v mypid="$current_pid" ' - NR>1 && $2 != "?" && $2 != me && $1 != mypid && $3 ~ /sh$/ { - print $1 - }' | - xargs --no-run-if-empty kill -9 - # enable motd chmod +x /etc/update-motd.d/*