2010-01-12 16:13:00 +01:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Copyright (c) 2009 by Thomas Renninger <trenn@suse.de>
|
|
|
|
#
|
|
|
|
# This program is free software; you can redistribute it and/or modify
|
|
|
|
# it under the terms of the GNU General Public License as published by
|
|
|
|
# the Free Software Foundation; either version 2 of the License, or
|
|
|
|
# (at your option) any later version.
|
|
|
|
#
|
|
|
|
# This program is distributed in the hope that it will be useful,
|
|
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
# GNU General Public License for more details.
|
|
|
|
#
|
|
|
|
# You should have received a copy of the GNU General Public License
|
|
|
|
# along with this program; if not, write to the Free Software
|
|
|
|
# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
|
|
#
|
|
|
|
#
|
|
|
|
### BEGIN INIT INFO
|
|
|
|
# Provides: mcelog
|
|
|
|
# Required-Start:
|
|
|
|
# Should-Start: $remote_fs $network $syslog
|
|
|
|
# Required-Stop:
|
|
|
|
# Should-Stop: $remote_fs $network $syslog
|
|
|
|
# Default-Start: 2 3 5
|
|
|
|
# Default-Stop:
|
|
|
|
# Short-Description: Machine Check Architecture/Error (MCA/MCE) implementations
|
|
|
|
# Description: Depending on the configuration, the mcelog service will log
|
|
|
|
# HW initiated Machine Check Excpetions or also react on them intelligently
|
|
|
|
### END INIT INFO
|
|
|
|
|
|
|
|
. /etc/rc.status
|
2010-10-25 15:51:14 +02:00
|
|
|
[ -r /etc/sysconfig/mcelog ] && . /etc/sysconfig/mcelog
|
2010-01-12 16:13:00 +01:00
|
|
|
|
|
|
|
# Shell functions sourced from /etc/rc.status:
|
|
|
|
# rc_check check and set local and overall rc status
|
|
|
|
# rc_status check and set local and overall rc status
|
|
|
|
# rc_status -v ditto but be verbose in local rc status
|
|
|
|
# rc_status -v -r ditto and clear the local rc status
|
|
|
|
# rc_failed set local and overall rc status to failed
|
|
|
|
# rc_reset clear local rc status (overall remains)
|
|
|
|
# rc_exit exit appropriate to overall rc status
|
|
|
|
|
|
|
|
# First reset status of this service
|
|
|
|
rc_reset
|
|
|
|
|
|
|
|
mcelog="/usr/sbin/mcelog"
|
2010-02-23 14:04:03 +01:00
|
|
|
mcelog_pid="/var/run/mcelog.pid"
|
2010-09-16 12:23:45 +02:00
|
|
|
mcelog_params=" --daemon --pidfile ${mcelog_pid}"
|
2010-10-25 15:51:14 +02:00
|
|
|
if [ "${MCELOG_ADMIN_EMAIL}x" != "x" ];then
|
|
|
|
mcelog_params="$mcelog_params --email $MCELOG_ADMIN_EMAIL"
|
|
|
|
fi
|
2010-09-16 12:23:45 +02:00
|
|
|
mcedev=/dev/mcelog
|
2010-01-12 16:13:00 +01:00
|
|
|
|
2010-09-16 12:23:45 +02:00
|
|
|
check="checkproc ${mcelog}"
|
|
|
|
kill="killproc ${mcelog}"
|
|
|
|
start="startproc ${mcelog} ${mcelog_params}"
|
2010-01-12 16:13:00 +01:00
|
|
|
|
|
|
|
test_kernel_support()
|
|
|
|
{
|
|
|
|
if [ ! -c ${mcedev} ];then
|
|
|
|
echo -n "$mcedev not found - no kernel or HW support "
|
|
|
|
return 1
|
|
|
|
else
|
|
|
|
return 0
|
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
case "$1" in
|
|
|
|
start)
|
|
|
|
echo -n "Starting mcelog... "
|
|
|
|
if ! test_kernel_support; then
|
|
|
|
rc_status -u
|
|
|
|
elif ${check};then
|
|
|
|
echo -n "already running"
|
|
|
|
else
|
|
|
|
${start}
|
|
|
|
fi
|
|
|
|
rc_status -v
|
|
|
|
;;
|
|
|
|
stop)
|
|
|
|
echo -n "Shutting down mcelog... "
|
|
|
|
${kill}
|
|
|
|
rc_status -v
|
|
|
|
;;
|
2010-09-16 12:23:45 +02:00
|
|
|
try-restart)
|
|
|
|
## Do a restart only if the service was active before.
|
|
|
|
$0 status
|
|
|
|
if test $? = 0; then
|
|
|
|
$0 restart
|
|
|
|
else
|
|
|
|
rc_reset # Not running is not a failure.
|
|
|
|
fi
|
|
|
|
# Remember status and be quiet
|
|
|
|
rc_status
|
|
|
|
;;
|
2010-01-12 16:13:00 +01:00
|
|
|
reload|restart)
|
|
|
|
/etc/init.d/mcelog stop
|
|
|
|
/etc/init.d/mcelog start
|
|
|
|
;;
|
|
|
|
status)
|
|
|
|
echo -n "Checking for service mcelog... "
|
|
|
|
if ! test_kernel_support; then
|
|
|
|
rc_status -u
|
|
|
|
else
|
|
|
|
${check}
|
|
|
|
rc_status -v
|
|
|
|
fi
|
|
|
|
;;
|
|
|
|
*)
|
|
|
|
echo "Usage: $0 {start|stop|restart|reload|status}"
|
|
|
|
exit 1
|
|
|
|
;;
|
|
|
|
esac
|
|
|
|
|
|
|
|
rc_exit
|