Establish this repo as a collection of independent script folders for the self-hosted environment (odin, an Unraid host). - CLAUDE.md: repo conventions, the odin stack, and MemPalace usage. The infrastructure facts are carried over from the FamilySync project, where they are documented and verified; the mapping of the name "odin" to that host is assumed and flagged for confirmation, along with the SSH/deploy gaps marked "?". - Core rule: each collection is a self-contained top-level folder owning its own docs, config, and dependencies. No shared/ or utils/ at the root — duplication is preferred over coupling so a collection stays independently deletable. - _template/: scaffold making that rule concrete. The bash entrypoint ships strict mode, --dry-run, and a required-env guard (all four paths tested). - mempalace.yaml: wing "odin-scripts", set explicitly because basename auto-detection would produce the colliding wing "scripts". Tracked rather than gitignored so a fresh clone keeps the config; entities.json stays ignored. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
56 lines
1.1 KiB
Bash
Executable File
56 lines
1.1 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
# Template entrypoint. Copy, rename, and replace main().
|
|
set -euo pipefail
|
|
|
|
readonly SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
readonly COLLECTION_DIR="$(dirname "$SCRIPT_DIR")"
|
|
|
|
DRY_RUN=0
|
|
|
|
usage() {
|
|
cat <<'EOF'
|
|
Usage: example [--dry-run] [--help]
|
|
|
|
--dry-run Show what would happen without changing anything.
|
|
--help Show this message.
|
|
EOF
|
|
}
|
|
|
|
log() { printf '%s\n' "$*"; }
|
|
warn() { printf '%s\n' "$*" >&2; }
|
|
die() { warn "error: $*"; exit 1; }
|
|
|
|
# Run a mutating command, or describe it under --dry-run.
|
|
run() {
|
|
if (( DRY_RUN )); then
|
|
log "[dry-run] $*"
|
|
else
|
|
"$@"
|
|
fi
|
|
}
|
|
|
|
load_env() {
|
|
local env_file="$COLLECTION_DIR/.env"
|
|
[[ -f "$env_file" ]] || return 0
|
|
set -a; . "$env_file"; set +a
|
|
}
|
|
|
|
main() {
|
|
while (( $# )); do
|
|
case "$1" in
|
|
--dry-run) DRY_RUN=1 ;;
|
|
--help|-h) usage; exit 0 ;;
|
|
*) die "unknown argument: $1" ;;
|
|
esac
|
|
shift
|
|
done
|
|
|
|
load_env
|
|
: "${EXAMPLE_HOST:?EXAMPLE_HOST is not set — see .env.example}"
|
|
|
|
log "target: $EXAMPLE_HOST"
|
|
run true # replace with the real work
|
|
}
|
|
|
|
main "$@"
|