snac2

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

commit a2155e9a32391097cec750518f5f3d1ae3b83ee4
parent 918cd657a6e493572bdbf42b19b165c062ed92cd
Author: grunfink <grunfink@noreply.codeberg.org>
Date:   Tue,  1 Apr 2025 17:21:13 +0000

Merge pull request 'Convert `snac-admin` to bash' (#336) from shtrophic/snac2:master into master

Reviewed-on: https://codeberg.org/grunfink/snac2/pulls/336

Diffstat:
Mexamples/snac-admin | 42+++++++++++++++++++++++++-----------------
1 file changed, 25 insertions(+), 17 deletions(-)

diff --git a/examples/snac-admin b/examples/snac-admin @@ -1,43 +1,51 @@ -#!/usr/bin/env fish +#!/usr/bin/env bash ## ## 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 +## Please make sure to adjust SNAC_DIR ## down below according to your setup. ## ## USAGE ## snac-admin state ## snac-admin adduser rikkert +## snac-admin block example.org +## snac-admin verify_links lisa +## ... ## ## Author: @chris@social.shtrophic.net ## ## Released into the public domain ## -set -l SNAC_PID $(pidof snac) -set -l SNAC_BASEDIR /var/lib/snac +set -e -if test -z $SNAC_PID - echo "no such process" 1>&2 +SNAC_PID=$(pidof snac) +SNAC_DIR=/var/lib/snac + +SNAC_VERB=$1 +shift + +if [ -z $SNAC_PID ]; then + echo "no such process" >&2 exit 1 -end +fi -if test $(id -u) -ne 0 - echo "not root" 1>&2 +if [ $(id -u) -ne 0 ]; then + echo "not root" >&2 exit 1 -end +fi -if ! test -d $SNAC_BASEDIR - echo "$SNAC_BASEDIR does not exist" 1>&2 +if [ ! -d $SNAC_DIR ]; then + echo "$SNAC_DIR is not a directory" >&2 exit 1 -end +fi -if test -z $argv[1] - echo "no arguments" 1>&2 +if [ -z $SNAC_VERB ]; then + echo "no arguments" >&2 exit 1 -end +fi -nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $argv[1] $SNAC_BASEDIR $argv[2..] +nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $SNAC_VERB $SNAC_DIR $@