S49sshguard 826 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. #!/bin/sh
  2. DAEMON="sshguard"
  3. PIDFILE="/var/run/$DAEMON.pid"
  4. start() {
  5. printf 'Starting %s: ' "$DAEMON"
  6. iptables -L sshguard > /dev/null 2>&1 || \
  7. (iptables -N sshguard && iptables -A INPUT -j sshguard)
  8. start-stop-daemon -S -q -b -p /run/sshguard.pid \
  9. -x /usr/sbin/sshguard -- -i /run/sshguard.pid
  10. status=$?
  11. if [ "$status" -eq 0 ]; then
  12. echo "OK"
  13. else
  14. echo "FAIL"
  15. fi
  16. return "$status"
  17. }
  18. stop() {
  19. printf 'Stopping %s: ' "$DAEMON"
  20. start-stop-daemon -K -q -p "$PIDFILE"
  21. status=$?
  22. if [ "$status" -eq 0 ]; then
  23. rm -f "$PIDFILE"
  24. echo "OK"
  25. else
  26. echo "FAIL"
  27. fi
  28. return "$status"
  29. }
  30. restart() {
  31. stop
  32. sleep 1
  33. start
  34. }
  35. case "$1" in
  36. start|stop|restart)
  37. "$1";;
  38. reload)
  39. # Restart, since there is no true "reload" feature.
  40. restart;;
  41. *)
  42. echo "Usage: $0 {start|stop|restart|reload}"
  43. exit 1
  44. esac