Magellan Linux

Contents of /trunk/xen-tools/xend.rc

Parent Directory Parent Directory | Revision Log Revision Log


Revision 615 - (show annotations) (download)
Sat May 24 10:32:18 2008 UTC (16 years, 5 months ago) by niro
File size: 1343 byte(s)
-initscript files for xen-tools packages

1 #!/bin/bash
2 # $Header: /root/magellan-cvs/src/xen-tools/xend.rc,v 1.1 2008-05-24 10:32:18 niro Exp $
3
4 #%rlevels: 3:s 4:s 5:s 0:k 1:k 2:k 6:k
5 #%start: 60
6 #%stop: 30
7
8 #deps
9 #%needs:
10 #%before:
11 #%after:
12
13 source /etc/sysconfig/rc
14 source $rc_functions
15
16 is_privileged_domain()
17 {
18 grep -qsE '^control_d$' /proc/xen/capabilities
19 return $?
20 }
21
22 await_daemons_up()
23 {
24 for ((i=0; i<5; i++))
25 do
26 sleep 1
27 /usr/sbin/xend status && return 0
28 done
29 return 1
30 }
31
32 case "$1" in
33 start)
34 if is_privileged_domain
35 then
36 echo -e ${COLOREDSTAR}"Starting Xen control daemon ..."
37 /usr/sbin/xend start
38 /usr/sbin/xend status || await_daemons_up
39 evaluate_retval
40 else
41 ${WARNING} "Can't start xend - this is not a privileged domain ..."
42 print_status failure
43 fi
44
45 update_svcstatus $1
46 splash svc_started "$(basename $0)" 0
47 ;;
48
49 stop)
50 if [ "$(xm list | wc -l)" -gt 2 ]
51 then
52 echo -e ${COLOREDSTAR}"Stopping all domains ..."
53 /usr/sbin/xm shutdown --all --wait >/dev/null
54 evaluate_retval
55 fi
56
57 echo -e ${COLOREDSTAR}"Stopping Xen control daemon"
58 /usr/sbin/xend stop
59 evaluate_retval
60
61 update_svcstatus $1
62 splash svc_stopped "$(basename $0)" 0
63 ;;
64
65 restart)
66 $0 stop
67 sleep 1
68 $0 start
69 ;;
70
71 status)
72 is_privileged_domain && /usr/sbin/xend status
73 ;;
74
75 *)
76 echo "Usage: $0 {start|stop|restart|status}"
77 exit 1
78 ;;
79 esac