mirror of
https://github.com/netbirdio/netbird.git
synced 2026-08-30 03:21:29 +02:00
Wails already does this: the GUI is started by a per-user LaunchAgent. So starting the GUI assumes there is a user that is logging in to refer to. We are aligning the auto-update to this model here. IF there is a user, restart the GUI otherwise wait for a login. WHY it didn't happen before 0.75: cause the Fyne GUI never wrote any ui_preferences.json file or any other in users $HOME folder. So it's a problem related to the new GUI and has nothing to do with MDM.
53 lines
1.4 KiB
Bash
Executable File
53 lines
1.4 KiB
Bash
Executable File
#!/bin/sh
|
|
|
|
set -x
|
|
|
|
APP=/Applications/NetBird.app
|
|
AGENT=/usr/local/bin/netbird
|
|
LOG_FILE=/var/log/netbird/client_post_install.log
|
|
|
|
mkdir -p /var/log/netbird/
|
|
mkdir -p /usr/local/bin/
|
|
|
|
{
|
|
echo "Installing NetBird..."
|
|
|
|
if test -d $APP; then
|
|
echo "NetBird app copied successfully."
|
|
else
|
|
echo "NetBird app could not be copied to the Applications folder."
|
|
exit 1
|
|
fi
|
|
|
|
ln -fs $APP/Contents/MacOS/netbird $AGENT
|
|
if test -f $AGENT; then
|
|
echo "NetBird binary linked successfully."
|
|
else
|
|
echo "NetBird could not create symlink to /usr/local/bin"
|
|
exit 1
|
|
fi
|
|
|
|
$AGENT service install || true
|
|
$AGENT service start || true
|
|
|
|
# Launch the GUI as the logged-in console user, NOT as the installer's
|
|
# (root) context. When there is no active GUI session
|
|
# (unattended MDM install, login window), there is nobody to launch as, skip it;
|
|
|
|
console_user=$(stat -f%Su /dev/console 2>/dev/null)
|
|
case "$console_user" in
|
|
""|root|loginwindow|_mbsetupuser)
|
|
echo "No active GUI user session (console user: '${console_user:-none}'); skipping UI launch."
|
|
;;
|
|
*)
|
|
uid=$(id -u "$console_user")
|
|
echo "Launching NetBird UI as console user $console_user (uid $uid)."
|
|
launchctl asuser "$uid" open "$APP" || true
|
|
;;
|
|
esac
|
|
|
|
echo "Finished Netbird installation successfully"
|
|
exit 0 # all good
|
|
} &> $LOG_FILE
|
|
|