Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions packages/bsp/common/usr/lib/armbian/armbian-firstlogin
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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/*

Expand Down