aboutsummaryrefslogtreecommitdiff
path: root/examples/snac-admin
diff options
context:
space:
mode:
author_ <pmjv@noreply.codeberg.org>2025-04-06 07:22:44 +0000
committer_ <pmjv@noreply.codeberg.org>2025-04-06 07:22:44 +0000
commit3c427faaf8bc3c1cf942566252a098b81c603419 (patch)
tree5bdaea6008da151ef0a5a56771691f8073d80c9c /examples/snac-admin
parent0e4c210e7ad9c3b7d0e37b71b2d91c6b4798b799 (diff)
parent6f884e0d5d4eb9be41764c5ae16da52fed997e88 (diff)
Merge pull request 'master' (#1) from grunfink/snac2:master into master
Reviewed-on: https://codeberg.org/pmjv/snac2/pulls/1
Diffstat (limited to 'examples/snac-admin')
-rw-r--r--examples/snac-admin51
1 files changed, 51 insertions, 0 deletions
diff --git a/examples/snac-admin b/examples/snac-admin
new file mode 100644
index 0000000..e51e28b
--- /dev/null
+++ b/examples/snac-admin
@@ -0,0 +1,51 @@
+#!/usr/bin/env bash
+##
+## SNAC-ADMIN
+## a simple script that is supposed to improve
+## a snac admin's life, especially when snac
+## is being run as a systemd.unit with
+## DynamicUser=yes enabled.
+## Please make sure to adjust SNAC_DIR
+## down below according to your setup.
+##
+## USAGE
+## snac-admin state
+## snac-admin adduser rikkert
+## snac-admin block example.org
+## snac-admin verify_links lisa
+## ...
+##
+## Author: @chris@social.shtrophic.net
+##
+## Released into the public domain
+##
+
+set -e
+
+SNAC_PID=$(pidof snac)
+SNAC_DIR=/var/lib/snac
+
+SNAC_VERB=$1
+shift
+
+if [ -z $SNAC_PID ]; then
+ echo "no such process" >&2
+ exit 1
+fi
+
+if [ $(id -u) -ne 0 ]; then
+ echo "not root" >&2
+ exit 1
+fi
+
+if [ ! -d $SNAC_DIR ]; then
+ echo "$SNAC_DIR is not a directory" >&2
+ exit 1
+fi
+
+if [ -z $SNAC_VERB ]; then
+ echo "no arguments" >&2
+ exit 1
+fi
+
+nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $SNAC_VERB $SNAC_DIR $@