Skip to content
21 changes: 11 additions & 10 deletions release_files/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ UI_APP="netbird-ui"
# Set default variable
OS_NAME=""
OS_TYPE=""
DARWIN="darwin"
LINUX="linux"
ARCH="$(uname -m)"
PACKAGE_MANAGER="bin"
INSTALL_DIR=""
Expand Down Expand Up @@ -57,13 +59,13 @@ download_release_binary() {
BINARY_BASE_NAME="${VERSION#v}_${OS_TYPE}_${ARCH}.tar.gz"

# for Darwin, download the signed NetBird-UI
if [ "$OS_TYPE" = "darwin" ] && [ "$1" = "$UI_APP" ]; then
if [ "$OS_TYPE" = DARWIN ] && [ "$1" = "$UI_APP" ]; then
BINARY_BASE_NAME="${VERSION#v}_${OS_TYPE}_${ARCH}_signed.zip"
fi

if [ "$1" = "$UI_APP" ]; then
BINARY_NAME="$1-${OS_TYPE}_${BINARY_BASE_NAME}"
if [ "$OS_TYPE" = "darwin" ]; then
if [ "$OS_TYPE" = DARWIN ]; then
BINARY_NAME="$1_${BINARY_BASE_NAME}"
fi
else
Expand All @@ -74,13 +76,13 @@ download_release_binary() {

echo "Installing $1 from $DOWNLOAD_URL"
if [ -n "$GITHUB_TOKEN" ]; then
cd /tmp && curl -H "Authorization: token ${GITHUB_TOKEN}" -LO "$DOWNLOAD_URL"
cd "${TMPDIR:-/tmp}" && curl --fail --silent --show-error --location --remote-name --time-cond "${TMPDIR:-/tmp}/${BINARY_NAME}" --header "Authorization: token ${GITHUB_TOKEN}" "$DOWNLOAD_URL"
else
cd /tmp && curl -LO "$DOWNLOAD_URL" || curl -LO --dns-servers 8.8.8.8 "$DOWNLOAD_URL"
cd "${TMPDIR:-/tmp}" && curl --fail --silent --show-error --location --remote-name --time-cond "${TMPDIR:-/tmp}/${BINARY_NAME}" "$DOWNLOAD_URL" || curl --fail --silent --show-error --location --remote-name --dns-servers 8.8.8.8 --time-cond "${TMPDIR:-/tmp}/${BINARY_NAME}" "$DOWNLOAD_URL"
fi


if [ "$OS_TYPE" = "darwin" ] && [ "$1" = "$UI_APP" ]; then
if [ "$OS_TYPE" = DARWIN ] && [ "$1" = "$UI_APP" ]; then
INSTALL_DIR="/Applications/NetBird UI.app"

if test -d "$INSTALL_DIR" ; then
Expand Down Expand Up @@ -185,9 +187,8 @@ install_pkg() {

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
curl --fail --silent --show-error --location --time-cond "${TMPDIR:-/tmp}/netbird.pkg" --output "${TMPDIR:-/tmp}/netbird.pkg" "${PKG_URL}"
${SUDO} installer -pkg "${TMPDIR:-/tmp}/netbird.pkg" -target /
}

check_use_bin_variable() {
Expand Down Expand Up @@ -389,7 +390,7 @@ fi
if type uname >/dev/null 2>&1; then
case "$(uname)" in
Linux)
OS_TYPE="linux"
OS_TYPE=LINUX
UNAME_OUTPUT="$(uname -a)"
if echo "$UNAME_OUTPUT" | grep -qi "synology"; then
OS_NAME="synology"
Expand Down Expand Up @@ -440,7 +441,7 @@ if type uname >/dev/null 2>&1; then
;;
Darwin)
OS_NAME="macos"
OS_TYPE="darwin"
OS_TYPE=DARWIN
INSTALL_DIR="/usr/local/bin"

# Check the availability of a compatible package manager
Expand Down