summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar grunfink2025-03-31 08:17:25 +0000
committerGravatar grunfink2025-03-31 08:17:25 +0000
commit918cd657a6e493572bdbf42b19b165c062ed92cd (patch)
tree85d04478996d908016fd58dbdf19a3528d0253b5
parentMerge pull request 'Added tittle text and class to custom emojis (issue #330)... (diff)
parentadd snac-admin (diff)
downloadpenes-snac2-918cd657a6e493572bdbf42b19b165c062ed92cd.tar.gz
penes-snac2-918cd657a6e493572bdbf42b19b165c062ed92cd.tar.xz
penes-snac2-918cd657a6e493572bdbf42b19b165c062ed92cd.zip
Merge pull request 'Add `snac-admin` example script for systemd users' (#334) from shtrophic/snac2:master into master
Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/334
-rw-r--r--examples/snac-admin43
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/snac-admin b/examples/snac-admin
new file mode 100644
index 0000000..971618b
--- /dev/null
+++ b/examples/snac-admin
@@ -0,0 +1,43 @@
1#!/usr/bin/env fish
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_BASEDIR
9## down below according to your setup.
10##
11## USAGE
12## snac-admin state
13## snac-admin adduser rikkert
14##
15## Author: @chris@social.shtrophic.net
16##
17## Released into the public domain
18##
19
20set -l SNAC_PID $(pidof snac)
21set -l SNAC_BASEDIR /var/lib/snac
22
23if test -z $SNAC_PID
24 echo "no such process" 1>&2
25 exit 1
26end
27
28if test $(id -u) -ne 0
29 echo "not root" 1>&2
30 exit 1
31end
32
33if ! test -d $SNAC_BASEDIR
34 echo "$SNAC_BASEDIR does not exist" 1>&2
35 exit 1
36end
37
38if test -z $argv[1]
39 echo "no arguments" 1>&2
40 exit 1
41end
42
43nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $argv[1] $SNAC_BASEDIR $argv[2..]