Files
netbird/release_files/darwin_pkg/postinstall
T
mlsmaycon e0737f94dc [release] Write fresh-install breadcrumb from installers
Installers write a .fresh-install breadcrumb on fresh installs only and
delete stale breadcrumbs on upgrade; none of them writes login items or
registry Run keys. Windows NSIS detects upgrades via the uninstall
registry entry or an existing installed executable; the macOS pkg via the
previous pkgutil receipt; Linux deb/rpm via the standard postinstall
arguments. Post-update GUI relaunches (macOS open, Linux
ui-post-install.sh) pass --post-update so the first-run autostart default
cannot fire on updates.
2026-07-12 12:42:25 +02:00

67 lines
2.1 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
FRESH_INSTALL_MARKER_DIR="/Library/Application Support/NetBird"
FRESH_INSTALL_MARKER="$FRESH_INSTALL_MARKER_DIR/.fresh-install"
mkdir -p /var/log/netbird/
mkdir -p /usr/local/bin/
{
echo "Installing NetBird..."
# Fresh-vs-upgrade detection: the pkg receipt of a previous install is
# still present while this script runs, so a receipt means upgrade. Only
# a true fresh install gets the breadcrumb the GUI uses to enable
# launch-on-login by default; the installer itself never writes login
# items. On upgrade any stale breadcrumb is removed (covers a fresh
# install where the GUI never launched before the first update).
IS_UPGRADE="false"
if [ -n "${INSTALL_PKG_SESSION_ID:-}" ] && pkgutil --pkg-info "${INSTALL_PKG_SESSION_ID}" > /dev/null 2>&1; then
IS_UPGRADE="true"
fi
if [ "$IS_UPGRADE" = "true" ]; then
echo "Upgrade detected (receipt for ${INSTALL_PKG_SESSION_ID} present), removing stale fresh-install marker."
rm -f "$FRESH_INSTALL_MARKER"
else
echo "Fresh install detected, writing fresh-install marker."
mkdir -p "$FRESH_INSTALL_MARKER_DIR"
touch "$FRESH_INSTALL_MARKER"
fi
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
# On upgrade the GUI relaunch carries --post-update so its first-run
# autostart default cannot fire (belt-and-suspenders on top of the
# absent breadcrumb).
if [ "$IS_UPGRADE" = "true" ]; then
open $APP --args --post-update
else
open $APP
fi
echo "Finished Netbird installation successfully"
exit 0 # all good
} &> $LOG_FILE