feat: greenfield deployment — no Go required
- install.sh detects if Go is installed - If Go available: builds from source (current behavior) - If Go missing: downloads pre-built binary from latest release - Detects amd64/arm64 architecture automatically - Same logic applies to -update mode - Removed hard dependency on ollama.service in systemd unit
This commit is contained in:
parent
59788ba0c8
commit
f9a7df1580
1 changed files with 31 additions and 7 deletions
38
install.sh
38
install.sh
|
|
@ -69,7 +69,16 @@ if [ "${1:-}" = "-update" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
info "Rebuilding binary..."
|
info "Rebuilding binary..."
|
||||||
CGO_ENABLED=0 go build -ldflags="-s -w" -o receiptnext .
|
if command -v go &>/dev/null; then
|
||||||
|
CGO_ENABLED=0 go build -ldflags="-s -w" -o receiptnext .
|
||||||
|
else
|
||||||
|
warn "Go not found — downloading pre-built binary..."
|
||||||
|
TAG=$(curl -fsSL https://git.lohmar.co.uk/api/v1/repos/cclohmar/ReceiptNext/releases/latest \
|
||||||
|
| python3 -c "import json,sys; print(json.load(sys.stdin).get('tag_name','v1.0.0'))" 2>/dev/null || echo "v1.0.0")
|
||||||
|
ARCH="$(uname -m)"; [ "$ARCH" = "x86_64" ] && ARCH="amd64"; [ "$ARCH" = "aarch64" ] && ARCH="arm64"
|
||||||
|
sudo_if curl -fsSL -o receiptnext "https://git.lohmar.co.uk/cclohmar/ReceiptNext/releases/download/${TAG}/receiptnext-linux-${ARCH}"
|
||||||
|
sudo_if chmod +x receiptnext
|
||||||
|
fi
|
||||||
|
|
||||||
info "Restarting service..."
|
info "Restarting service..."
|
||||||
systemctl restart "$SERVICE_NAME"
|
systemctl restart "$SERVICE_NAME"
|
||||||
|
|
@ -103,10 +112,26 @@ else
|
||||||
cd "$INSTALL_DIR"
|
cd "$INSTALL_DIR"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# ── 2. Build binary ──────────────────────────────────────────────
|
# ── 2. Build or download binary ──────────────────────────────────
|
||||||
info "Building binary (pure Go, no CGO)..."
|
ARCH="$(uname -m)"
|
||||||
CGO_ENABLED=0 go build -ldflags="-s -w" -o receiptnext .
|
case "$ARCH" in
|
||||||
info "Binary built: $INSTALL_DIR/receiptnext"
|
x86_64) ARCH="amd64" ;;
|
||||||
|
aarch64) ARCH="arm64" ;;
|
||||||
|
*) err "Unsupported architecture: $ARCH"; exit 1 ;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
if command -v go &>/dev/null; then
|
||||||
|
info "Building binary from source (pure Go, no CGO)..."
|
||||||
|
CGO_ENABLED=0 go build -ldflags="-s -w" -o receiptnext .
|
||||||
|
else
|
||||||
|
info "Go not found — downloading pre-built binary..."
|
||||||
|
TAG=$(curl -fsSL https://git.lohmar.co.uk/api/v1/repos/cclohmar/ReceiptNext/releases/latest \
|
||||||
|
| python3 -c "import json,sys; print(json.load(sys.stdin).get('tag_name','v1.0.0'))" 2>/dev/null || echo "v1.0.0")
|
||||||
|
URL="https://git.lohmar.co.uk/cclohmar/ReceiptNext/releases/download/${TAG}/receiptnext-linux-${ARCH}"
|
||||||
|
sudo_if curl -fsSL -o receiptnext "$URL"
|
||||||
|
sudo_if chmod +x receiptnext
|
||||||
|
fi
|
||||||
|
info "Binary ready: $INSTALL_DIR/receiptnext"
|
||||||
|
|
||||||
# ── 3. Create runtime directories ────────────────────────────────
|
# ── 3. Create runtime directories ────────────────────────────────
|
||||||
sudo_if mkdir -p storage
|
sudo_if mkdir -p storage
|
||||||
|
|
@ -291,8 +316,7 @@ sudo_if tee "/etc/systemd/system/${SERVICE_NAME}.service" > /dev/null << SERVEOF
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=ReceiptNext — AI-Powered Expense Tracker
|
Description=ReceiptNext — AI-Powered Expense Tracker
|
||||||
Documentation=https://git.lohmar.co.uk/cclohmar/ReceiptNext
|
Documentation=https://git.lohmar.co.uk/cclohmar/ReceiptNext
|
||||||
After=network.target ollama.service
|
After=network.target
|
||||||
Wants=ollama.service
|
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
Type=simple
|
Type=simple
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue