Initial implementation: extend TrueCloud Backup to S3 and B2 providers
Patches middlewared at runtime via sitecustomize.py (no file edits to /usr/) and widens the UI credential dropdown from Storj-only to S3+B2+Storj. Persists across TrueNAS updates via PREINIT initshutdownscript stored in DB.
This commit is contained in:
Executable
+44
@@ -0,0 +1,44 @@
|
||||
#!/bin/bash
|
||||
# /data/truecloud-patch/apply.sh
|
||||
#
|
||||
# PREINIT script registered via TrueNAS initshutdownscript.
|
||||
# Runs on every boot before middlewared starts, re-applying patches that
|
||||
# TrueNAS updates wipe from /usr/.
|
||||
#
|
||||
# Two things are patched:
|
||||
# 1. sitecustomize.py → monkey-patches B2 restic support + URL fix into
|
||||
# middlewared at Python startup time (backend)
|
||||
# 2. Angular JS bundle → adds S3 and B2 to the credential dropdown in
|
||||
# the TrueCloud Backup task form (UI)
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
PATCH_DIR="/data/truecloud-patch"
|
||||
LOG="$PATCH_DIR/apply.log"
|
||||
|
||||
{
|
||||
echo "=== $(date -Iseconds) ==="
|
||||
|
||||
# ── 1. Backend: install sitecustomize.py ─────────────────────────────
|
||||
SITE_PKG=$(python3 -c "import site; print(site.getsitepackages()[0])" 2>/dev/null || true)
|
||||
|
||||
if [ -z "$SITE_PKG" ]; then
|
||||
echo "WARNING: could not determine site-packages path, skipping backend patch"
|
||||
else
|
||||
# If an unrelated sitecustomize.py exists, back it up once.
|
||||
if [ -f "$SITE_PKG/sitecustomize.py" ] && \
|
||||
! grep -q "truecloud-patch" "$SITE_PKG/sitecustomize.py" 2>/dev/null; then
|
||||
cp "$SITE_PKG/sitecustomize.py" "$SITE_PKG/sitecustomize.py.pre-truecloud-patch"
|
||||
echo "Backed up existing sitecustomize.py"
|
||||
fi
|
||||
|
||||
cp "$PATCH_DIR/sitecustomize.py" "$SITE_PKG/sitecustomize.py"
|
||||
echo "Installed sitecustomize.py → $SITE_PKG/sitecustomize.py"
|
||||
fi
|
||||
|
||||
# ── 2. UI: patch Angular bundle ──────────────────────────────────────
|
||||
python3 "$PATCH_DIR/patch_ui.py"
|
||||
|
||||
echo "=== done ==="
|
||||
|
||||
} >> "$LOG" 2>&1
|
||||
Reference in New Issue
Block a user