mirror of
https://github.com/netbirdio/netbird.git
synced 2026-03-31 06:24:18 -04:00
Fixes #4808 by extracting the full username by: - Get PID using pgrep - Get UID from PID using /proc/${PID}/loginuid - Get user name from UID using id Also replaces "complex" pipe from ps to sed with a (hopefully) "simpler" (as in requiring less knowledge about the arguments of ps and regexps) invocation of cat and id.
16 lines
369 B
Bash
16 lines
369 B
Bash
#!/bin/sh
|
|
|
|
set -e
|
|
set -u
|
|
|
|
# Check if netbird-ui is running
|
|
pid="$(pgrep -x -f /usr/bin/netbird-ui || true)"
|
|
if [ -n "${pid}" ]
|
|
then
|
|
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 - "${username}" -c 'nohup /usr/bin/netbird-ui > /dev/null 2>&1 &'
|
|
fi
|