#!/usr/bin/env bash # Prepare Unraid appdata, clone the Fluxer mirror, and write example configs. # Does not start containers and does not overwrite an existing config.json. set -euo pipefail APPDATA="${FLUXER_APPDATA:-/mnt/user/appdata/fluxer}" SRC_DIR="${APPDATA}/src" PACKAGING_DIR="$(cd "$(dirname "$0")/.." && pwd)" FLUXER_REMOTE="${FLUXER_REMOTE:-https://git.masengr.com/Michael-A-Sloan/fluxer.git}" if [[ ! -d /mnt/user/appdata ]]; then echo "Error: /mnt/user/appdata not found. Run this on the Unraid server." >&2 exit 1 fi mkdir -p "${APPDATA}/mysql" "${APPDATA}/redis" "${APPDATA}/storage" if [[ ! -d "${SRC_DIR}/.git" ]]; then echo "Cloning Fluxer mirror into ${SRC_DIR}" git clone "${FLUXER_REMOTE}" "${SRC_DIR}" else echo "Fluxer source already present at ${SRC_DIR}" fi if [[ ! -f "${APPDATA}/config.json" ]]; then cp "${PACKAGING_DIR}/config.example.json" "${APPDATA}/config.json" echo "Wrote ${APPDATA}/config.json — edit token, owners, and passwords before starting the bot." else echo "Keeping existing ${APPDATA}/config.json" fi if [[ ! -f "${APPDATA}/nodelink.config.json" ]]; then cp "${PACKAGING_DIR}/nodelink.config.json" "${APPDATA}/nodelink.config.json" echo "Wrote ${APPDATA}/nodelink.config.json" fi if [[ ! -d "${APPDATA}/storage/locales" && -d "${SRC_DIR}/storage/locales" ]]; then cp -a "${SRC_DIR}/storage/." "${APPDATA}/storage/" echo "Copied Fluxer storage/locales into appdata" fi # Official Fluxer image runs as uid/gid 10001. chown -R 10001:10001 "${APPDATA}/storage" "${APPDATA}/config.json" 2>/dev/null || true if ! docker network inspect fluxer-net >/dev/null 2>&1; then docker network create fluxer-net echo "Created docker network fluxer-net" else echo "Docker network fluxer-net already exists" fi echo echo "Bootstrap done." echo " Appdata: ${APPDATA}" echo " Source: ${SRC_DIR}" echo "Next: sh scripts/update.sh"