You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

rspamd_debian.in 3.3KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. #! /bin/sh
  2. ### BEGIN INIT INFO
  3. # Provides: rspamd
  4. # Required-Start: $syslog
  5. # Required-Stop: $syslog
  6. # Default-Start: 2 3 4 5
  7. # Default-Stop: 0 1 6
  8. # Short-Description: Rspamd spam filtering system
  9. # Description: Rspamd is fast and modular spam filtering system written in C
  10. ### END INIT INFO
  11. # Author: Vsevolod Stakhov <vsevolod@highsecure.ru>
  12. # PATH should only include /usr/* if it runs after the mountnfs.sh script
  13. PATH=/sbin:/usr/sbin:/bin:/usr/bin
  14. DESC="Rspamd"
  15. NAME=rspamd
  16. DAEMON=/usr/bin/$NAME
  17. DAEMON_ARGS="-c /etc/rspamd.xml"
  18. PIDFILE=/var/run/rspamd/$NAME.pid
  19. SCRIPTNAME=/etc/init.d/$NAME
  20. # Exit if the package is not installed
  21. [ -x "$DAEMON" ] || exit 0
  22. # Load the VERBOSE setting and other rcS variables
  23. . /lib/init/vars.sh
  24. # Define LSB log_* functions.
  25. # Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
  26. . /lib/lsb/init-functions
  27. #
  28. # Function that starts the daemon/service
  29. #
  30. do_start()
  31. {
  32. # Return
  33. # 0 if daemon has been started
  34. # 1 if daemon was already running
  35. # 2 if daemon could not be started
  36. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \
  37. || return 1
  38. start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON -- \
  39. $DAEMON_ARGS \
  40. || return 2
  41. }
  42. #
  43. # Function that stops the daemon/service
  44. #
  45. do_stop()
  46. {
  47. # Return
  48. # 0 if daemon has been stopped
  49. # 1 if daemon was already stopped
  50. # 2 if daemon could not be stopped
  51. # other if a failure occurred
  52. start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE --name $NAME
  53. RETVAL="$?"
  54. [ "$RETVAL" = 2 ] && return 2
  55. # Wait for children to finish too if this is a daemon that forks
  56. # and if the daemon is only ever run from this initscript.
  57. # If the above conditions are not satisfied then add some other code
  58. # that waits for the process to drop all resources that could be
  59. # needed by services started subsequently. A last resort is to
  60. # sleep for some time.
  61. start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON
  62. [ "$?" = 2 ] && return 2
  63. # Many daemons don't delete their pidfiles when they exit.
  64. rm -f $PIDFILE
  65. return "$RETVAL"
  66. }
  67. #
  68. # Function that sends a SIGHUP to the daemon/service
  69. #
  70. do_reload() {
  71. start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME
  72. return 0
  73. }
  74. case "$1" in
  75. start)
  76. [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
  77. do_start
  78. case "$?" in
  79. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  80. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  81. esac
  82. ;;
  83. stop)
  84. [ "$VERBOSE" != no ] && log_daemon_msg "Stopping $DESC" "$NAME"
  85. do_stop
  86. case "$?" in
  87. 0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
  88. 2) [ "$VERBOSE" != no ] && log_end_msg 1 ;;
  89. esac
  90. ;;
  91. status)
  92. status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $?
  93. ;;
  94. reload|force-reload)
  95. log_daemon_msg "Reloading $DESC" "$NAME"
  96. do_reload
  97. log_end_msg $?
  98. ;;
  99. restart)
  100. log_daemon_msg "Restarting $DESC" "$NAME"
  101. do_stop
  102. case "$?" in
  103. 0|1)
  104. do_start
  105. case "$?" in
  106. 0) log_end_msg 0 ;;
  107. 1) log_end_msg 1 ;; # Old process is still running
  108. *) log_end_msg 1 ;; # Failed to start
  109. esac
  110. ;;
  111. *)
  112. # Failed to stop
  113. log_end_msg 1
  114. ;;
  115. esac
  116. ;;
  117. *)
  118. echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2
  119. exit 3
  120. ;;
  121. esac
  122. :