[Pacemaker] syslog-ng as resource / how to make sure it gets restarted
Koch, Sebastian
Sebastian.Koch at netzwerk.de
Thu Sep 30 12:27:45 UTC 2010
Hello,
i now edited the syslog-ng Debian Init Script to fit the LSB spec. Now
it should be cluster ready. See the new Script version below. Feedback
is appreciated and I hope it helps somebody.
------------------------------------------------------------------------
------------------------------------------------------------------------
---------
#! /bin/sh
### BEGIN INIT INFO
# Provides: syslog
# Required-Start: $local_fs $network $time $remote_fs
# Required-Stop: $local_fs $network $time $remote_fs
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Starting system logging daemon
# Description: Starting syslog-NG, the next generation
# syslog daemon.
### END INIT INFO#
#
# skeleton example file to build /etc/init.d/ scripts.
# This file should be used to construct scripts for
/etc/init.d.
#
# Written by Miquel van Smoorenburg <miquels at cistron.nl>.
# Modified for Debian GNU/Linux
# by Ian Murdock <imurdock at gnu.ai.mit.edu>.
#
# Version: @(#)skeleton 1.8 03-Mar-1998 miquels at cistron.nl
# This file was customized by SZALAY Attila <sasa at debian.org>
#
# EDIT: This file was editied by Sebastian koch, Fa. NETZWERK GmbH
# to fit the LSB spec in order to be cluster-ready (pacemaker)
#
#we source /etc/default/syslog-ng if exists
[ -r /etc/default/syslog-ng ] && . /etc/default/syslog-ng
# stop syslog-ng before changing its PID file!
PIDFILE="/var/run/syslog-ng.pid"
SYSLOGNG="/usr/sbin/syslog-ng"
NAME="syslog-ng"
PATH=/sbin:/bin:/usr/sbin:/usr/bin
test -f $SYSLOGNG || exit 0
# Define LSB log_* functions.
# Depend on lsb-base (>= 3.0-6) to ensure that this file is present.
. /lib/lsb/init-functions
case "x$CONSOLE_LOG_LEVEL" in
x[1-8])
dmesg -n $CONSOLE_LOG_LEVEL
;;
x)
;;
*)
log_warning_msg "CONSOLE_LOG_LEVEL is of unaccepted value."
;;
esac
if [ -n "$KERNEL_RINGBUF_SIZE" ]
then
log_warning_msg "KERNEL_RINGBUF_SIZE option is useless and therefore
removed."
fi
check_started() {
if [ -f "$PIDFILE" ]; then
pid="$(cat $PIDFILE)"
if [ "$pid" ] && kill -0 $pid >/dev/null; then
return 0 # Is started
fi
fi
return 1 # Isn't started
}
create_xconsole() {
if [ ! -e /dev/xconsole ]
then
mknod -m 640 /dev/xconsole p
fi
}
syslogng_start() {
if ! check_started; then
log_daemon_msg "Starting system logging" "$NAME"
create_xconsole
start-stop-daemon --start --quiet --exec "$SYSLOGNG" \
--pidfile "$PIDFILE" -- -p "$PIDFILE"
RET="$?"
log_end_msg $RET
return $RET
else
log_warning_msg "already running!"
fi
return $ret
}
syslogng_stop() {
if check_started; then
log_daemon_msg "Stopping system logging" "$NAME"
start-stop-daemon --stop --quiet --name "$NAME" --retry 3 \
--pidfile "$PIDFILE"
RET="$?"
log_end_msg $RET
rm -f "$PIDFILE"
return $RET
else
log_warning_msg "isn't running!"
fi
return $ret
}
syslogng_reload() {
log_daemon_msg "Reload system logging" "$NAME"
if $SYSLOGNG -s
then
start-stop-daemon --stop --signal 1 --quiet --exec "$SYSLOGNG" \
--pidfile "$PIDFILE"
RET="$?"
log_end_msg $RET
return $RET
else
log_end_msg 1
return 1
fi
}
DAEMON=$NAME;
syslogng_status()
{
log_action_begin_msg "checking $DAEMON"
if check_started; then
log_action_end_msg 0 "running"
else
if [ -e "$PIDFILE" ]; then
log_action_end_msg 1 "$DAEMON failed"
exit 1
else
log_action_end_msg 0 "not running"
exit 3
fi
fi
}
case "$1" in
start)
syslogng_start || exit 1
;;
stop)
syslogng_stop || exit 1
;;
status)
syslogng_status || exit 1
;;
reload|force-reload)
syslogng_reload || exit 1
;;
restart)
syslogng_stop
syslogng_start || exit 1
;;
*)
echo "Usage: /etc/init.d/$NAME
{start|stop|restart|status|reload|force-reload}" >&2
exit 1
;;
esac
exit 0
------------------------------------------------------------------------
------------------------------------------------------------------------
-------------
Sebastian Koch
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.clusterlabs.org/pipermail/pacemaker/attachments/20100930/5d22fbbc/attachment-0001.html>
More information about the Pacemaker
mailing list