rc.sendmail 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. #!@l_prefix@/lib/rpm/bash @l_prefix@/etc/rc
  2. ##
  3. ## rc.sendmail -- Run-Commands for Sendmail Daemon
  4. ## Copyright (c) 2000-2001 Cable & Wireless Deutschland GmbH
  5. ## Copyright (c) 2000-2001 Ralf S. Engelschall <rse@engelschall.com>
  6. ##
  7. ## Permission to use, copy, modify, and distribute this software for
  8. ## any purpose with or without fee is hereby granted, provided that
  9. ## the above copyright notice and this permission notice appear in all
  10. ## copies.
  11. ##
  12. ## THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
  13. ## WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
  14. ## MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
  15. ## IN NO EVENT SHALL THE AUTHORS AND COPYRIGHT HOLDERS AND THEIR
  16. ## CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  17. ## SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  18. ## LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
  19. ## USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  20. ## ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  21. ## OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
  22. ## OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  23. ## SUCH DAMAGE.
  24. ##
  25. %config
  26. mta_name="sendmail"
  27. mta_aliases_file="@l_prefix@/etc/sendmail/t.aliases"
  28. mta_aliases_update="cd @l_prefix@/etc/sendmail && make t.aliases.db"
  29. sendmail_enable="yes"
  30. sendmail_flags_in="-bd"
  31. sendmail_flags_out="-q60s"
  32. sendmail_flags=""
  33. sendmail_rotate_prolog=""
  34. sendmail_rotate_epilog=""
  35. sendmail_rotate_numfiles="10"
  36. sendmail_rotate_minsize="1M"
  37. sendmail_rotate_complevel="9"
  38. %common
  39. sendmail_start () {
  40. if opServiceEnabled sendmail; then
  41. @l_prefix@/sbin/sendmail $sendmail_flags_in $sendmail_flags \
  42. -OPidFile=@l_prefix@/var/sendmail/sendmail.in.pid
  43. @l_prefix@/sbin/sendmail $sendmail_flags_out $sendmail_flags \
  44. -OPidFile=@l_prefix@/var/sendmail/sendmail.out.pid
  45. fi
  46. }
  47. sendmail_signal () {
  48. if opServiceEnabled sendmail; then
  49. if [ -f @l_prefix@/var/sendmail/sendmail.in.pid ]; then
  50. rpmtool signal -c -d2 \
  51. -p `head -1 @l_prefix@/var/sendmail/sendmail.in.pid` "$@"
  52. fi
  53. if [ -f @l_prefix@/var/sendmail/sendmail.out.pid ]; then
  54. rpmtool signal -c -d2 \
  55. -p `head -1 @l_prefix@/var/sendmail/sendmail.out.pid` "$@"
  56. fi
  57. fi
  58. }
  59. %start -p 200 -u root
  60. sendmail_start
  61. %stop -p 200 -u root
  62. sendmail_signal TERM KILL
  63. %restart -u root
  64. sendmail_signal TERM KILL
  65. sleep 2
  66. sendmail_start
  67. %reload -u root
  68. # sendmail does not like SIGHUP on queue-only processes,
  69. # so we have to perform actually a restart...
  70. sendmail_signal TERM KILL
  71. sleep 2
  72. sendmail_start
  73. %daily -u root
  74. if opServiceEnabled sendmail; then
  75. opTmpDirGen sendmail
  76. opTmpDirFile sendmail hint hintfile
  77. prolog="true"
  78. if [ ".$sendmail_rotate_prolog" != . ]; then
  79. prolog="$prolog; $sendmail_rotate_prolog"
  80. fi
  81. epilog="echo 'epilog' >$hintfile"
  82. if [ ".$sendmail_rotate_epilog" != . ]; then
  83. epilog="$epilog; $sendmail_rotate_epilog"
  84. fi
  85. shtool rotate -f \
  86. -n${sendmail_rotate_numfiles} -s${sendmail_rotate_minsize} \
  87. -d -z${sendmail_rotate_complevel} \
  88. -o@l_fsusr@ -g@l_fsgrp@ -m644 \
  89. -P "$prolog" \
  90. -E "$epilog" \
  91. @l_prefix@/var/sendmail/sendmail.log
  92. if [ ".`cat $hintfile`" = ".epilog" ]; then
  93. sendmail_signal TERM KILL
  94. sleep 2
  95. sendmail_start
  96. fi
  97. opTmpDirDel sendmail
  98. fi