Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 30 additions & 2 deletions scripts/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,34 @@ if [[ $EUID -ne 0 ]]; then
exit 1
fi

# Detect available downloader: prefer wget, fall back to curl
if command -v wget >/dev/null 2>&1; then
DOWNLOADER="wget"
elif command -v curl >/dev/null 2>&1; then
DOWNLOADER="curl"
else
echo_red "Neither 'wget' nor 'curl' is installed."
echo_red "Please install one of them and run this script again."
exit 1
fi
echo_blue "Using downloader: $DOWNLOADER"

# fetch URL contents to stdout, quietly (used for API calls)
fetch() {
case $DOWNLOADER in
wget) wget -qO - "$1" ;;
curl) curl -fsSL "$1" ;;
esac
}

# download URL to stdout, with a progress indicator (used for the release tarball)
download() {
case $DOWNLOADER in
wget) wget -q --show-progress -O - "$1" ;;
curl) curl -fL --progress-bar "$1" ;;
esac
}

PROXY=""
VERSION=""

Expand Down Expand Up @@ -87,7 +115,7 @@ esac

# get latest version
if [ -z "$VERSION" ]; then
VERSION=$(curl --silent "https://api.github.com/repos/$OWNER/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
VERSION=$(fetch "https://api.github.com/repos/$OWNER/$REPO/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/')
fi
echo_blue "Target version: $VERSION"

Expand All @@ -96,7 +124,7 @@ URL=${PROXY}https://github.com/$OWNER/$REPO/releases/download/$VERSION/${REPO}_$
echo_blue "Downloading $REPO from $URL"

# download and extract
wget -q --show-progress -O - "$URL" | tar -xz && \
download "$URL" | tar -xz && \
mv $REPO $LOCATION/$REPO && \
chmod +x $LOCATION/$REPO && \
echo_green "$REPO installed successfully! Location: $LOCATION/$REPO" && \
Expand Down