#!/bin/bash # dev_install.sh — symlinks the OS-appropriate plugin into the web server for local development. # Run once after cloning. Re-run if the repo is moved. # Safe to re-run: removes stale symlink before recreating. # # Plugin layout: # Plugin/unraid/ ← Unraid plugin (PHP, served by emhttp at /usr/local/emhttp/plugins/) # Plugin/debian/ ← future # Plugin// ← future # # Adding a new OS: # 1. Create Plugin// with the OS-appropriate web app files # 2. Add detection + TARGET path below set -euo pipefail PLUGIN_NAME="varaverk" SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # ── Detect OS ──────────────────────────────────────────────────────────────── detect_os() { if [[ -f /etc/unraid-version ]]; then echo "unraid" elif [[ -f /etc/debian_version ]]; then echo "debian" elif [[ -f /etc/arch-release ]]; then echo "arch" else echo "unknown"; fi } OS="${1:-$(detect_os)}" # accept override: ./dev_install.sh unraid # ── OS-specific install target ──────────────────────────────────────────────── case "$OS" in unraid) SOURCE="$SCRIPT_DIR/unraid" TARGET="/usr/local/emhttp/plugins/$PLUGIN_NAME" ;; debian|arch) echo "OS '$OS' detected but plugin target path not yet defined." echo "Add the TARGET= line for this OS in dev_install.sh." exit 1 ;; unknown|*) echo "Unsupported OS — could not detect from /etc/*-version markers." echo "Usage: $0 (e.g. $0 unraid)" exit 1 ;; esac # ── Install ─────────────────────────────────────────────────────────────────── if [[ ! -d "$SOURCE" ]]; then echo "ERROR: Plugin source not found: $SOURCE" exit 1 fi if [[ -L "$TARGET" ]]; then echo "Removing existing symlink: $TARGET" rm "$TARGET" elif [[ -d "$TARGET" ]]; then echo "ERROR: $TARGET exists as a real directory — remove it manually first." exit 1 fi ln -s "$SOURCE" "$TARGET" echo "" echo "OS: $OS" echo "Source: $SOURCE" echo "Target: $TARGET" echo "" echo "Plugin linked. Changes in Plugin/$OS/ take effect immediately."