#!/bin/bash # Points the legacy /tmp/memwatch/{run,full}.sh at the repo scripts, so older # instructions keep working after /tmp is cleared (reboot). Each shim prefers # the main clone's copy and falls back to the copy this was installed from (a # worktree may be removed later). Shims are replaced atomically, so a run that # is already executing the old file is unaffected. # # Usage: app/tool/memwatch/install.sh set -eu here=$(cd "$(dirname "$0")" && pwd) common=$(git -C "$here" rev-parse --path-format=absolute --git-common-dir) main="$(dirname "$common")/app/tool/memwatch" dir=${MEMWATCH_DIR:-/tmp/memwatch} mkdir -p "$dir" for name in run full; do tmp=$(mktemp "$dir/.$name.XXXXXX") cat > "$tmp" <&2; exit 127 EOF chmod +x "$tmp" mv -f "$tmp" "$dir/$name.sh" done echo "$dir/{run,full}.sh -> $main (fallback $here)"