#!/usr/bin/env bash # Shelfless installer for a Debian/Ubuntu Proxmox LXC. # Installs Node, fetches the repo, builds the frontend, and sets up a systemd service # that serves the app and reverse-proxies to your Audiobookshelf server. # # Usage (as root on the container): # REPO_URL=https://git.scarriffle.com//shelfless.git \ # ABS_URL=http://127.0.0.1:13378 PORT=8080 \ # bash install.sh # # Re-running updates an existing install. set -euo pipefail REPO_URL="${REPO_URL:?Set REPO_URL to your git repo, e.g. https://git.scarriffle.com/owner/shelfless.git}" INSTALL_DIR="${INSTALL_DIR:-/opt/shelfless}" ABS_URL="${ABS_URL:-http://127.0.0.1:13378}" PORT="${PORT:-8080}" SERVICE="${SERVICE:-shelfless}" echo "==> Installing system dependencies" apt-get update -y apt-get install -y git curl ca-certificates if ! command -v node >/dev/null 2>&1; then echo "==> Installing Node.js 20.x" curl -fsSL https://deb.nodesource.com/setup_20.x | bash - apt-get install -y nodejs fi echo " node $(node --version), npm $(npm --version)" echo "==> Fetching source into $INSTALL_DIR" if [ -d "$INSTALL_DIR/.git" ]; then git -C "$INSTALL_DIR" pull --ff-only else git clone "$REPO_URL" "$INSTALL_DIR" fi echo "==> Building" cd "$INSTALL_DIR" npm ci npm run build echo "==> Writing systemd unit /etc/systemd/system/$SERVICE.service" NODE_BIN="$(command -v node)" cat > "/etc/systemd/system/$SERVICE.service" < Enabling and starting service" systemctl daemon-reload systemctl enable --now "$SERVICE" sleep 1 systemctl --no-pager --full status "$SERVICE" || true IP="$(hostname -I 2>/dev/null | awk '{print $1}')" echo "" echo "Done. Shelfless is running:" echo " URL: http://${IP:-}:$PORT" echo " ABS: $ABS_URL" echo " Logs: journalctl -u $SERVICE -f"