Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 5th, 2012  |  syntax: None  |  size: 2.23 KB  |  hits: 11  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #!/sbin/runscript
  2. # Copyright 1999-2004 Gentoo Foundation
  3. # Distributed under the terms of the GNU General Public License v2
  4. # $Header: /var/cvsroot/gentoo-x86/app-admin/syslog-ng/files/syslog-ng.rc6-r1,v 1.7 2007/11/04 08:02:28 mr_bones_ Exp $
  5.  
  6. opts="checkconfig reload"
  7.  
  8. depend() {
  9.         # Make networking dependency conditional on configuration
  10.         case $(sed 's/#.*//' /etc/syslog-ng/syslog-ng.conf) in
  11.                 *source*tcp*|*source*udp*|*destination*tcp*|*destination*udp*)
  12.                         need net
  13.                         use stunnel ;;
  14.         esac
  15.  
  16.         # kludge for baselayout-1 compatibility
  17.         [ -z "${svclib}" ] && config /etc/syslog-ng/syslog-ng.conf
  18.         need clock hostname localmount
  19.         provide logger
  20. }
  21.  
  22. checkconfig() {
  23.         if [ ! -e /etc/syslog-ng/syslog-ng.conf ] ; then
  24.                 eerror "You need to create /etc/syslog-ng/syslog-ng.conf first."
  25.                 eerror "An example can be found in /etc/syslog-ng/syslog-ng.conf.sample"
  26.                 return 1
  27.         fi
  28.         syslog-ng -s /etc/syslog-ng/syslog-ng.conf
  29.  
  30.         # the start and reload functions have their own eends so
  31.         # avoid calling this twice when there are no problems
  32.         [ $? -eq 0 ] || eend $? "Configuration error. Please fix your configfile (/etc/syslog-ng/syslog-ng.conf)"
  33. }
  34.  
  35. start() {
  36.         checkconfig || return 1
  37.         ebegin "Starting syslog-ng"
  38.         [ -n "${SYSLOG_NG_OPTS}" ] && SYSLOG_NG_OPTS="-- ${SYSLOG_NG_OPTS}"
  39.         start-stop-daemon --start --quiet --exec /usr/sbin/syslog-ng ${SYSLOG_NG_OPTS}
  40.         eend $? "Failed to start syslog-ng"
  41. }
  42.  
  43. stop() {
  44.         ebegin "Stopping syslog-ng"
  45.         start-stop-daemon --stop --quiet --pidfile /var/run/syslog-ng.pid
  46.         eend $? "Failed to stop syslog-ng"
  47.         sleep 1 # needed for syslog-ng to stop in case we're restarting
  48. }
  49.  
  50. reload() {
  51.         if [ ! -f /var/run/syslog-ng.pid ]; then
  52.                 eerror "syslog-ng isn't running"
  53.                 return 1
  54.         fi
  55.         checkconfig || return 1
  56.         ebegin "Reloading configuration and re-opening log files"
  57.         start-stop-daemon --stop --oknodo --signal HUP \
  58.             --pidfile /var/run/syslog-ng.pid
  59.         eend $?
  60. }