Add curl one-liner install support

- Switch REPO_URL to HTTPS for machines without SSH keys
- Handle piped execution (curl | bash) where BASH_SOURCE is unavailable
- Add one-liner install commands to README (root and user mode)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
shuki
2026-03-05 21:33:11 +02:00
parent 43daeec779
commit 30c87a9147
2 changed files with 35 additions and 19 deletions

View File

@@ -41,10 +41,26 @@ A generic Linux backup tool with a Whiptail TUI and CLI interface. Define named
## Installation ## Installation
### One-liner (root)
```bash ```bash
git clone ssh://git@git.linux-hosting.co.il:2222/shukivaknin/gniza4linux.git curl -sSL https://git.linux-hosting.co.il/shukivaknin/gniza4linux/raw/branch/main/scripts/install.sh | sudo bash
```
### One-liner (user mode)
```bash
curl -sSL https://git.linux-hosting.co.il/shukivaknin/gniza4linux/raw/branch/main/scripts/install.sh | bash
```
### From source
```bash
git clone https://git.linux-hosting.co.il/shukivaknin/gniza4linux.git
cd gniza4linux cd gniza4linux
bash scripts/install.sh sudo bash scripts/install.sh # root mode
# or
bash scripts/install.sh # user mode
``` ```
Root mode installs to `/usr/local/gniza`. User mode installs to `~/.local/share/gniza`. Root mode installs to `/usr/local/gniza`. User mode installs to `~/.local/share/gniza`.

View File

@@ -1,18 +1,14 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eo pipefail set -eo pipefail
REPO_URL="ssh://git@git.linux-hosting.co.il:2222/shukivaknin/gniza4linux.git" REPO_URL="https://git.linux-hosting.co.il/shukivaknin/gniza4linux.git"
# Colors # Colors — force enable when piped (curl | bash), since output still goes to terminal
if [[ -t 1 ]]; then C_GREEN=$'\033[0;32m'
C_GREEN=$'\033[0;32m' C_RED=$'\033[0;31m'
C_RED=$'\033[0;31m' C_YELLOW=$'\033[0;33m'
C_YELLOW=$'\033[0;33m' C_BOLD=$'\033[1m'
C_BOLD=$'\033[1m' C_RESET=$'\033[0m'
C_RESET=$'\033[0m'
else
C_GREEN="" C_RED="" C_YELLOW="" C_BOLD="" C_RESET=""
fi
info() { echo "${C_GREEN}[INFO]${C_RESET} $*"; } info() { echo "${C_GREEN}[INFO]${C_RESET} $*"; }
warn() { echo "${C_YELLOW}[WARN]${C_RESET} $*" >&2; } warn() { echo "${C_YELLOW}[WARN]${C_RESET} $*" >&2; }
@@ -43,12 +39,16 @@ echo ""
# ── Determine source ──────────────────────────────────────── # ── Determine source ────────────────────────────────────────
SOURCE_DIR="" SOURCE_DIR=""
# Check if running from a local clone # Check if running from a local clone (won't work when piped via curl)
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" if [[ -n "${BASH_SOURCE[0]:-}" && "${BASH_SOURCE[0]}" != "bash" ]]; then
if [[ -f "$SCRIPT_DIR/../lib/constants.sh" && -f "$SCRIPT_DIR/../bin/gniza" ]]; then SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" 2>/dev/null && pwd)" || true
SOURCE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)" if [[ -n "${SCRIPT_DIR:-}" && -f "$SCRIPT_DIR/../lib/constants.sh" && -f "$SCRIPT_DIR/../bin/gniza" ]]; then
info "Installing from local clone: $SOURCE_DIR" SOURCE_DIR="$(cd "$SCRIPT_DIR/.." && pwd)"
else info "Installing from local clone: $SOURCE_DIR"
fi
fi
if [[ -z "$SOURCE_DIR" ]]; then
# Clone from git # Clone from git
if ! command -v git &>/dev/null; then if ! command -v git &>/dev/null; then
die "git is required to install gniza4linux (or run from a local clone)" die "git is required to install gniza4linux (or run from a local clone)"