ngircd-redhat.init 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. #!/bin/sh
  2. #
  3. # ngIRCd start and stop script for RedHat based distributions.
  4. # Written by Naoya Nakazawa <naoya.n@gmail.com> for CentOS 5.2, 2009.
  5. #
  6. # chkconfig: 2345 01
  7. # description: ngIRCd is an Open Source server for \
  8. # the Internet Relay Chat (IRC), which \
  9. # is developed and published under \
  10. # the terms of the GNU General Public
  11. # Licence (URL: http://www.gnu.org/licenses/gpl.html). \
  12. # ngIRCd means "next generation IRC daemon", \
  13. # it's written from scratch and not deduced from the \
  14. # "grandfather of IRC daemons", the daemon of the IRCNet.
  15. #
  16. # processname: /usr/sbin/ngircd
  17. # config: /etc/ngircd
  18. # pidfile: /var/run/ngircd.pid
  19. PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
  20. DAEMON=/usr/sbin/ngircd
  21. NAME=ngIRCd
  22. BASENAME=ngircd
  23. CONF=/etc/$BASENAME.conf
  24. DESC="IRC daemon"
  25. PARAMS="-f $CONF"
  26. # Source function library.
  27. . /etc/init.d/functions
  28. # Get config.
  29. test -f /etc/sysconfig/network && . /etc/sysconfig/network
  30. test -f /etc/sysconfig/makuosan && . /etc/sysconfig/makuosan
  31. # Check that networking is up.
  32. [ "${NETWORKING}" = "yes" ] || exit 0
  33. [ -x $DAEMON ] || exit 1
  34. [ -f $CONF ] || exit 2
  35. RETVAL=0
  36. start(){
  37. echo -n $"Starting $NAME: "
  38. daemon $DAEMON $PARAMS
  39. RETVAL=$?
  40. [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$BASENAME
  41. echo
  42. return $RETVAL
  43. }
  44. stop(){
  45. echo -n $"Stopping $NAME: "
  46. killproc $DAEMON
  47. RETVAL=$?
  48. if [ $RETVAL -eq 0 ] ; then
  49. rm -f /var/lock/subsys/$BASENAME
  50. fi
  51. echo
  52. return $RETVAL
  53. }
  54. reload(){
  55. echo -n $"Reloading configuration: "
  56. killproc $DAEMON -HUP
  57. RETVAL=$?
  58. echo
  59. return $RETVAL
  60. }
  61. restart(){
  62. stop
  63. start
  64. }
  65. condrestart(){
  66. [ -e /var/lock/subsys/$BASENAME ] && restart
  67. return 0
  68. }
  69. check_config(){
  70. $DAEMON $PARAMS --configtest >/dev/null 2>&1
  71. [ $? -eq 0 ] && return 0
  72. echo -n $"Configuration of $NAME is not valid, won't (re)start!"
  73. echo -n $"Run \"$DAEMON --configtest\" and fix it up ..."
  74. exit 6
  75. }
  76. # See how we were called.
  77. case "$1" in
  78. start)
  79. check_config
  80. start
  81. ;;
  82. stop)
  83. stop
  84. ;;
  85. status)
  86. status $NAME
  87. ;;
  88. restart)
  89. restart
  90. ;;
  91. reload)
  92. reload
  93. ;;
  94. condrestart)
  95. condrestart
  96. ;;
  97. test)
  98. check_config
  99. ;;
  100. *)
  101. echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|test}"
  102. RETVAL=1
  103. esac
  104. exit $RETVAL