From fc4f4366e6eccc6acddcbe4ddb43d394b9233577 Mon Sep 17 00:00:00 2001 From: Dennis Schridde <63082+devurandom@users.noreply.github.com> Date: Wed, 19 Nov 2025 00:18:29 +0100 Subject: [PATCH 1/3] Fix ui-post-install.sh to use the full username Closes: https://github.com/netbirdio/netbird/issues/4808 --- release_files/ui-post-install.sh | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/release_files/ui-post-install.sh b/release_files/ui-post-install.sh index f6e8ddf92c4..42173912ef5 100644 --- a/release_files/ui-post-install.sh +++ b/release_files/ui-post-install.sh @@ -1,10 +1,12 @@ #!/bin/sh # Check if netbird-ui is running -if pgrep -x -f /usr/bin/netbird-ui >/dev/null 2>&1; +pid="$(pgrep -x -f /usr/bin/netbird-ui)" +if [[ "${pid}" ]] then - runner=$(ps --no-headers -o '%U' -p $(pgrep -x -f /usr/bin/netbird-ui) | sed 's/^[ \t]*//;s/[ \t]*$//') + uid="$(cat /proc/"${pid}"/loginuid)" + username="$(id -nu "${uid}")" # Only re-run if it was already running pkill -x -f /usr/bin/netbird-ui >/dev/null 2>&1 - su -l - "$runner" -c 'nohup /usr/bin/netbird-ui > /dev/null 2>&1 &' + su -l - "${username}" -c 'nohup /usr/bin/netbird-ui > /dev/null 2>&1 &' fi From 059408ebaf70da52b8b738e7caaf5c1b7ba4aca3 Mon Sep 17 00:00:00 2001 From: Dennis Schridde <63082+devurandom@users.noreply.github.com> Date: Wed, 19 Nov 2025 00:32:02 +0100 Subject: [PATCH 2/3] Abort when any command fails --- release_files/ui-post-install.sh | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/release_files/ui-post-install.sh b/release_files/ui-post-install.sh index 42173912ef5..e2fcbb3ad9f 100644 --- a/release_files/ui-post-install.sh +++ b/release_files/ui-post-install.sh @@ -1,8 +1,11 @@ #!/bin/sh +set -e +set -u + # Check if netbird-ui is running -pid="$(pgrep -x -f /usr/bin/netbird-ui)" -if [[ "${pid}" ]] +pid="$(pgrep -x -f /usr/bin/netbird-ui || true)" +if [ -n "${pid}" ] then uid="$(cat /proc/"${pid}"/loginuid)" username="$(id -nu "${uid}")" From 81e7ce512d71d428c0715dd39f94fdbb919e5178 Mon Sep 17 00:00:00 2001 From: Dennis Schridde <63082+devurandom@users.noreply.github.com> Date: Wed, 19 Nov 2025 00:39:59 +0100 Subject: [PATCH 3/3] Address feedback on su invocation --- release_files/ui-post-install.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/release_files/ui-post-install.sh b/release_files/ui-post-install.sh index e2fcbb3ad9f..ff6c4ee9b33 100644 --- a/release_files/ui-post-install.sh +++ b/release_files/ui-post-install.sh @@ -11,5 +11,5 @@ then username="$(id -nu "${uid}")" # Only re-run if it was already running pkill -x -f /usr/bin/netbird-ui >/dev/null 2>&1 - su -l - "${username}" -c 'nohup /usr/bin/netbird-ui > /dev/null 2>&1 &' + su - "${username}" -c 'nohup /usr/bin/netbird-ui > /dev/null 2>&1 &' fi