xen/init.xenconsoled
2012-02-01 14:53:08 +04:00

121 lines
2.5 KiB
Bash

#!/bin/bash
#
# xenconsoled Script to start and stop the Xen xenconsoled daemon
#
# Author: Daniel P. Berrange <berrange@redhat.com>
#
# chkconfig: 2345 97 01
# description: Starts and stops the Xen control daemon.
### BEGIN INIT INFO
# Provides: xenconsoled
# Required-Start: $syslog $remote_fs
# Should-Start:
# Required-Stop: $syslog $remote_fs
# Should-Stop:
# Default-Start: 3 4 5
# Default-Stop: 0 1 2 6
# Default-Enabled: yes
# Short-Description: Start/stop xenconsoled
# Description: Starts and stops the Xen xenconsoled daemon.
### END INIT INFO
# Source function library.
. /etc/rc.d/init.d/functions
if [ ! -d /proc/xen ]; then
exit 0
fi
if ! grep -q "control_d" /proc/xen/capabilities ; then
exit 0
fi
# Default config params
XENCONSOLED_LOG_HYPERVISOR=no
XENCONSOLED_LOG_GUESTS=no
XENCONSOLED_LOG_DIR=/var/log/xen/console
XENCONSOLED_ARGS=
# User customized params
test -f /etc/sysconfig/xenconsoled && . /etc/sysconfig/xenconsoled
XENCONSOLED_LOG=none
if [ "$XENCONSOLED_LOG_HYPERVISOR" = "yes" ]
then
if [ "$XENCONSOLED_LOG_GUESTS" = "yes" ]
then
XENCONSOLED_LOG=all
else
XENCONSOLED_LOG=hv
fi
else
if [ "$XENCONSOLED_LOG_GUESTS" = "yes" ]
then
XENCONSOLED_LOG=guest
fi
fi
start() {
echo -n $"Starting xenconsoled daemon: "
/usr/sbin/xenconsoled --log=$XENCONSOLED_LOG --log-dir=$XENCONSOLED_LOG_DIR $XENCONSOLED_ARGS
RETVAL=$?
test $RETVAL = 0 && echo_success || echo_failure
echo
[ $RETVAL -eq 0 ] && touch /var/lock/subsys/xenconsoled
}
stop() {
echo -n $"Stopping xenconsoled daemon: "
killproc xenconsoled > /dev/null
RETVAL=$?
test $RETVAL = 0 && echo_success || echo_failure
echo
[ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/xenconsoled
}
rcstatus() {
status xenconsoled
RETVAL=$?
test $RETVAL = 0 && echo_success || echo_failure
echo
}
reload() {
echo -n $"Reloading xenconsoled daemon: "
killproc xenconsoled -HUP > /dev/null
RETVAL=$?
test $RETVAL = 0 && echo_success || echo_failure
echo
}
RETVAL=0
case "$1" in
start)
start
;;
stop)
stop
;;
status)
rcstatus
;;
reload)
reload
;;
restart|force-reload)
stop
start
;;
condrestart)
if [ -f /var/lock/subsys/xenconsoled ]
then
stop
start
fi
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload}"
exit 1
esac
exit $RETVAL