1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 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 $@
|