libvirtd.init.in 2.7 KB
Newer Older
1 2
#!/bin/sh

3 4 5 6 7
# 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
D
Daniel Veillard 已提交
8 9
# Required-Start: $network messagebus
# Should-Start: $named
10
# Should-Start: xend
D
Daniel Veillard 已提交
11
# Should-Start: hal
12
# Should-Start: avahi-daemon
D
Daniel Veillard 已提交
13 14
# Required-Stop: $network messagebus
# Should-Stop: $named
15 16
# Default-Start: 3 4 5
# Short-Description: daemon for libvirt virtualization API
17
# Description: This is a daemon for managing guest instances
18 19 20 21 22 23
#              and libvirt virtual networks
#              See http://libvirt.org
### END INIT INFO

# the following is chkconfig init header
#
24
# libvirtd:   guest and virtual network management daemon
25 26
#
# chkconfig: 345 97 03
27 28
# description:  This is a daemon for managing guest instances \
#               and libvirt virtual networks \
29 30
#               See http://libvirt.org
#
31 32
# processname: libvirtd
# pidfile: @localstatedir@/run/libvirtd.pid
33 34 35 36 37 38
#

# Source function library.
. @sysconfdir@/rc.d/init.d/functions

SERVICE=libvirtd
39
PROCESS=libvirtd
40
PIDFILE=@localstatedir@/run/$SERVICE.pid
41

42 43
LIBVIRTD_CONFIG=
LIBVIRTD_ARGS=
44
KRB5_KTNAME=/etc/libvirt/krb5.tab
45 46 47

test -f @sysconfdir@/sysconfig/libvirtd && . @sysconfdir@/sysconfig/libvirtd

48 49 50
export QEMU_AUDIO_DRV
export SDL_AUDIODRIVER

51 52 53 54 55
LIBVIRTD_CONFIG_ARGS=
if [ -n "$LIBVIRTD_CONFIG" ]
then
    LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
fi
56 57 58 59 60

RETVAL=0

start() {
    echo -n $"Starting $SERVICE daemon: "
R
Richard W.M. Jones 已提交
61 62
    mkdir -p @localstatedir@/cache/libvirt
    rm -rf @localstatedir@/cache/libvirt/*
63
    KRB5_KTNAME=$KRB5_KTNAME daemon --pidfile $PIDFILE --check $SERVICE $PROCESS --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
64 65 66 67 68 69 70 71
    RETVAL=$?
    echo
    [ $RETVAL -eq 0 ] && touch @localstatedir@/lock/subsys/$SERVICE
}

stop() {
    echo -n $"Stopping $SERVICE daemon: "

72
    killproc -p $PIDFILE $PROCESS
73 74 75 76
    RETVAL=$?
    echo
    if [ $RETVAL -eq 0 ]; then
        rm -f @localstatedir@/lock/subsys/$SERVICE
77
        rm -rf @localstatedir@/cache/libvirt/*
78 79
    else
        exit $RETVAL
80 81 82 83 84 85 86 87 88 89 90
    fi
}

restart() {
    stop
    start
}

reload() {
    echo -n $"Reloading $SERVICE configuration: "

91
    killproc -p $PIDFILE $PROCESS -HUP
92 93 94 95 96 97 98 99 100 101 102
    RETVAL=$?
    echo
    return $RETVAL
}

# See how we were called.
case "$1" in
    start|stop|restart|reload)
        $1
        ;;
    status)
103
        status -p $PIDFILE $PROCESS
104 105
        RETVAL=$?
        ;;
106 107
    force-reload)
        reload
108
        ;;
109
    condrestart|try-restart)
110 111 112
        [ -f @localstatedir@/lock/subsys/$SERVICE ] && restart || :
        ;;
    *)
113
        echo $"Usage: $0 {start|stop|status|restart|condrestart|reload|force-reload|try-restart}"
114
        exit 2
115 116 117
        ;;
esac
exit $RETVAL