summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar default2025-04-01 19:21:27 +0200
committerGravatar default2025-04-01 19:21:27 +0200
commit1962c628dfc2fa72470d39c8e1f3c975ca58faaf (patch)
tree331abb7c30bbcbdfb905a9f3c32cc4fb6c9e8078
parentUpdated RELEASE_NOTES. (diff)
parentMerge pull request 'Convert `snac-admin` to bash' (#336) from shtrophic/snac2... (diff)
downloadpenes-snac2-1962c628dfc2fa72470d39c8e1f3c975ca58faaf.tar.gz
penes-snac2-1962c628dfc2fa72470d39c8e1f3c975ca58faaf.tar.xz
penes-snac2-1962c628dfc2fa72470d39c8e1f3c975ca58faaf.zip
Merge branch 'master' of grunfink-codeberg:grunfink/snac2
-rw-r--r--examples/snac-admin42
1 files changed, 25 insertions, 17 deletions
diff --git a/examples/snac-admin b/examples/snac-admin
index 971618b..e51e28b 100644
--- a/examples/snac-admin
+++ b/examples/snac-admin
@@ -1,43 +1,51 @@
1#!/usr/bin/env fish 1#!/usr/bin/env bash
2## 2##
3## SNAC-ADMIN 3## SNAC-ADMIN
4## a simple script that is supposed to improve 4## a simple script that is supposed to improve
5## a snac admin's life, especially when snac 5## a snac admin's life, especially when snac
6## is being run as a systemd.unit with 6## is being run as a systemd.unit with
7## DynamicUser=yes enabled. 7## DynamicUser=yes enabled.
8## Please make sure to adjust SNAC_BASEDIR 8## Please make sure to adjust SNAC_DIR
9## down below according to your setup. 9## down below according to your setup.
10## 10##
11## USAGE 11## USAGE
12## snac-admin state 12## snac-admin state
13## snac-admin adduser rikkert 13## snac-admin adduser rikkert
14## snac-admin block example.org
15## snac-admin verify_links lisa
16## ...
14## 17##
15## Author: @chris@social.shtrophic.net 18## Author: @chris@social.shtrophic.net
16## 19##
17## Released into the public domain 20## Released into the public domain
18## 21##
19 22
20set -l SNAC_PID $(pidof snac) 23set -e
21set -l SNAC_BASEDIR /var/lib/snac
22 24
23if test -z $SNAC_PID 25SNAC_PID=$(pidof snac)
24 echo "no such process" 1>&2 26SNAC_DIR=/var/lib/snac
27
28SNAC_VERB=$1
29shift
30
31if [ -z $SNAC_PID ]; then
32 echo "no such process" >&2
25 exit 1 33 exit 1
26end 34fi
27 35
28if test $(id -u) -ne 0 36if [ $(id -u) -ne 0 ]; then
29 echo "not root" 1>&2 37 echo "not root" >&2
30 exit 1 38 exit 1
31end 39fi
32 40
33if ! test -d $SNAC_BASEDIR 41if [ ! -d $SNAC_DIR ]; then
34 echo "$SNAC_BASEDIR does not exist" 1>&2 42 echo "$SNAC_DIR is not a directory" >&2
35 exit 1 43 exit 1
36end 44fi
37 45
38if test -z $argv[1] 46if [ -z $SNAC_VERB ]; then
39 echo "no arguments" 1>&2 47 echo "no arguments" >&2
40 exit 1 48 exit 1
41end 49fi
42 50
43nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $argv[1] $SNAC_BASEDIR $argv[2..] 51nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $SNAC_VERB $SNAC_DIR $@