snac2

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

snac-admin (928B)


      1 #!/usr/bin/env bash
      2 ##
      3 ## SNAC-ADMIN
      4 ##  a simple script that is supposed to improve
      5 ##  a snac admin's life, especially when snac
      6 ##  is being run as a systemd.unit with
      7 ##  DynamicUser=yes enabled.
      8 ##  Please make sure to adjust SNAC_DIR
      9 ##  down below according to your setup.
     10 ##
     11 ## USAGE
     12 ##  snac-admin state
     13 ##  snac-admin adduser rikkert
     14 ##  snac-admin block example.org
     15 ##  snac-admin verify_links lisa
     16 ##  ...
     17 ##
     18 ## Author: @chris@social.shtrophic.net
     19 ## 
     20 ## Released into the public domain 
     21 ##
     22 
     23 set -e
     24 
     25 SNAC_PID=$(pidof snac)
     26 SNAC_DIR=/var/lib/snac
     27 
     28 SNAC_VERB=$1
     29 shift
     30 
     31 if [ -z $SNAC_PID ]; then
     32 	echo "no such process" >&2
     33 	exit 1
     34 fi
     35 
     36 if [ $(id -u) -ne 0 ]; then
     37 	echo "not root" >&2
     38 	exit 1
     39 fi
     40 
     41 if [ ! -d $SNAC_DIR ]; then
     42 	echo "$SNAC_DIR is not a directory" >&2
     43 	exit 1
     44 fi
     45 
     46 if [ -z $SNAC_VERB ]; then
     47 	echo "no arguments" >&2
     48 	exit 1
     49 fi
     50 
     51 nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $SNAC_VERB $SNAC_DIR $@