diff --git a/README.md b/README.md index 4057793..91adb19 100644 --- a/README.md +++ b/README.md @@ -120,6 +120,30 @@ call that path on every boot. Refresh your browser. S3 and B2 credentials now appear in the **Data Protection → TrueCloud Backup → Add** credential dropdown. +## Updating + +To update to a new version of the patch: + +```bash +cd /mnt/tank/truenas-truecloud-patch + +# If install.sh was previously run as root, the .git directory may be owned +# by root. Fix it first, or just pull as root: +sudo git pull # easiest option +# — or — +sudo chown -R $(whoami) .git && git pull + +bash install.sh +``` + +`install.sh` clears any stale kill switch, re-applies the updated patches, +and restarts middlewared. Run `python3 patch/create_task.py verify` afterwards +to confirm the patches loaded successfully. + +Check [CHANGELOG.md](CHANGELOG.md) to see what changed between versions. + +--- + ## Creating a task via CLI If the UI still shows only Storj after refreshing (e.g. the JS bundle pattern diff --git a/install.sh b/install.sh index 343448e..3c41113 100755 --- a/install.sh +++ b/install.sh @@ -16,6 +16,8 @@ set -euo pipefail +VERSION="0.0.2" + # The directory containing install.sh is the permanent install location. PATCH_DIR="$(cd "$(dirname "$0")" && pwd)" _HOOK_COMMENT='TrueCloud provider patch (S3/B2)' @@ -29,7 +31,7 @@ if [ ! -f "$PATCH_DIR/patch/apply.sh" ]; then exit 1 fi -echo "=== TrueNAS TrueCloud Provider Patch — Install ===" +echo "=== TrueNAS TrueCloud Provider Patch v${VERSION} — Install ===" echo "" # ── Preflight ───────────────────────────────────────────────────────────────── diff --git a/patch/apply.sh b/patch/apply.sh index 962342b..294cd16 100755 --- a/patch/apply.sh +++ b/patch/apply.sh @@ -18,6 +18,7 @@ # Derive PATCH_DIR from this script's location (parent of the patch/ directory). PATCH_DIR="$(cd "$(dirname "$0")/.." && pwd)" LOG="$PATCH_DIR/apply.log" +VERSION="0.0.2" # Rotate log at 512 KB to avoid unbounded growth on a system volume. # Keep two prior generations (.1 and .2) so the last three boots are always available. @@ -27,7 +28,7 @@ if [ -f "$LOG" ] && [ "$(wc -c < "$LOG")" -gt 524288 ]; then fi exec >> "$LOG" 2>&1 -echo "=== $(date -Iseconds) ===" +echo "=== $(date -Iseconds) [v${VERSION}] ===" # Kill switch: if this file exists, skip all patching and exit cleanly. # Recovery: touch "$PATCH_DIR/disabled" (then reboot or restart middlewared). diff --git a/patch/create_task.py b/patch/create_task.py index 224b993..16ce13a 100755 --- a/patch/create_task.py +++ b/patch/create_task.py @@ -48,6 +48,8 @@ import sys import urllib.error import urllib.request +__version__ = "0.0.2" + _PATCH_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) _STATUS_FILE = os.path.join(_PATCH_DIR, "hook_status.json") @@ -194,6 +196,7 @@ def main(): formatter_class=argparse.RawDescriptionHelpFormatter, epilog=__doc__.split("Examples")[1] if __doc__ and "Examples" in __doc__ else "", ) + p.add_argument("--version", "-V", action="version", version=f"truecloud-patch {__version__}") p.add_argument("--host", default=None, metavar="HOST", help="TrueNAS hostname or IP address (required except for verify)") p.add_argument("--api-key", default=None, metavar="KEY", diff --git a/recover.sh b/recover.sh index 1c00850..f132f71 100755 --- a/recover.sh +++ b/recover.sh @@ -16,8 +16,13 @@ # rm /mnt/tank/truenas-truecloud-patch/disabled # bash /mnt/tank/truenas-truecloud-patch/patch/apply.sh +VERSION="0.0.2" + PATCH_DIR="$(cd "$(dirname "$0")" && pwd)" +echo "=== TrueNAS TrueCloud Provider Patch v${VERSION} — Recover ===" +echo "" + if [ "$(id -u)" -ne 0 ]; then echo "ERROR: must be run as root." >&2 exit 1 diff --git a/uninstall.sh b/uninstall.sh index 7c29431..216001b 100755 --- a/uninstall.sh +++ b/uninstall.sh @@ -3,10 +3,12 @@ set -euo pipefail +VERSION="0.0.2" + PATCH_DIR="$(cd "$(dirname "$0")" && pwd)" _HOOK_COMMENT='TrueCloud provider patch (S3/B2)' -echo "=== TrueNAS TrueCloud Provider Patch — Uninstall ===" +echo "=== TrueNAS TrueCloud Provider Patch v${VERSION} — Uninstall ===" echo "" if [ "$(id -u)" -ne 0 ]; then