Skip to content

Instantly share code, notes, and snippets.

@hourback
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hourback/67491f4e7f3a7fc88092 to your computer and use it in GitHub Desktop.
Save hourback/67491f4e7f3a7fc88092 to your computer and use it in GitHub Desktop.
A SysV init script for nxlog on RHEL 5 box (/etc/init.d/nxlog)
#! /bin/bash
#
# nxlog Start/Stop the nxlog log handler
#
# chkconfig: 2345 90 60
# description: nxlog is an open-source, cross-platform log handler.
# processname: nxlog
# config: /usr/local/etc/nxlog/nxlog.conf
# pidfile: /var/run/nxlog.pid
# Source function library.
. /etc/init.d/functions
RETVAL=0
prog=nxlog
exec=/usr/local/bin/nxlog
# Source config
if [ -f /etc/sysconfig/$prog ] ; then
. /etc/sysconfig/$prog
fi
start() {
[ -x $exec ] || exit 5
echo -n $"Starting nxlog: "
$exec
RETVAL=$?
echo
[ $RETVAL -eq 0 ]
return $RETVAL
}
stop() {
echo -n $"Shutting down nxlog: "
$exec -s
RETVAL=$?
echo
[ $RETVAL -eq 0 ]
return $RETVAL
}
reload() {
RETVAL=1
echo -n "Reloading nxlog..."
$exec -r
RETVAL=$?
if [ $RETVAL -ne 0 ]; then
failure
else
success
fi
echo
return $RETVAL
}
rhstatus() {
/sbin/pidof $prog
RETVAL=$?
echo return $RETVAL
}
restart() {
stop
start
}
case "$1" in
start)
start
;;
stop)
stop
;;
restart)
restart
;;
reload|force-reload)
reload
;;
status)
rhstatus
;;
condrestart|try-restart)
rhstatus >/dev/null 2>&1 || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|restart|condrestart|try-restart|reload|force-reload|status}"
exit 2
esac
exit $?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment