snac-admin 928 B

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  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. set -e
  23. SNAC_PID=$(pidof snac)
  24. SNAC_DIR=/var/lib/snac
  25. SNAC_VERB=$1
  26. shift
  27. if [ -z $SNAC_PID ]; then
  28. echo "no such process" >&2
  29. exit 1
  30. fi
  31. if [ $(id -u) -ne 0 ]; then
  32. echo "not root" >&2
  33. exit 1
  34. fi
  35. if [ ! -d $SNAC_DIR ]; then
  36. echo "$SNAC_DIR is not a directory" >&2
  37. exit 1
  38. fi
  39. if [ -z $SNAC_VERB ]; then
  40. echo "no arguments" >&2
  41. exit 1
  42. fi
  43. nsenter -ae -S follow -G follow -t $SNAC_PID -- snac $SNAC_VERB $SNAC_DIR $@