Advertisement
diabliyo

dkfilter init

Apr 4th, 2011
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.02 KB | None | 0 0
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2005-2006 Messiah College.
  4. #
  5. ### BEGIN INIT INFO
  6. # Default-Start: 3 4 5
  7. # Default-Stop: 0 1 2 6
  8. # Description: Runs dkfilter
  9. ### END INIT INFO
  10.  
  11. DKFILTERUSER=dkfilter
  12. DKFILTERGROUP=dkfilter
  13. DKFILTERDIR=/usr/local/dkfilter
  14.  
  15. HOSTNAME=`hostname -f`
  16. DOMAIN=`hostname -d`
  17. DKFILTER_IN_ARGS="
  18. --hostname=$HOSTNAME
  19. 127.0.0.1:10025 127.0.0.1:10026"
  20. DKFILTER_OUT_ARGS="
  21. --keyfile=$DKFILTERDIR/default.key.priv
  22. --selector=default
  23. --domain=$DOMAIN
  24. --method=nofws
  25. --headers
  26. 127.0.0.1:10027 127.0.0.1:10028"
  27.  
  28. DKFILTER_COMMON_ARGS="
  29. --user=$DKFILTERUSER
  30. --group=$DKFILTERGROUP
  31. --daemonize"
  32.  
  33. DKFILTER_IN_BIN="$DKFILTERDIR/bin/dkfilter.in"
  34. DKFILTER_OUT_BIN="$DKFILTERDIR/bin/dkfilter.out"
  35.  
  36. PIDDIR=$DKFILTERDIR/var/run
  37. DKFILTER_IN_PID=$PIDDIR/dkfilter_in.pid
  38. DKFILTER_OUT_PID=$PIDDIR/dkfilter_out.pid
  39.  
  40. case "$1" in
  41. start-in)
  42. echo -n "Starting inbound DomainKeys-filter (dkfilter.in)..."
  43.  
  44. # create directory for pid files if necessary
  45. test -d $PIDDIR || mkdir -p $PIDDIR || exit 1
  46.  
  47. # start the filter
  48. $DKFILTER_IN_BIN $DKFILTER_COMMON_ARGS --pidfile=$DKFILTER_IN_PID $DKFILTER_IN_ARGS
  49. RETVAL=$?
  50. if [ $RETVAL -eq 0 ]; then
  51. echo done.
  52. else
  53. echo failed.
  54. exit $RETVAL
  55. fi
  56. ;;
  57.  
  58. start-out)
  59. echo -n "Starting outbound DomainKeys-filter (dkfilter.out)..."
  60.  
  61. # create directory for pid files if necessary
  62. test -d $PIDDIR || mkdir -p $PIDDIR || exit 1
  63.  
  64. # start the filter
  65. $DKFILTER_OUT_BIN $DKFILTER_COMMON_ARGS --pidfile=$DKFILTER_OUT_PID $DKFILTER_OUT_ARGS
  66. RETVAL=$?
  67. if [ $RETVAL -eq 0 ]; then
  68. echo done.
  69. else
  70. echo failed.
  71. exit $RETVAL
  72. fi
  73. ;;
  74.  
  75. stop-in)
  76. echo -n "Shutting down inbound DomainKeys-filter (dkfilter.in)..."
  77. if [ -f $DKFILTER_IN_PID ]; then
  78. kill `cat $DKFILTER_IN_PID` && rm -f $DKFILTER_IN_PID
  79. RETVAL=$?
  80. [ $RETVAL -eq 0 ] && echo done. || echo failed.
  81. exit $RETVAL
  82. else
  83. echo not running.
  84. fi
  85. ;;
  86. stop-out)
  87. echo -n "Shutting down outbound DomainKeys-filter (dkfilter.out)..."
  88. if [ -f $DKFILTER_OUT_PID ]; then
  89. kill `cat $DKFILTER_OUT_PID` && rm -f $DKFILTER_OUT_PID
  90. RETVAL=$?
  91. [ $RETVAL -eq 0 ] && echo done. || echo failed.
  92. exit $RETVAL
  93. else
  94. echo not running.
  95. fi
  96. ;;
  97. start)
  98. $0 start-in && $0 start-out || exit $?
  99. ;;
  100. stop)
  101. $0 stop-in && $0 stop-out || exit $?
  102. ;;
  103. restart)
  104. $0 stop && $0 start || exit $?
  105. ;;
  106. status)
  107. echo -n "dkfilter.in..."
  108. if [ -f $DKFILTER_IN_PID ]; then
  109. pid=`cat $DKFILTER_IN_PID`
  110. if ps -ef |grep -v grep |grep -q "$pid"; then
  111. echo " running (pid=$pid)"
  112. else
  113. echo " stopped (pid=$pid not found)"
  114. fi
  115. else
  116. echo " stopped"
  117. fi
  118. echo -n "dkfilter.out..."
  119. if [ -f $DKFILTER_OUT_PID ]; then
  120. pid=`cat $DKFILTER_OUT_PID`
  121. if ps -ef |grep -v grep |grep -q "$pid"; then
  122. echo " running (pid=$pid)"
  123. else
  124. echo " stopped (pid=$pid not found)"
  125. fi
  126. else
  127. echo " stopped"
  128. fi
  129. ;;
  130. *)
  131. echo "Usage: $0 {start|stop|restart|status}"
  132. exit 1
  133. ;;
  134. esac
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement