newsd.sh.in 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211
  1. #!/bin/sh
  2. #
  3. # "$Id: newsd.sh.in 150 2009-04-10 07:52:29Z mike $"
  4. #
  5. # Startup/shutdown script for newsd.
  6. #
  7. # Copyright 2003-2004 Michael Sweet
  8. # Copyright 2002 Greg Ercolano
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public Licensse as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # This program is distributed in the hope that it will be useful,
  16. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. # GNU General Public License for more details.
  19. #
  20. # You should have received a copy of the GNU General Public License
  21. # along with this program; if not, write to the Free Software
  22. # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  23. #
  24. #### OS-Dependent Information
  25. #
  26. # Linux chkconfig stuff:
  27. #
  28. # chkconfig: 235 99 00
  29. # description: Startup/shutdown script for newsd.
  30. #
  31. #
  32. # NetBSD 1.5+ rcorder script lines. The format of the following two
  33. # lines is very strict -- please don't add additional spaces!
  34. #
  35. # PROVIDE: newsd
  36. # REQUIRE: DAEMON
  37. #
  38. #### OS-Dependent Configuration
  39. case "`uname`" in
  40. IRIX*)
  41. IS_ON=/sbin/chkconfig
  42. if $IS_ON verbose; then
  43. ECHO=echo
  44. else
  45. ECHO=:
  46. fi
  47. ECHO_OK=:
  48. ECHO_ERROR=:
  49. ;;
  50. *BSD*)
  51. IS_ON=:
  52. ECHO=echo
  53. ECHO_OK=:
  54. ECHO_ERROR=:
  55. ;;
  56. Darwin*)
  57. . /etc/rc.common
  58. if test "${NEWSD:=-YES-}" = "-NO-"; then
  59. exit 0
  60. fi
  61. IS_ON=:
  62. ECHO=ConsoleMessage
  63. ECHO_OK=:
  64. ECHO_ERROR=:
  65. ;;
  66. Linux*)
  67. IS_ON=/bin/true
  68. if test -f /etc/init.d/functions; then
  69. . /etc/init.d/functions
  70. ECHO=echo
  71. ECHO_OK="echo_success"
  72. ECHO_ERROR="echo_failure"
  73. else
  74. ECHO=echo
  75. ECHO_OK=:
  76. ECHO_ERROR=:
  77. fi
  78. ;;
  79. *)
  80. IS_ON=/bin/true
  81. ECHO=echo
  82. ECHO_OK=:
  83. ECHO_ERROR=:
  84. ;;
  85. esac
  86. #### OS-Independent Stuff
  87. #
  88. # Set the timezone, if possible... This allows the
  89. # server and all child processes to know the local
  90. # timezone when reporting dates and times to the user.
  91. # If no timezone information is found, then Greenwich
  92. # Mean Time (GMT) will probably be used.
  93. #
  94. for file in /etc/TIMEZONE /etc/rc.config /etc/sysconfig/clock; do
  95. if test -f $file; then
  96. . $file
  97. fi
  98. done
  99. if test "x$ZONE" != x; then
  100. TZ="$ZONE"
  101. fi
  102. if test "x$TIMEZONE" != x; then
  103. TZ="$TIMEZONE"
  104. fi
  105. if test "x$TZ" != x; then
  106. export TZ
  107. fi
  108. #
  109. # See if the server (newsd) is running...
  110. #
  111. case "`uname`" in
  112. HP-UX* | AIX* | SINIX*)
  113. pid=`ps -e | awk '{if (match($4, ".*/newsd$") || $4 == "newsd") print $1}'`
  114. ;;
  115. IRIX* | SunOS*)
  116. pid=`ps -e | nawk '{if (match($4, ".*/newsd$") || $4 == "newsd") print $1}'`
  117. ;;
  118. UnixWare*)
  119. pid=`ps -e | awk '{if (match($6, ".*/newsd$") || $6 == "newsd") print $1}'`
  120. . /etc/TIMEZONE
  121. ;;
  122. OSF1*)
  123. pid=`ps -e | awk '{if (match($5, ".*/newsd$") || $5 == "newsd") print $1}'`
  124. ;;
  125. Linux* | *BSD* | Darwin*)
  126. pid=`ps ax | awk '{if (match($5, ".*/newsd$") || $5 == "newsd") print $1}'`
  127. ;;
  128. *)
  129. pid=""
  130. ;;
  131. esac
  132. #
  133. # Start or stop the server based upon the first argument to the script.
  134. #
  135. case $1 in
  136. start | restart | reload)
  137. if $IS_ON newsd; then
  138. if test "$pid" != ""; then
  139. kill $pid
  140. sleep 1
  141. fi
  142. prefix=@prefix@
  143. exec_prefix=@exec_prefix@
  144. @sbindir@/newsd
  145. if test $? != 0; then
  146. $ECHO_FAIL
  147. $ECHO "newsd: unable to $1 NNTP server."
  148. exit 1
  149. fi
  150. $ECHO_OK
  151. $ECHO "newsd: ${1}ed NNTP server."
  152. fi
  153. ;;
  154. stop)
  155. if test "$pid" != ""; then
  156. kill $pid
  157. $ECHO_OK
  158. $ECHO "newsd: stopped NNTP server."
  159. fi
  160. ;;
  161. status)
  162. if test "$pid" != ""; then
  163. echo "newsd: NNTP server is running."
  164. else
  165. echo "newsd: NNTP server is not running."
  166. fi
  167. ;;
  168. *)
  169. echo "Usage: newsd {reload|restart|start|status|stop}"
  170. exit 1
  171. ;;
  172. esac
  173. #
  174. # Exit with no errors.
  175. #
  176. exit 0
  177. #
  178. # End of "$Id: newsd.sh.in 150 2009-04-10 07:52:29Z mike $".
  179. #