commit 918cd65
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
1 files changed,
+43,
-0
+43,
-0
1@@ -0,0 +1,43 @@
2+#!/usr/bin/env fish
3+##
4+## SNAC-ADMIN
5+## a simple script that is supposed to improve
6+## a snac admin's life, especially when snac
7+## is being run as a systemd.unit with
8+## DynamicUser=yes enabled.
9+## Please make sure to adjust SNAC_BASEDIR
10+## down below according to your setup.
11+##
12+## USAGE
13+## snac-admin state
14+## snac-admin adduser rikkert
15+##
16+## Author: @chris@social.shtrophic.net
17+##
18+## Released into the public domain
19+##
20+
21+set -l SNAC_PID $(pidof snac)
22+set -l SNAC_BASEDIR /var/lib/snac
23+
24+if test -z $SNAC_PID
25+ echo "no such process" 1>&2
26+ exit 1
27+end
28+
29+if test $(id -u) -ne 0
30+ echo "not root" 1>&2
31+ exit 1
32+end
33+
34+if ! test -d $SNAC_BASEDIR
35+ echo "$SNAC_BASEDIR does not exist" 1>&2
36+ exit 1
37+end
38+
39+if test -z $argv[1]
40+ echo "no arguments" 1>&2
41+ exit 1
42+end
43+
44+nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $argv[1] $SNAC_BASEDIR $argv[2..]