]> TLD Linux GIT Repositories - packages/libvirt.git/blob - libvirt.init
- release 2
[packages/libvirt.git] / libvirt.init
1 #!/bin/sh
2 # libvirtd:   guest and virtual network management daemon
3 #
4 # chkconfig: 345 97 03
5 # description:  This is a daemon for managing guest instances
6 #               and libvirt virtual networks
7 #               See http://libvirt.org
8 #
9 # processname: libvirtd
10 #
11
12 LIBVIRTD_CONFIG=
13 LIBVIRTD_ARGS=
14
15 LIBVIRTD_CONFIG_ARGS=
16 if [ -n "$LIBVIRTD_CONFIG" ]; then
17         LIBVIRTD_CONFIG_ARGS="--config $LIBVIRTD_CONFIG"
18 fi
19
20 # Source function library.
21 . /etc/rc.d/init.d/functions
22
23 # Source config
24 if [ -f /etc/sysconfig/libvirtd ] ; then
25         . /etc/sysconfig/libvirtd
26 fi
27
28 start() {
29         if [ -f /var/lock/subsys/libvirtd ]; then
30                 msg_already_running "libvirtd"
31                 return
32         fi
33
34         umask 077
35         msg_starting "libvirtd"
36         daemon /usr/sbin/libvirtd --daemon $LIBVIRTD_CONFIG_ARGS $LIBVIRTD_ARGS
37         RETVAL=$?
38         [ $RETVAL -eq 0 ] && touch /var/lock/subsys/libvirtd
39 }
40
41 stop() {
42         if [ ! -f /var/lock/subsys/libvirtd ]; then
43                 msg_not_running "libvirtd"
44                 return
45         fi
46
47         msg_stopping "libvirtd"
48         killproc libvirtd
49         rm -f /var/lock/subsys/libvirtd
50 }
51
52 reload() {
53         if [ ! -f /var/lock/subsys/libvirtd ]; then
54                 msg_not_running "libvirtd"
55                 RETVAL=7
56                 return
57         fi
58
59         msg_reloading libvirtd
60         killproc libvirtd -HUP
61         RETVAL=$?
62 }
63
64 condrestart() {
65         if [ ! -f /var/lock/subsys/libvirtd ]; then
66                 msg_not_running "libvirtd"
67                 RETVAL=$1
68                 return
69         fi
70
71         stop
72         start
73 }
74
75 RETVAL=0
76 case "$1" in
77   start)
78         start
79         ;;
80   stop)
81         stop
82         ;;
83   restart)
84         stop
85         start
86         ;;
87   try-restart)
88         condrestart 0
89         ;;
90   reload|force-reload)
91         reload
92         ;;
93   status)
94         status libvirtd
95         ;;
96   *)
97         msg_usage "$0 {start|stop|restart|try-restart|reload|force-reload|status}"
98         exit 3
99 esac
100
101 exit $RETVAL