]>
Commit | Line | Data |
---|---|---|
2e8b91a6 JR |
1 | #!/bin/sh |
2 | # | |
3 | # xend Script to start and stop the Xen control daemon. | |
4 | # | |
5 | # chkconfig: 2345 98 01 | |
6 | # description: Starts and stops the Xen control daemon. | |
7 | # | |
8 | ### BEGIN INIT INFO | |
9 | # Provides: xend | |
10 | # Required-Start: $syslog $remote_fs xenstored xenconsoled | |
11 | # Should-Start: | |
12 | # Required-Stop: $syslog $remote_fs xenstored xenconsoled | |
13 | # Should-Stop: | |
14 | # Default-Start: 2 3 4 5 | |
15 | # Default-Stop: 0 1 6 | |
16 | # Short-Description: Start/stop xend | |
17 | # Description: Starts and stops the Xen control daemon. | |
18 | ### END INIT INFO | |
19 | ||
20 | waitfordaemon() { | |
21 | i=1 | |
22 | rets=10 | |
23 | /usr/sbin/xend status | |
24 | while [ $? -ne 0 -a $i -lt $rets ]; do | |
25 | sleep 1 | |
26 | i=$(($i + 1)) | |
27 | /usr/sbin/xend status | |
28 | done | |
29 | return $? | |
30 | } | |
31 | ||
32 | start() { | |
33 | if [ -f /var/lock/subsys/xend ]; then | |
34 | msg_already_running "Xen control daemon" | |
35 | return | |
36 | fi | |
37 | if [ ! -f /var/lock/subsys/xenconsoled -o ! -f /var/lock/subsys/xenstored ]; then | |
38 | echo "xenconsoled and xenstored must be started first" | |
39 | return | |
40 | fi | |
41 | show "Starting Xen control daemon" | |
42 | busy | |
43 | /usr/sbin/xend start | |
44 | waitfordaemon | |
45 | RETVAL=$? | |
46 | if [ $RETVAL -eq 0 ]; then | |
47 | touch /var/lock/subsys/xend | |
48 | ok | |
49 | else | |
50 | fail | |
51 | fi | |
52 | } | |
53 | ||
54 | stop() { | |
55 | if [ ! -f /var/lock/subsys/xend ]; then | |
56 | msg_not_running "Xen control daemon" | |
57 | return | |
58 | fi | |
59 | show "Stopping Xen control daemon" | |
60 | busy | |
61 | /usr/sbin/xend stop | |
62 | ok | |
63 | rm -f /var/lock/subsys/xend | |
64 | } | |
65 | ||
66 | reload() { | |
67 | if [ ! -f /var/lock/subsys/xend ]; then | |
68 | msg_not_running "Xen control daemon" | |
69 | return | |
70 | fi | |
71 | show "Reloading Xen control daemon" | |
72 | busy | |
73 | /usr/sbin/xend reload | |
74 | ok | |
75 | } | |
76 | ||
77 | restartp() { | |
78 | if [ ! -f /var/lock/subsys/xend ]; then | |
79 | msg_not_running "Xen control daemon" | |
80 | return | |
81 | fi | |
82 | show "Restarting Xen control daemon" | |
83 | busy | |
84 | /usr/sbin/xend restart | |
85 | waitfordaemon | |
86 | RETVAL=$? | |
87 | if [ $RETVAL -eq 0 ]; then | |
88 | ok | |
89 | else | |
90 | fail | |
91 | fi | |
92 | } | |
93 | ||
94 | RETVAL=0 | |
95 | # See how we were called. | |
96 | case "$1" in | |
97 | start) | |
98 | start | |
99 | ;; | |
100 | stop) | |
101 | stop | |
102 | ;; | |
103 | status) | |
104 | /usr/sbin/xend status | |
105 | ;; | |
106 | reload) | |
107 | reload | |
108 | ;; | |
109 | restart|force-reload) | |
110 | restart | |
111 | ;; | |
112 | *) | |
113 | msg_usage "$0 {start|stop|status|restart|reload|force-reload}" | |
114 | exit 3 | |
115 | esac | |
116 | ||
117 | exit $RETVAL |