[client] Add macOS .pkg installer support to installation script (#3755)

[client] Add macOS .pkg installer support to installation script
This commit is contained in:
hakansa 2025-04-29 13:43:42 +03:00 committed by GitHub
parent 2f44fe2e23
commit d2b42c8f68
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -199,6 +199,21 @@ install_native_binaries() {
fi fi
} }
# Handle macOS .pkg installer
install_pkg() {
case "$(uname -m)" in
x86_64) ARCH="amd64" ;;
arm64|aarch64) ARCH="arm64" ;;
*) echo "Unsupported macOS arch: $(uname -m)" >&2; exit 1 ;;
esac
PKG_URL=$(curl -sIL -o /dev/null -w '%{url_effective}' "https://pkgs.netbird.io/macos/${ARCH}")
echo "Downloading NetBird macOS installer from https://pkgs.netbird.io/macos/${ARCH}"
curl -fsSL -o /tmp/netbird.pkg "${PKG_URL}"
${SUDO} installer -pkg /tmp/netbird.pkg -target /
rm -f /tmp/netbird.pkg
}
check_use_bin_variable() { check_use_bin_variable() {
if [ "${USE_BIN_INSTALL}-x" = "true-x" ]; then if [ "${USE_BIN_INSTALL}-x" = "true-x" ]; then
echo "The installation will be performed using binary files" echo "The installation will be performed using binary files"
@ -265,6 +280,16 @@ install_netbird() {
${SUDO} pacman -Syy ${SUDO} pacman -Syy
add_aur_repo add_aur_repo
;; ;;
pkg)
# Check if the package is already installed
if [ -f /Library/Receipts/netbird.pkg ]; then
echo "NetBird is already installed. Please remove it before proceeding."
exit 1
fi
# Install the package
install_pkg
;;
brew) brew)
# Remove Netbird if it had been installed using Homebrew before # Remove Netbird if it had been installed using Homebrew before
if brew ls --versions netbird >/dev/null 2>&1; then if brew ls --versions netbird >/dev/null 2>&1; then
@ -274,7 +299,7 @@ install_netbird() {
netbird service stop netbird service stop
netbird service uninstall netbird service uninstall
# Unlik the app # Unlink the app
brew unlink netbird brew unlink netbird
fi fi
@ -312,7 +337,7 @@ install_netbird() {
echo "package_manager=$PACKAGE_MANAGER" | ${SUDO} tee "$CONFIG_FILE" > /dev/null echo "package_manager=$PACKAGE_MANAGER" | ${SUDO} tee "$CONFIG_FILE" > /dev/null
# Load and start netbird service # Load and start netbird service
if [ "$PACKAGE_MANAGER" != "rpm-ostree" ]; then if [ "$PACKAGE_MANAGER" != "rpm-ostree" ] && [ "$PACKAGE_MANAGER" != "pkg" ]; then
if ! ${SUDO} netbird service install 2>&1; then if ! ${SUDO} netbird service install 2>&1; then
echo "NetBird service has already been loaded" echo "NetBird service has already been loaded"
fi fi
@ -451,9 +476,8 @@ if type uname >/dev/null 2>&1; then
# Check the availability of a compatible package manager # Check the availability of a compatible package manager
if check_use_bin_variable; then if check_use_bin_variable; then
PACKAGE_MANAGER="bin" PACKAGE_MANAGER="bin"
elif [ -x "$(command -v brew)" ]; then else
PACKAGE_MANAGER="brew" PACKAGE_MANAGER="pkg"
echo "The installation will be performed using brew package manager"
fi fi
;; ;;
esac esac