libvirtd.init.in 2.6 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 48 49 50 51 52

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

LIBVIRTD_CONFIG_ARGS=
if [ -n "$LIBVIRTD_CONFIG" ]
then
    LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
fi
53 54 55 56 57

RETVAL=0

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

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

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

restart() {
    stop
    start
}

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

87
    killproc -p $PIDFILE $PROCESS -HUP
88 89 90 91 92 93 94 95 96 97 98
    RETVAL=$?
    echo
    return $RETVAL
}

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