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.init 2.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142
  1. #!/bin/sh
  2. #
  3. # rspamd - this script starts and stops the rspamd daemon
  4. ### BEGIN INIT INFO
  5. # Provides: rspamd
  6. # Required-Start: $remote_fs $network
  7. # Required-Stop: $network $remote_fs
  8. # Default-Start: 5
  9. # Default-Stop:
  10. # Short-Description: Rspamd daemon
  11. # Description: Rspamd spam filtering daemon process
  12. ### END INIT INFO
  13. #
  14. # chkconfig: - 85 15
  15. # description: rspamd is a spam filtering system
  16. # processname: rspamd
  17. # config: /etc/rspamd/rspamd.conf
  18. # config: /etc/sysconfig/rspamd
  19. # pidfile: /var/run/rspamd/rspamd.pid
  20. # Source function library.
  21. . /etc/rc.d/init.d/functions
  22. # Source networking configuration.
  23. . /etc/sysconfig/network
  24. # Check that networking is up.
  25. [ "$NETWORKING" = "no" ] && exit 0
  26. rspamd="/usr/bin/rspamd"
  27. rspamadm="/usr/bin/rspamadm"
  28. prog=$(basename $rspamd)
  29. RSPAMD_CONF_FILE="/etc/rspamd/rspamd.conf"
  30. RSPAMD_USER="_rspamd"
  31. RSPAMD_GROUP="_rspamd"
  32. [ -f /etc/sysconfig/rspamd ] && . /etc/sysconfig/rspamd
  33. lockfile=/var/lock/subsys/rspamd
  34. start() {
  35. [ -x $rspamd ] || exit 5
  36. [ -f $rspamd_CONF_FILE ] || exit 6
  37. echo -n $"Starting $prog: "
  38. daemon $rspamd -c $RSPAMD_CONF_FILE -u $RSPAMD_USER -g $RSPAMD_GROUP
  39. retval=$?
  40. echo
  41. [ $retval -eq 0 ] && touch $lockfile
  42. return $retval
  43. }
  44. stop() {
  45. echo -n $"Stopping $prog: "
  46. killproc $prog -TERM
  47. retval=$?
  48. if [ $retval -eq 0 ]; then
  49. if [ "$CONSOLETYPE" != "serial" ]; then
  50. echo -en "\\033[16G"
  51. fi
  52. STOPTIMEOUT=30
  53. while [ $STOPTIMEOUT -gt 0 ]; do
  54. rh_status_q || break
  55. sleep 1
  56. let STOPTIMEOUT=${STOPTIMEOUT}-1
  57. done
  58. if [ $STOPTIMEOUT -eq 0 ]; then
  59. echo "Timeout error occurred trying to stop Rspamd. Forcefully stop the remaining processes."
  60. killproc $prog -KILL
  61. # Sleep forever after SIGKILL being sent (e.g. UNINT SLEEP)
  62. while rh_status_q
  63. do
  64. sleep 1
  65. echo -n $"."
  66. done
  67. fi
  68. rm -f $lockfile
  69. fi
  70. echo
  71. return $retval
  72. }
  73. restart() {
  74. configtest || return $?
  75. stop
  76. start
  77. }
  78. reload() {
  79. configtest || return $?
  80. echo -n $"Reloading $prog: "
  81. killproc $rspamd -HUP
  82. RETVAL=$?
  83. echo
  84. }
  85. force_reload() {
  86. restart
  87. }
  88. configtest() {
  89. $rspamadm configtest -c $RSPAMD_CONF_FILE
  90. }
  91. rh_status() {
  92. status $prog
  93. }
  94. rh_status_q() {
  95. rh_status >/dev/null 2>&1
  96. }
  97. case "$1" in
  98. start)
  99. rh_status_q && exit 0
  100. $1
  101. ;;
  102. stop)
  103. rh_status_q || exit 0
  104. $1
  105. ;;
  106. restart|configtest)
  107. $1
  108. ;;
  109. reload)
  110. rh_status_q || exit 7
  111. $1
  112. ;;
  113. force-reload)
  114. force_reload
  115. ;;
  116. status)
  117. rh_status
  118. ;;
  119. condrestart|try-restart)
  120. rh_status_q || exit 0
  121. restart
  122. ;;
  123. *)
  124. echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload|configtest}"
  125. exit 2
  126. esac