Add support to force using binary install (#1082)

Check if the USE_BIN_INSTALL variable is set to true and skip package manager discovery
This commit is contained in:
Maycon Santos
2023-08-16 15:10:57 +02:00
committed by GitHub
parent 442ba7cbc8
commit 01f2b0ecb7
5 changed files with 60 additions and 104 deletions

View File

@@ -24,13 +24,21 @@ download_release_binary() {
VERSION=$(get_latest_release)
BASE_URL="https://github.com/${OWNER}/${REPO}/releases/download"
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
BINARY_BASE_NAME="${VERSION#v}_${OS_TYPE}_${ARCH}_signed.zip"
fi
BINARY_NAME="$1_${BINARY_BASE_NAME}"
if [ "$1" = "$UI_APP" ]; then
BINARY_NAME="$1-${OS_TYPE}_${BINARY_BASE_NAME}"
if [ "$OS_TYPE" = "darwin" ]; then
BINARY_NAME="$1_${BINARY_BASE_NAME}"
fi
else
BINARY_NAME="$1_${BINARY_BASE_NAME}"
fi
DOWNLOAD_URL="${BASE_URL}/${VERSION}/${BINARY_NAME}"
echo "Installing $1 from $DOWNLOAD_URL"
@@ -128,6 +136,14 @@ install_native_binaries() {
fi
}
check_use_bin_variable() {
if [ "${USE_BIN_INSTALL}-x" = "true-x" ]; then
echo "The installation will be performed using binary files"
return 0
fi
return 1
}
install_netbird() {
# Check if netbird CLI is installed
if [ -x "$(command -v netbird)" ]; then
@@ -170,8 +186,10 @@ install_netbird() {
echo "Netbird UI installation will be omitted as Linux does not run desktop environment"
fi
# Check the availability of a compactible package manager
if [ -x "$(command -v apt)" ]; then
# Check the availability of a compatible package manager
if check_use_bin_variable; then
PACKAGE_MANAGER="bin"
elif [ -x "$(command -v apt)" ]; then
PACKAGE_MANAGER="apt"
echo "The installation will be performed using apt package manager"
elif [ -x "$(command -v dnf)" ]; then
@@ -191,7 +209,9 @@ install_netbird() {
INSTALL_DIR="/usr/local/bin"
# Check the availability of a compatible package manager
if [ -x "$(command -v brew)" ]; then
if check_use_bin_variable; then
PACKAGE_MANAGER="bin"
elif [ -x "$(command -v brew)" ]; then
PACKAGE_MANAGER="brew"
echo "The installation will be performed using brew package manager"
fi