From 9f09e651b8a59f9f93e500b88fce6a434d936a32 Mon Sep 17 00:00:00 2001 From: luxick Date: Fri, 16 Jan 2026 13:22:21 +0100 Subject: [PATCH] add deploy script --- deploy.sh | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) create mode 100755 deploy.sh diff --git a/deploy.sh b/deploy.sh new file mode 100755 index 0000000..e3ef72e --- /dev/null +++ b/deploy.sh @@ -0,0 +1,94 @@ +#!/usr/bin/env bash +set -euo pipefail + +# Deploy this luxtools template checkout into a mounted DokuWiki plugins dir. +# Default target is the user's mount path. +# +# Usage: +# ./deploy.sh # deploy to /thebe/Web/lib/tpl/luxtools/ +# ./deploy.sh --dry-run # show what would change +# ./deploy.sh /path/to/luxtools +# ./deploy.sh --no-delete # don't delete extraneous files at target + +TARGET="/thebe/Web/lib/tpl/luxtools" +DRY_RUN=0 +DELETE=1 + +while (($#)); do + case "$1" in + --dry-run|-n) + DRY_RUN=1 + shift + ;; + --no-delete) + DELETE=0 + shift + ;; + -h|--help) + sed -n '1,80p' "$0" + exit 0 + ;; + *) + TARGET="$1" + shift + ;; + esac +done + +if ! command -v rsync >/dev/null 2>&1; then + echo "Error: rsync is required." >&2 + exit 1 +fi + +SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" + +# Safety checks: make sure source looks like luxtools plugin +if [[ ! -f "$SRC_DIR/template.info.txt" ]]; then + echo "Error: '$SRC_DIR' doesn't look like luxtools (missing template.info.txt)." >&2 + exit 1 +fi + +# Ensure target dir exists +mkdir -p "$TARGET" + +# Safety check: refuse to deploy to an obviously wrong directory. +# Allow empty dir (fresh install) OR existing luxtools template dir. +if [[ -e "$TARGET/plugin.info.txt" ]]; then + if ! grep -qi "^base\s\+luxtools" "$TARGET/template.info.txt" 2>/dev/null; then + echo "Error: target '$TARGET' has a template.info.txt, but it doesn't look like luxtools." >&2 + echo "Refusing to deploy." >&2 + exit 1 + fi +fi + +RSYNC_ARGS=( + -a + --human-readable + --itemize-changes + --chmod=Du=rwx,Dgo=rx,Fu=rw,Fgo=r + --exclude=deploy.sh + --exclude=.git/ + --exclude=_dokuwiki/ + --exclude=.github/ + --exclude=.vscode/ + --exclude=_test/ + --exclude=deleted.files + --exclude=*.swp + --exclude=*.swo + --exclude=.DS_Store +) + +if ((DRY_RUN)); then + RSYNC_ARGS+=(--dry-run) +fi + +if ((DELETE)); then + RSYNC_ARGS+=(--delete) +fi + +echo "Deploying luxtools from: $SRC_DIR/" +echo "Deploying luxtools to: $TARGET/" + +rsync "${RSYNC_ARGS[@]}" "$SRC_DIR/" "$TARGET/" + +echo "Done."