snac2

Fork of https://codeberg.org/grunfink/snac2
git clone https://git.inz.fi/snac2
Log | Files | Refs | README | LICENSE

commit 918cd657a6e493572bdbf42b19b165c062ed92cd
parent 741ea91e5d05e38042a5624e39ef0f090f438156
Author: grunfink <grunfink@noreply.codeberg.org>
Date:   Mon, 31 Mar 2025 08:17:25 +0000

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

Diffstat:
Aexamples/snac-admin | 43+++++++++++++++++++++++++++++++++++++++++++
1 file changed, 43 insertions(+), 0 deletions(-)

diff --git a/examples/snac-admin 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..]