summaryrefslogtreecommitdiff
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-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 @@
1#!/usr/bin/env bash
2##
3## SNAC-ADMIN
4## a simple script that is supposed to improve
5## a snac admin's life, especially when snac
6## is being run as a systemd.unit with
7## DynamicUser=yes enabled.
8## Please make sure to adjust SNAC_DIR
9## down below according to your setup.
10##
11## USAGE
12## snac-admin state
13## snac-admin adduser rikkert
14## snac-admin block example.org
15## snac-admin verify_links lisa
16## ...
17##
18## Author: @chris@social.shtrophic.net
19##
20## Released into the public domain
21##
22
23set -e
24
25SNAC_PID=$(pidof snac)
26SNAC_DIR=/var/lib/snac
27
28SNAC_VERB=$1
29shift
30
31if [ -z $SNAC_PID ]; then
32 echo "no such process" >&2
33 exit 1
34fi
35
36if [ $(id -u) -ne 0 ]; then
37 echo "not root" >&2
38 exit 1
39fi
40
41if [ ! -d $SNAC_DIR ]; then
42 echo "$SNAC_DIR is not a directory" >&2
43 exit 1
44fi
45
46if [ -z $SNAC_VERB ]; then
47 echo "no arguments" >&2
48 exit 1
49fi
50
51nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $SNAC_VERB $SNAC_DIR $@