您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

snf-server.redhat 2.1KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. #!/bin/bash
  2. #
  3. # SNFServer This shell script takes care of starting and stopping
  4. # the MicroNeil SNFServer daemon for RedHat systems.
  5. #
  6. # Author-- Alban Deniz
  7. #
  8. # Copyright (C) 2008 ARM Research Labs, LLC.
  9. # See www.armresearch.com for the copyright terms.
  10. #
  11. # chkconfig: 345 80 30
  12. # description: SNFServer provides email filtering (anti-spam) services \
  13. # See www.armresearch.com for details.
  14. # processname: SNFServer
  15. # Source function library.
  16. . /etc/rc.d/init.d/functions
  17. # Source networking configuration.
  18. . /etc/sysconfig/network
  19. # Location of programs.
  20. installedDir="PREFIX"
  21. # Location of programs.
  22. dir="$installedDir/sbin"
  23. # Name of config file.
  24. configFile="CONFFILE"
  25. # Name of daemon.
  26. prog="SNFServer"
  27. # Name of client.
  28. clientProg="SNFClient"
  29. # Name of user to run as.
  30. userName="snfilter"
  31. # Name of lockfile.
  32. lockFile="/var/lock/subsys/$prog"
  33. # Start command.
  34. snfStartCmd="$dir/$prog $configFile > /dev/null 2>&1 &"
  35. start(){
  36. SNFPID=$(pidof -s $dir/$prog)
  37. echo -n $"Starting $prog: "
  38. if [ -n "$SNFPID" ] ; then
  39. echo -n $"$prog is already running"
  40. failure
  41. echo
  42. return 1
  43. else
  44. su $userName -c "$snfStartCmd" -s /bin/sh > /dev/null 2>&1
  45. RETVAL=$?
  46. if [ $RETVAL -eq 0 ]; then
  47. $dir/$clientProg -status.second > /dev/null 2>&1
  48. RETVAL=$?
  49. fi
  50. fi
  51. if [ $RETVAL -eq 0 ]; then
  52. touch $lockFile
  53. success
  54. echo
  55. else
  56. failure
  57. echo
  58. fi
  59. return $RETVAL
  60. }
  61. stop(){
  62. echo -n $"Stopping $prog: "
  63. SNFPID=$(pidof -s $dir/$prog)
  64. if [ -n "$SNFPID" ]; then
  65. $dir/$clientProg -shutdown > /dev/null 2>&1
  66. sleep 10
  67. SNFPID=$(pidof -s $dir/$prog)
  68. if [ -n "$SNFPID" ]; then
  69. kill $SNFPID
  70. RETVAL=$?
  71. else
  72. RETVAL=0
  73. fi
  74. else
  75. echo -n $"$prog is not running"
  76. RETVAL=1
  77. failure
  78. echo
  79. fi
  80. if [ $RETVAL -eq 0 ]; then
  81. success
  82. echo
  83. rm -f $lockFile
  84. fi
  85. return $RETVAL
  86. }
  87. restart(){
  88. stop
  89. start
  90. }
  91. # See how we were called.
  92. case "$1" in
  93. start)
  94. start
  95. ;;
  96. stop)
  97. stop
  98. ;;
  99. status)
  100. status $prog
  101. ;;
  102. restart)
  103. restart
  104. ;;
  105. *)
  106. echo $"Usage: $0 {start|stop|status|restart}"
  107. exit 1
  108. esac
  109. exit $?