diff options
| author | shtrophic <christoph@liebender.dev> | 2025-04-17 22:01:21 +0200 |
|---|---|---|
| committer | shtrophic <christoph@liebender.dev> | 2025-04-17 22:01:21 +0200 |
| commit | ac8b03f9e96d5778b3c0ddfea94b54e17963a3d4 (patch) | |
| tree | b650f683bd6cea37e4d88ae247411f4f9edb2a32 /examples | |
| parent | 0aeebc177f7f40cd583c65a085c51a9398995135 (diff) | |
| parent | 8fbc8a3e14da59b9aa0640e5cc70d7556cf27c8d (diff) | |
Merge tag '2.75' into curl-smtp
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/snac-admin | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/examples/snac-admin b/examples/snac-admin new file mode 100644 index 0000000..e51e28b --- /dev/null +++ b/examples/snac-admin @@ -0,0 +1,51 @@ +#!/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_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 -e + +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 +fi + +if [ $(id -u) -ne 0 ]; then + echo "not root" >&2 + exit 1 +fi + +if [ ! -d $SNAC_DIR ]; then + echo "$SNAC_DIR is not a directory" >&2 + exit 1 +fi + +if [ -z $SNAC_VERB ]; then + echo "no arguments" >&2 + exit 1 +fi + +nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $SNAC_VERB $SNAC_DIR $@ |