scripts: sanity/dns/wallet-cli helpers; ops cleanup

This commit is contained in:
Hernâni Marques 2026-07-09 19:57:14 +02:00
parent 1181680a4b
commit be05666737
No known key found for this signature in database
18 changed files with 1440 additions and 0 deletions

View file

@ -0,0 +1,84 @@
#!/bin/bash
# Clean agent/ops clutter under /root on koopa (host).
# Preferred scratch is LOCAL: koopa-admin-log/.tmp/ (see ops/ROOT_HYGIENE.md).
# This script only removes leftover one-offs that landed in /root by mistake.
#
# Usage (as root on koopa):
# cleanup-root-scratch.sh
# cleanup-root-scratch.sh --dry-run
set -euo pipefail
[ "$(id -u)" -eq 0 ] || { echo "root only"; exit 1; }
DRY=0
[ "${1:-}" = "--dry-run" ] && DRY=1
# Staging on host only to delete (not the canonical scratch location)
TMP_BASE=/root/.tmp-cleanup
SESSION_DIR="$TMP_BASE/session-$(date -u +%Y%m%d-%H%M)-cleanup"
mkdir -p "$SESSION_DIR"
# One-off probe filenames created during taler settle/withdraw debugging (not durable).
JUNK_GLOBS=(
c1.sh chk-order.sh mk-order.sh mk-secret.py
d3.sh d4.sh d5.sh d6.sh d7.sh d8.sh dd.sh dd2.sh
f1.sh fdo.sh fsn.sh fix-perm2.sh fix-ww.sh
ps.sh rl.sh sc.sh ss.sh ww4.sh
exchange-overrides.conf
)
run() {
if [ "$DRY" -eq 1 ]; then
echo "DRY: $*"
else
eval "$@"
fi
}
echo "=== move junk scripts to $SESSION_DIR ==="
mkdir -p "$SESSION_DIR"
moved=0
for name in "${JUNK_GLOBS[@]}"; do
f="/root/$name"
if [ -e "$f" ]; then
run "mv -f $(printf %q "$f") $(printf %q "$SESSION_DIR/")"
echo " moved $name"
moved=$((moved + 1))
fi
done
echo "moved=$moved"
# Durable scripts that belong in admin-log — re-install from tree if present, remove loose copies
ADMIN="${KOOPA_ADMIN_LOG:-/root/koopa-admin-log}"
if [ ! -d "$ADMIN/scripts" ]; then
ADMIN=/home/hernani/koopa-admin-log
fi
for pair in \
"auto-confirm-withdrawals.sh:taler-bank/auto-confirm-withdrawals.sh" \
"make-demo-withdraw-qr.sh:taler-bank/make-demo-withdraw-qr.sh"
do
base="${pair%%:*}"
rel="${pair#*:}"
src="$ADMIN/scripts/$rel"
if [ -f "/root/$base" ]; then
if [ -f "$src" ]; then
echo " /root/$base is durable → install to /usr/local/bin, remove from /root"
run "install -m 755 $(printf %q "$src") /usr/local/bin/$base"
run "rm -f /root/$base"
else
echo " keep /root/$base (no admin-log copy at $src); move to $ADMIN/scripts if you can"
fi
fi
done
echo "=== delete staged junk (canonical scratch is local koopa-admin-log/.tmp/) ==="
if [ "$DRY" -eq 1 ]; then
ls -la "$SESSION_DIR" 2>/dev/null || true
else
rm -rf "$TMP_BASE"
# remove mistaken host scratch if present
rm -rf /root/.tmp
fi
echo "=== remaining non-dot files in /root ==="
ls -la /root | grep -v '^\.' | head -60
echo "DONE"