Consolidate all paths to plugin flash dir, fix watchdog 7.3 triggers

- Move SCRIPTS_DIR/DATA_DIR/STATE_DIR from appdata to /boot/config/plugins/varaverk
- All state files now in STATE_DIR (no more /tmp or /boot/config root writes)
- Bootstrap: Gitea-first clone with GitHub fallback, no array dependency
- varaverk.cfg seeded with Gitea connection settings
- .gitignore: add State_Files/, varaverk.cfg, varaverk-*.txz
- Partnership/transcode/fallback scripts use STATE_DIR variables
- PHP config.php: DATA_DIR/STATE_DIR constants, VV_SETUP_STATE_FILE dynamic
- deploy.sh PROD_ROOT updated to plugin flash dir

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Gmer4Lfe
2026-05-31 13:30:20 -04:00
co-authored by Claude Sonnet 4.6
parent 9191a54637
commit fb0530deba
40 changed files with 1609 additions and 262 deletions
+108
View File
@@ -0,0 +1,108 @@
#!/bin/bash
# ==============================================================================================
# ============================= build.sh =======================================================
# ==============================================================================================
#
# PURPOSE
# ─────────────────────────────────────────────────────────────────────────────
# Packages the plugin web files (Plugin/unraid/) into a Slackware .txz, the
# format unRAID re-installs from flash on every boot. This is the RELEASE path —
# for day-to-day development use dev_install.sh (symlink, instant edits).
#
# What it produces (in Plugin/dist/):
# varaverk-<version>-noarch-1.txz the package unRAID installs to
# /usr/local/emhttp/plugins/varaverk/
# varaverk-<version>-noarch-1.txz.sha256
#
# It also rewrites the <!ENTITY version> and <!ENTITY sha256> lines in
# Plugin/varaverk.plg so the .plg always points at the package just built.
#
# WHY a .txz (not the dev symlink):
# rc.local runs `plugin install` on every .plg at boot, BEFORE the array
# mounts. A symlink into /mnt/user/appdata can't be made that early (appdata
# isn't mounted) and the disks_mounted event hooks live behind that missing
# symlink — chicken-and-egg. A .txz lives on flash, so unRAID extracts it to
# RAM before the array starts; the event hooks are then present in time to
# rebuild cron when the array mounts. Scripts stay on appdata (git clone).
#
# ==============================================================================================
# USAGE
# ==============================================================================================
# ./build.sh # version = today's date (YYYY.MM.DD)
# ./build.sh 2026.09.01 # explicit version
#
# After building: commit Plugin/dist/<txz> + the updated .plg, then attach the
# .txz to a GitHub release tagged <version> so the .plg URL resolves for
# downloaders. (The .plg also works offline if the .txz is already cached on
# flash with a matching SHA256.)
# ==============================================================================================
set -euo pipefail
PLUGIN_NAME="varaverk"
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
SRC="$SCRIPT_DIR/unraid"
DIST="$SCRIPT_DIR/dist"
PLG="$SCRIPT_DIR/varaverk.plg"
VERSION="${1:-$(date +%Y.%m.%d)}"
PKG_BASENAME="${PLUGIN_NAME}-${VERSION}-noarch-1"
OUTFILE="$DIST/${PKG_BASENAME}.txz"
# ── Guards ──────────────────────────────────────────────────────────────────
[[ -d "$SRC" ]] || { echo "ERROR: source not found: $SRC"; exit 1; }
command -v makepkg >/dev/null || { echo "ERROR: makepkg not found (run on unRAID)"; exit 1; }
mkdir -p "$DIST"
# ── Stage files under the real install path ─────────────────────────────────
# installpkg extracts relative to / so the package must contain the full path.
STAGE="$(mktemp -d)"
trap 'rm -rf "$STAGE"' EXIT
INSTALL_ROOT="$STAGE/usr/local/emhttp/plugins/$PLUGIN_NAME"
mkdir -p "$INSTALL_ROOT"
# Copy web files; drop VCS/editor cruft and any dev-only leftovers.
cp -a "$SRC/." "$INSTALL_ROOT/"
find "$INSTALL_ROOT" -name '.git*' -prune -exec rm -rf {} + 2>/dev/null || true
find "$INSTALL_ROOT" -name '*.swp' -delete 2>/dev/null || true
# Normalise ownership/permissions inside the package.
chown -R root:root "$STAGE" 2>/dev/null || true
find "$INSTALL_ROOT" -type d -exec chmod 0755 {} +
find "$INSTALL_ROOT" -type f -exec chmod 0644 {} +
# Keep shell/event scripts executable.
find "$INSTALL_ROOT" \( -name '*.sh' -o -path '*/event/*' \) -type f -exec chmod 0755 {} +
# ── Build the package ───────────────────────────────────────────────────────
# makepkg doesn't quote its output arg internally, so build to a space-free temp
# path (the repo lives under a dir with spaces) then move into dist/.
TMP_OUT="$STAGE.txz"
( cd "$STAGE" && makepkg -l y -c y "$TMP_OUT" >/dev/null )
mv "$TMP_OUT" "$OUTFILE"
# ── Hash + record ───────────────────────────────────────────────────────────
SHA256="$(sha256sum "$OUTFILE" | awk '{print $1}')"
echo "$SHA256 ${PKG_BASENAME}.txz" > "$OUTFILE.sha256"
# ── Point the .plg at this build ────────────────────────────────────────────
if [[ -f "$PLG" ]]; then
sed -i -E "s|(<!ENTITY[[:space:]]+version[[:space:]]+\")[^\"]*(\">)|\1${VERSION}\2|" "$PLG"
sed -i -E "s|(<!ENTITY[[:space:]]+sha256[[:space:]]+\")[^\"]*(\">)|\1${SHA256}\2|" "$PLG"
fi
SIZE="$(numfmt --to=iec "$(stat -c %s "$OUTFILE")")"
cat <<EOF
Built: $OUTFILE ($SIZE)
Version: $VERSION
SHA256: $SHA256
.plg updated (version + sha256).
Next:
1) git add Plugin/dist/${PKG_BASENAME}.txz* Plugin/varaverk.plg && commit
2) Create GitHub release tagged "$VERSION", attach ${PKG_BASENAME}.txz
(skip for a local/offline install — copy the .txz to
/boot/config/plugins/$PLUGIN_NAME/ and the .plg uses the cached copy)
EOF