From 48acfc62bc2a6e3b1f9feb44f46a07d692dd83c7 Mon Sep 17 00:00:00 2001 From: Roland Date: Sat, 14 Feb 2026 15:37:09 -0700 Subject: [PATCH] Creating script to reset tags. --- scripts/reset_tags.sh | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100755 scripts/reset_tags.sh diff --git a/scripts/reset_tags.sh b/scripts/reset_tags.sh new file mode 100755 index 00000000..2e5ac136 --- /dev/null +++ b/scripts/reset_tags.sh @@ -0,0 +1,22 @@ +#!/usr/bin/env bash + +source /opt/wrolpi/wrolpi/scripts/lib.sh + +# Re-execute this script if it wasn't called with sudo. +if [ $EUID != 0 ]; then + sudo "$0" "$@" + exit $? +fi + +yes_or_no "Are you sure you want to delete all tags? This cannot be undone." || exit 0 + +set -x + +systemctl stop wrolpi-api + +# Delete all tag relationships and tags from the database. +sudo -iu postgres psql -d wrolpi -c "DELETE FROM tag_zim;" +sudo -iu postgres psql -d wrolpi -c "DELETE FROM tag_file;" +sudo -iu postgres psql -d wrolpi -c "DELETE FROM tag;" + +systemctl start wrolpi-api \ No newline at end of file