#!/usr/bin/env bash # Runs inside the fluxer-stack container from the Community Apps template. # Clones this repo onto the Unraid host, prepares the official compose bundle, # and starts it through the host Docker socket. Stopping this container stops # the Fluxer stack. Starting it brings the stack back. set -euo pipefail REPO_URL="${FLUXER_REPO_URL:-https://git.masengr.com/Michael-A-Sloan/Fluxer-selfhost-unraid.git}" ROOT="${FLUXER_REPO:-/mnt/user/appdata/fluxer-selfhost}" APPDATA="${FLUXER_APPDATA:-/mnt/user/appdata/fluxer}" DOMAIN="${FLUXER_DOMAIN:-}" MODE="$(printf '%s' "${FLUXER_MODE:-proxy}" | tr '[:upper:]' '[:lower:]')" STACK="" stop_stack() { if [[ -n "$STACK" && -f "$STACK/docker-compose.yml" ]]; then echo "Stopping the Fluxer compose stack." docker compose --project-directory "$STACK" stop || true fi exit 0 } if [[ -z "$DOMAIN" || "$DOMAIN" == "chat.example.com" ]]; then echo "Set FLUXER_DOMAIN to your real hostname, not chat.example.com, then start this container again." >&2 exit 1 fi case "$MODE" in proxy|direct) ;; *) echo "FLUXER_MODE must be proxy or direct. It is: $MODE" >&2 exit 1 ;; esac mkdir -p "$ROOT" "$APPDATA" if [[ ! -f "$ROOT/scripts/prepare-unraid.sh" ]]; then echo "Cloning $REPO_URL into $ROOT" git clone --depth 1 "$REPO_URL" "$ROOT" fi STACK="$ROOT/stack" export FLUXER_ALLOW_ANY_PATH=1 export FLUXER_APPDATA="$APPDATA" export FLUXER_STACK="$STACK" echo "Preparing Fluxer for $DOMAIN ($MODE)" bash "$ROOT/scripts/prepare-unraid.sh" "$DOMAIN" "--$MODE" docker compose --project-directory "$STACK" up -d echo "Fluxer is up. This container stays running so Unraid shows the app as started." echo "The setup token is FLUXER_SETUP_TOKEN in $STACK/.env" trap stop_stack TERM INT while true; do sleep 3600 done