Add self-hosted RCS backend, extension, and ops tooling
Ship the Go/SQLite API and Web UI, Chrome/Brave capture addon, Docker Compose, Pangolin reverse-proxy support, and a user-crontab watchdog so the binary stays running without systemd.
This commit is contained in:
Executable
+48
@@ -0,0 +1,48 @@
|
||||
#!/usr/bin/env bash
|
||||
# Remove local seed/test rows from data/rcs.db; keep real Reddit captures.
|
||||
set -euo pipefail
|
||||
|
||||
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
DB="${RCS_DB_PATH:-$ROOT/data/rcs.db}"
|
||||
SHOT_DIR="${RCS_DATA_DIR:-$ROOT/data}/screenshots"
|
||||
|
||||
if [[ ! -f "$DB" ]]; then
|
||||
echo "No database at $DB — nothing to prune."
|
||||
exit 0
|
||||
fi
|
||||
|
||||
before="$(sqlite3 "$DB" 'SELECT COUNT(*) FROM comments;')"
|
||||
|
||||
sqlite3 "$DB" <<'SQL'
|
||||
PRAGMA foreign_keys = ON;
|
||||
|
||||
DELETE FROM comments
|
||||
WHERE reddit_comment_id = 't1_testcomment1'
|
||||
OR reddit_comment_id LIKE 't1_page_%';
|
||||
|
||||
DELETE FROM posts
|
||||
WHERE reddit_post_id IN ('t3_testpost1', 't3_onlypost', 't3_seedpost');
|
||||
|
||||
DELETE FROM users
|
||||
WHERE reddit_user_id IN ('t2_user1', 't2_op', 't2_a', 't2_seed');
|
||||
|
||||
-- Orphan posts with no comments left
|
||||
DELETE FROM posts
|
||||
WHERE id NOT IN (SELECT DISTINCT post_id FROM comments);
|
||||
|
||||
-- Orphan users not referenced by comments or posts
|
||||
DELETE FROM users
|
||||
WHERE id NOT IN (SELECT DISTINCT author_id FROM comments)
|
||||
AND id NOT IN (SELECT DISTINCT author_id FROM posts);
|
||||
SQL
|
||||
|
||||
rm -f "$SHOT_DIR/t1_testcomment1.png"
|
||||
|
||||
after="$(sqlite3 "$DB" 'SELECT COUNT(*) FROM comments;')"
|
||||
posts="$(sqlite3 "$DB" 'SELECT COUNT(*) FROM posts;')"
|
||||
users="$(sqlite3 "$DB" 'SELECT COUNT(*) FROM users;')"
|
||||
|
||||
echo "Pruned seed/test data from $DB"
|
||||
echo " comments: $before -> $after"
|
||||
echo " posts: $posts"
|
||||
echo " users: $users"
|
||||
Reference in New Issue
Block a user