2007-02-23 15:50:58 +03:00
#!/bin/sh
2007-07-05 20:04:11 +04:00
# the following is the LSB init header see
# http://www.linux-foundation.org/spec//booksets/LSB-Core-generic/LSB-Core-generic.html#INITSCRCOMCONV
#
### BEGIN INIT INFO
# Provides: libvirtd
2009-05-07 11:34:05 +04:00
# Required-Start: $network messagebus
# Should-Start: $named
2007-07-05 20:04:11 +04:00
# Should-Start: xend
2009-05-07 11:34:05 +04:00
# Should-Start: hal
# Should-Start: avahi
# Required-Stop: $network messagebus
# Should-Stop: $named
2007-07-05 20:04:11 +04:00
# Default-Start: 3 4 5
# Short-Description: daemon for libvirt virtualization API
2008-05-15 10:12:32 +04:00
# Description: This is a daemon for managing guest instances
2007-07-05 20:04:11 +04:00
# and libvirt virtual networks
# See http://libvirt.org
### END INIT INFO
# the following is chkconfig init header
#
2008-05-15 10:12:32 +04:00
# libvirtd: guest and virtual network management daemon
2007-02-23 15:50:58 +03:00
#
# chkconfig: 345 97 03
2008-05-15 10:12:32 +04:00
# description: This is a daemon for managing guest instances
2007-02-23 15:50:58 +03:00
# and libvirt virtual networks
# See http://libvirt.org
#
2007-07-05 20:04:11 +04:00
# processname: libvirtd
# pidfile: @localstatedir@/run/libvirtd.pid
2007-02-23 15:50:58 +03:00
#
# Sanity checks.
2007-06-27 03:04:49 +04:00
[ -x @sbindir@/libvirtd ] || exit 0
2007-02-23 15:50:58 +03:00
# Source function library.
. @sysconfdir@/rc.d/init.d/functions
SERVICE=libvirtd
2007-06-27 03:04:49 +04:00
PROCESS=libvirtd
2009-11-12 22:31:48 +03:00
PIDFILE=@localstatedir@/run/$SERVICE.pid
2007-02-23 15:50:58 +03:00
2007-06-27 03:48:46 +04:00
LIBVIRTD_CONFIG=
LIBVIRTD_ARGS=
2007-12-05 18:24:15 +03:00
KRB5_KTNAME=/etc/libvirt/krb5.tab
2007-06-27 03:48:46 +04:00
test -f @sysconfdir@/sysconfig/libvirtd && . @sysconfdir@/sysconfig/libvirtd
LIBVIRTD_CONFIG_ARGS=
if [ -n "$LIBVIRTD_CONFIG" ]
then
LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
fi
2007-02-23 15:50:58 +03:00
RETVAL=0
start() {
echo -n $"Starting $SERVICE daemon: "
2008-06-10 14:43:28 +04:00
mkdir -p @localstatedir@/cache/libvirt
rm -rf @localstatedir@/cache/libvirt/*
2009-11-12 22:31:48 +03:00
KRB5_KTNAME=$KRB5_KTNAME daemon --pidfile $PIDFILE --check $SERVICE $PROCESS --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
2007-02-23 15:50:58 +03:00
RETVAL=$?
echo
[ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$SERVICE
}
stop() {
echo -n $"Stopping $SERVICE daemon: "
2009-11-12 22:31:48 +03:00
killproc -p $PIDFILE $PROCESS
2007-02-23 15:50:58 +03:00
RETVAL=$?
echo
if [ $RETVAL -eq 0 ]; then
rm -f @localstatedir@/lock/subsys/$SERVICE
2009-11-12 22:31:48 +03:00
rm -f $PIDFILE
2008-06-10 14:43:28 +04:00
rm -rf @localstatedir@/cache/libvirt/*
2007-02-23 15:50:58 +03:00
fi
}
restart() {
stop
start
}
reload() {
echo -n $"Reloading $SERVICE configuration: "
2009-11-12 22:31:48 +03:00
killproc -p $PIDFILE $PROCESS -HUP
2007-02-23 15:50:58 +03:00
RETVAL=$?
echo
return $RETVAL
}
# See how we were called.
case "$1" in
start|stop|restart|reload)
$1
;;
status)
2009-11-12 22:31:48 +03:00
status -p $PIDFILE $PROCESS
2007-02-23 15:50:58 +03:00
RETVAL=$?
;;
2007-07-05 20:04:11 +04:00
force-reload)
reload
;;
condrestart|try-restart)
2007-02-23 15:50:58 +03:00
[ -f @localstatedir@/lock/subsys/$SERVICE ] && restart || :
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|reload}"
exit 1
;;
esac
exit $RETVAL