Sophie

Sophie

distrib > Mandriva > 2009.1 > x86_64 > media > main-testing > by-pkgid > e462bed36cad5488cb02e862aa0b69b4 > files > 10

libvirt-utils-0.6.1-4mdv2009.1.x86_64.rpm

#!/bin/sh

# 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
# Required-Start: $network messagebus
# Should-Start: $named
# Should-Start: xend
# Required-Stop: $network messagebus
# Should-Stop: $named
# Default-Start: 3 4 5
# Short-Description: daemon for libvirt virtualization API
# Description: This is a daemon for managing guest instances
#              and libvirt virtual networks
#              See http://libvirt.org
### END INIT INFO

# the following is chkconfig init header
#
# libvirtd:   guest and virtual network management daemon
#
# chkconfig: 345 97 03
# description:  This is a daemon for managing guest instances
#               and libvirt virtual networks
#               See http://libvirt.org
#
# processname: libvirtd
# pidfile: /var/run/libvirtd.pid
#

# Sanity checks.
[ -x /usr/sbin/libvirtd ] || exit 0

# Source function library.
. /etc/rc.d/init.d/functions

SERVICE=libvirtd
PROCESS=libvirtd

LIBVIRTD_CONFIG=
LIBVIRTD_ARGS=
KRB5_KTNAME=/etc/libvirt/krb5.tab

test -f /etc/sysconfig/libvirtd && . /etc/sysconfig/libvirtd

LIBVIRTD_CONFIG_ARGS=
if [ -n "$LIBVIRTD_CONFIG" ]
then
    LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
fi

RETVAL=0

start() {
    gprintf "Starting %s daemon: " "$SERVICE"
    mkdir -p /var/cache/libvirt
    rm -rf /var/cache/libvirt/*
    KRB5_KTNAME=$KRB5_KTNAME daemon --check $SERVICE $PROCESS --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch /var/lock/subsys/$SERVICE
}

stop() {
    gprintf "Stopping %s daemon: " "$SERVICE"

    killproc $PROCESS
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ]; then
        rm -f /var/lock/subsys/$SERVICE
        rm -f /var/run/$SERVICE.pid
	rm -rf /var/cache/libvirt/*
    fi
}

restart() {
    stop
    start
}

reload() {
    gprintf "Reloading %s configuration: " "$SERVICE"

    killproc $PROCESS -HUP
    RETVAL=$?
    echo
    return $RETVAL
}

# See how we were called.
case "$1" in
    start|stop|restart|reload)
        $1
        ;;
    status)
        status $PROCESS
        RETVAL=$?
        ;;
    force-reload)
        reload
	;;
    condrestart|try-restart)
        [ -f /var/lock/subsys/$SERVICE ] && restart || :
        ;;
    *)
        gprintf "Usage: %s {start|stop|status|restart|condrestart|reload}\n" "$0"
	exit 1
        ;;
esac
exit $RETVAL