Skip to content

Commit

Permalink
chore(script): update install script
Browse files Browse the repository at this point in the history
  • Loading branch information
QaidVoid committed Nov 2, 2024
1 parent 7bea339 commit a18cba3
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 4 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,26 @@ A fast, modern package manager for Linux systems.
```sh
curl -qfsSL "https://soar.qaidvoid.dev/install.sh" | sh
```
The install script supports several environment variables to customize the installation:

- `SOAR_VERSION`: Specify the version to install
```sh
# Install specific version
SOAR_VERSION=0.4.0 curl -qfsSL "https://soar.qaidvoid.dev/install.sh" | sh

# Install latest release
SOAR_VERSION=latest curl -qfsSL "https://soar.qaidvoid.dev/install.sh" | sh

# Install nightly build
SOAR_VERSION=nightly curl -qfsSL "https://soar.qaidvoid.dev/install.sh" | sh
```

- `SOAR_INSTALL_DIR`: Specify custom installation directory
```sh
SOAR_INSTALL_DIR=~/.bin curl -qfsSL "https://soar.qaidvoid.dev/install.sh" | sh
```

> **Note**: If no installation directory is specified, the script will attempt to install in `~/.local/bin`. If that's not available, it will install in the current directory.
### From Source
Expand Down
33 changes: 29 additions & 4 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,9 @@
set -eu

main() {
DEFAULT_VERSION="0.3.1"
DEFAULT_VERSION="latest"
SOAR_VERSION="${SOAR_VERSION:-$DEFAULT_VERSION}"

# Function to check for curl or wget
check_download_tool() {
if command -v curl >/dev/null 2>&1; then
Expand Down Expand Up @@ -49,12 +50,29 @@ main() {
return
fi

# Fallback to /usr/local/bin if running as root
if [ "$(id -u)" = "0" ]; then
if [ -d "/usr/local/bin" ] && [ -w "/usr/local/bin" ]; then
printf "/usr/local/bin"
return
fi
fi

# Fallback to current directory
echo "Notice: ~/.local/bin not found or not writable. Installing in current directory."
echo "You should move the binary to a location in your $PATH."
echo "Notice: ~/.local/bin not found or not writable. Installing in current directory." >&2
echo "You should move the binary to a location in your \$PATH." >&2
printf "%s" "$(pwd)"
}

get_latest_version() {
latest_version=$($DOWNLOAD_TOOL "https://api.github.com/repos/QaidVoid/soar/releases/latest" | grep '"tag_name":' | sed -E 's/.*"v([^"]+)".*/\1/')
if [ -z "$latest_version" ]; then
echo "Error: Could not determine latest version"
exit 1
fi
printf "%s" "$latest_version"
}

# Function to download and install
install_soar() {
DOWNLOAD_TOOL=$(check_download_tool)
Expand All @@ -77,7 +95,14 @@ main() {

# Get latest release URL
echo "Downloading Soar..."
RELEASE_URL="https://github.com/QaidVoid/soar/releases/download/v$SOAR_VERSION/soar-$SOAR_VERSION-$ARCH-linux"
if [[ "$SOAR_VERSION" == *"nightly"* ]]; then
RELEASE_URL="https://github.com/QaidVoid/soar/releases/download/nightly/soar-nightly-$ARCH-linux"
elif [[ "$SOAR_VERSION" == *"latest"* ]]; then
SOAR_VERSION=$(get_latest_version)
RELEASE_URL="https://github.com/QaidVoid/soar/releases/latest/download/soar-$SOAR_VERSION-$ARCH-linux"
else
RELEASE_URL="https://github.com/QaidVoid/soar/releases/download/v$SOAR_VERSION/soar-$SOAR_VERSION-$ARCH-linux"
fi
echo $RELEASE_URL

# Download and install
Expand Down

0 comments on commit a18cba3

Please sign in to comment.