diff options
| -rw-r--r-- | examples/snac-admin | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/examples/snac-admin b/examples/snac-admin new file mode 100644 index 0000000..971618b --- /dev/null +++ b/examples/snac-admin | |||
| @@ -0,0 +1,43 @@ | |||
| 1 | #!/usr/bin/env fish | ||
| 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_BASEDIR | ||
| 9 | ## down below according to your setup. | ||
| 10 | ## | ||
| 11 | ## USAGE | ||
| 12 | ## snac-admin state | ||
| 13 | ## snac-admin adduser rikkert | ||
| 14 | ## | ||
| 15 | ## Author: @chris@social.shtrophic.net | ||
| 16 | ## | ||
| 17 | ## Released into the public domain | ||
| 18 | ## | ||
| 19 | |||
| 20 | set -l SNAC_PID $(pidof snac) | ||
| 21 | set -l SNAC_BASEDIR /var/lib/snac | ||
| 22 | |||
| 23 | if test -z $SNAC_PID | ||
| 24 | echo "no such process" 1>&2 | ||
| 25 | exit 1 | ||
| 26 | end | ||
| 27 | |||
| 28 | if test $(id -u) -ne 0 | ||
| 29 | echo "not root" 1>&2 | ||
| 30 | exit 1 | ||
| 31 | end | ||
| 32 | |||
| 33 | if ! test -d $SNAC_BASEDIR | ||
| 34 | echo "$SNAC_BASEDIR does not exist" 1>&2 | ||
| 35 | exit 1 | ||
| 36 | end | ||
| 37 | |||
| 38 | if test -z $argv[1] | ||
| 39 | echo "no arguments" 1>&2 | ||
| 40 | exit 1 | ||
| 41 | end | ||
| 42 | |||
| 43 | nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $argv[1] $SNAC_BASEDIR $argv[2..] | ||