Documentation fixes.
[virt-hostinfo.git] / conf / hostinfo.init.in
1 #!/bin/sh
2 #
3 # hostinfo: Access host information and statistics from virtual machines
4 #
5 # chkconfig:   - 98 02
6 # description: This daemon allows access to host information from guests.
7
8 ### BEGIN INIT INFO
9 # Provides: hostinfo
10 # Required-Start: libvirtd
11 # Required-Stop: libvirtd
12 # Default-Stop: 
13 # Short-Description: Access host information and statistics from virtual machines
14 # Description: This daemon allows access to host information from guests.
15 ### END INIT INFO
16
17 # Source function library.
18 . /etc/rc.d/init.d/functions
19
20 exec="/usr/sbin/hostinfod"
21 prog="hostinfod"
22 config="/etc/hostinfo/hostinfo.conf"
23
24 [ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
25
26 ARGS=
27 if [ -n "$HOSTINFO_VERBOSE" ]; then
28     ARGS="$ARGS -v"
29 fi
30 if [ -n "$HOSTINFO_CONFIG" ]; then
31     ARGS="$ARGS --config $HOSTINFO_CONFIG"
32 fi
33 if [ -n "$HOSTINFO_LIBVIRT_URI" ]; then
34     ARGS="$ARGS --connect $HOSTINFO_LIBVIRT_URI"
35 fi
36
37 lockfile=/var/lock/subsys/$prog
38
39 start() {
40     [ -x $exec ] || exit 5
41     [ -f $config ] || exit 6
42     echo -n $"Starting $prog: "
43     daemon $exec $ARGS
44     retval=$?
45     echo
46     [ $retval -eq 0 ] && touch $lockfile
47     return $retval
48 }
49
50 stop() {
51     echo -n $"Stopping $prog: "
52     killproc $prog
53     retval=$?
54     echo
55     [ $retval -eq 0 ] && rm -f $lockfile
56     return $retval
57 }
58
59 restart() {
60     stop
61     start
62 }
63
64 reload() {
65     restart
66 }
67
68 force_reload() {
69     restart
70 }
71
72 rh_status() {
73     status $prog
74 }
75
76 rh_status_q() {
77     rh_status >/dev/null 2>&1
78 }
79
80
81 case "$1" in
82     start)
83         rh_status_q && exit 0
84         $1
85         ;;
86     stop)
87         rh_status_q || exit 0
88         $1
89         ;;
90     restart)
91         $1
92         ;;
93     reload)
94         rh_status_q || exit 7
95         $1
96         ;;
97     force-reload)
98         force_reload
99         ;;
100     status)
101         rh_status
102         ;;
103     condrestart|try-restart)
104         rh_status_q || exit 0
105         restart
106         ;;
107     *)
108         echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
109         exit 2
110 esac
111 exit $?