Files
environment/sample/uninstall_sample.sh
T
warren 205566a0f0 feat: portable sample package (100 videos w/ deep scan); clean-install wipes ALL Qdrant collections + legacy storage dirs
- sample/: build_package.sh (pack from pre-clean backup), install_sample.sh (上架), uninstall_sample.sh (下架), README
- clean-install.sh: delete every collection via /collections API + rm legacy qdrant storage dirs (~/qdrant/storage/collections etc.)
2026-11-08 22:11:50 +08:00

57 lines
1.9 KiB
Bash
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# =============================================================
# momentry sample package (下架)
# 將 sample 影片與其 deep scan 資料從本機 momentry 系統移除
#
# 用法:
# bash uninstall_sample.sh
# =============================================================
set -euo pipefail
PKG="$(cd "$(dirname "$0")" && pwd)"
MOMENTRY_DIR="${MOMENTRY_DIR:-$HOME/momentry}"
DEMO_DIR="$MOMENTRY_DIR/var/sftpgo/data/demo"
OUT_DIR="$MOMENTRY_DIR/output"
DB="${MOMENTRY_DB:-momentry}"
if [ -x /opt/homebrew/bin/psql ]; then
PSQL=/opt/homebrew/bin/psql
elif [ -x "$HOME/opt_pgsql/bin/psql" ]; then
PSQL="$HOME/opt_pgsql/bin/psql"
else
PSQL=$(command -v psql || true)
[ -n "$PSQL" ] || { echo "!! 找不到 psql"; exit 1; }
fi
[ -f "$PKG/manifest.tsv" ] || { echo "!! 找不到 manifest.tsv"; exit 1; }
UUIDS=$(cut -f1 "$PKG/manifest.tsv" | tr '\n' ',' | sed 's/,$//')
FNAME_TABLES="processor_results monitor_jobs scenes chunk speaker_detections trace_profiles trace_operation_history tkg_nodes tkg_edges tkg_operation_log pipeline_progress"
echo "=== 下架 sample data($(wc -l < "$PKG/manifest.tsv" | tr -d ' ') 支影片)==="
for t in $FNAME_TABLES videos; do
"$PSQL" -U "${MOMENTRY_PGUSER:-accusys}" -d "$DB" -q -v ON_ERROR_STOP=1 <<SQL || echo "(略過 $t)"
DO \$\$
DECLARE t regclass := to_regclass('public.$t');
BEGIN
IF t IS NOT NULL THEN
EXECUTE format('DELETE FROM %I WHERE file_uuid IN (%s);', '$t', '$UUIDS');
END IF;
END \$\$;
SQL
done
echo "[1/3] 刪除 output JSON"
while IFS=$'\t' read -r uuid fname; do
rm -f "$OUT_DIR"/"$uuid".* 2>/dev/null || true
[ -d "$OUT_DIR/$uuid" ] && rm -rf "$OUT_DIR/$uuid" || true
done < "$PKG/manifest.tsv"
echo "[2/3] 刪除影片檔"
while IFS=$'\t' read -r uuid fname; do
[ -n "$fname" ] && rm -f "$DEMO_DIR/$fname" || true
done < "$PKG/manifest.tsv"
echo "[3/3] 完成"
"$PSQL" -U "${MOMENTRY_PGUSER:-accusys}" -d "$DB" -t -A -c "SELECT 'videos 殘留='||COUNT(*) FROM videos;"