commit 84e72a5

shtrophic  ·  2025-03-30 20:13:54 +0000 UTC
parent 741ea91
add snac-admin
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..]