zoraxy-headers/install.sh

67 lines
2.1 KiB
Bash
Executable file

#!/usr/bin/env bash
#==============================================================================
# Header Tagger — Zoraxy Plugin Installer
# Clones, builds, and installs the zoraxy-headers plugin.
#==============================================================================
set -euo pipefail
GREEN='\033[0;32m'; YELLOW='\033[1;33m'; RED='\033[0;31m'; NC='\033[0m'
log() { echo -e "${GREEN}[+]${NC} $*"; }
warn() { echo -e "${YELLOW}[!]${NC} $*"; }
err() { echo -e "${RED}[✗]${NC} $*"; }
PLUGIN_REPO="https://git.lohmar.co.uk/cclohmar/zoraxy-headers.git"
PLUGIN_DIR="/opt/zoraxy/plugins/zoraxy-headers"
# Ensure root
if [[ $EUID -ne 0 ]]; then
warn "Requires root. Restarting with sudo..."
sudo bash "$0" "$@"
exit $?
fi
# Detect OS + install deps
if [ -f /etc/os-release ]; then . /etc/os-release; else OS_ID="unknown"; fi
log "Detected: $OS_ID"
case "$OS_ID" in
debian|ubuntu|raspbian|linuxmint)
apt-get update -qq && apt-get install -y -qq git curl golang-go ;;
rhel|centos|fedora|rocky|almalinux|amzn)
dnf install -y git curl golang 2>/dev/null || yum install -y git curl golang ;;
alpine) apk add --no-cache git curl go ;;
arch|manjaro) pacman -S --noconfirm git curl go ;;
*) warn "Unsupported OS — install git, curl, go manually." ;;
esac
# Clone / pull
if [ -d "$PLUGIN_DIR/.git" ]; then
log "Updating existing clone..."
git -C "$PLUGIN_DIR" pull origin main 2>/dev/null || true
else
log "Cloning plugin..."
mkdir -p "$(dirname "$PLUGIN_DIR")"
git clone "$PLUGIN_REPO" "$PLUGIN_DIR"
fi
# Build
log "Building..."
(cd "$PLUGIN_DIR" && go build -buildvcs=false -o zoraxy-headers .)
# Ownership
if id zoraxy &>/dev/null; then
chown -R zoraxy:zoraxy "$PLUGIN_DIR"
fi
# Restart Zoraxy to discover the plugin
log "Restarting Zoraxy..."
systemctl restart zoraxy 2>/dev/null || true
echo ""
echo -e "${GREEN}========================================${NC}"
echo -e "${GREEN} ✅ Header Tagger installed!${NC}"
echo -e "${GREEN}========================================${NC}"
echo ""
echo -e " Enable it in Zoraxy → Plugins → Header Tagger"
echo -e " Access at: /plugin.ui/zoraxy-headers/"
echo ""