diff options
| author | shtrophic <christoph@liebender.dev> | 2025-03-30 22:13:54 +0200 |
|---|---|---|
| committer | shtrophic <christoph@liebender.dev> | 2025-03-30 22:13:54 +0200 |
| commit | 84e72a52286db8e0af2d4a671f4b042d3e69f0d2 (patch) | |
| tree | 85d04478996d908016fd58dbdf19a3528d0253b5 /examples | |
| parent | 741ea91e5d05e38042a5624e39ef0f090f438156 (diff) | |
add snac-admin
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/snac-admin | 43 |
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 @@ +#!/usr/bin/env fish +## +## SNAC-ADMIN +## a simple script that is supposed to improve +## a snac admin's life, especially when snac +## is being run as a systemd.unit with +## DynamicUser=yes enabled. +## Please make sure to adjust SNAC_BASEDIR +## down below according to your setup. +## +## USAGE +## snac-admin state +## snac-admin adduser rikkert +## +## Author: @chris@social.shtrophic.net +## +## Released into the public domain +## + +set -l SNAC_PID $(pidof snac) +set -l SNAC_BASEDIR /var/lib/snac + +if test -z $SNAC_PID + echo "no such process" 1>&2 + exit 1 +end + +if test $(id -u) -ne 0 + echo "not root" 1>&2 + exit 1 +end + +if ! test -d $SNAC_BASEDIR + echo "$SNAC_BASEDIR does not exist" 1>&2 + exit 1 +end + +if test -z $argv[1] + echo "no arguments" 1>&2 + exit 1 +end + +nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $argv[1] $SNAC_BASEDIR $argv[2..] |