]> git.pld-linux.org Git - packages/xen.git/blame - xen-xendomains.init
- pl for -devel,-static; fixed -devel desc (what documentation?)
[packages/xen.git] / xen-xendomains.init
CommitLineData
ce2a536c
AM
1#!/bin/sh
2#
3# /etc/init.d/xendomains
4# Start / stop domains automatically when domain 0 boots / shuts down.
5#
6# chkconfig: 345 99 00
7# description: Start / stop Xen domains.
8#
9# This script offers fairly basic functionality. It should work on Redhat
10# but also on LSB-compliant SuSE releases and on Debian with the LSB package
11# installed. (LSB is the Linux Standard Base)
12#
13# Based on the example in the "Designing High Quality Integrated Linux
14# Applications HOWTO" by Avi Alkalay
15# <http://www.tldp.org/HOWTO/HighQuality-Apps-HOWTO/>
16#
17### BEGIN INIT INFO
18# Provides: xendomains
19# Required-Start: $syslog $remote_fs xend
20# Should-Start:
21# Required-Stop: $syslog $remote_fs xend
22# Should-Stop:
23# Default-Start: 3 4 5
24# Default-Stop: 0 1 2 6
25# Short-Description: Start/stop secondary xen domains
26# Description: Start / stop domains automatically when domain 0
27# boots / shuts down.
28### END INIT INFO
29
30if ! [ -e /proc/xen/privcmd ]; then
31 exit 0
32fi
33
34RETVAL=0
35
36INITD=/etc/init.d
37
38AUTODIR=/etc/xen/auto
39LOCKFILE=/var/lock/subsys/xendomains
40
41if [ -e /lib/lsb ]; then
42 # assume an LSB-compliant distro (Debian with LSB package,
43 # recent-enough SuSE, others...)
44
45 . /lib/lsb/init-functions # source LSB standard functions
46
47 on_fn_exit()
48 {
49 if [ $RETVAL -eq 0 ]; then
50 log_success_msg
51 else
52 log_failure_msg
53 fi
54 }
55elif [ -r $INITD/functions ]; then
56 # assume a Redhat-like distro
57 . $INITD/functions # source Redhat functions
58
59 on_fn_exit()
60 {
61 if [ $RETVAL -eq 0 ]; then
62 success
63 else
64 failure
65 fi
66
67 echo
68 }
69else
70 # none of the above
71 LOCKFILE=/var/lock/xendomains
72
73 on_fn_exit()
74 {
75 echo
76 }
77fi
78
79
80
81start() {
82 if [ -f $LOCKFILE ]; then return; fi
83
84 echo -n $"Starting auto Xen domains:"
85
86 # We expect config scripts for auto starting domains to be in
87 # AUTODIR - they could just be symlinks to files elsewhere
88 if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then
89 touch $LOCKFILE
90
91 # Create all domains with config files in AUTODIR.
92 for dom in $AUTODIR/*; do
93 xm create --quiet --defconfig $dom
94 if [ $? -ne 0 ]; then
95 RETVAL=$?
96 fi
97 done
98
99 fi
100
101 on_fn_exit
102}
103
104stop()
105{
106 # NB. this shuts down ALL Xen domains (politely), not just the ones in
107 # AUTODIR/*
108 # This is because it's easier to do ;-) but arguably if this script is run
109 # on system shutdown then it's also the right thing to do.
110
111 echo -n $"Shutting down all Xen domains:"
112
113 xm shutdown --all --wait --halt
114
115 RETVAL=$?
116
117 [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
118
119 on_fn_exit
120}
121
122# This does NOT necessarily restart all running domains: instead it
123# stops all running domains and then boots all the domains specified in
124# AUTODIR. If other domains have been started manually then they will
125# not get restarted.
126# Commented out to avoid confusion!
127#
128#restart()
129#{
130# stop
131# start
132#}
133
134# same as restart for now - commented out to avoid confusion
135#reload()
136#{
137# restart
138#}
139
140
141case "$1" in
142 start)
143 start
144 ;;
145
146 stop)
147 stop
148 ;;
149
150# The following are commented out to disable them by default to avoid confusion
151# - see the notes above
152#
153# restart)
154# restart
155# ;;
156#
157# reload)
158# reload
159# ;;
160
161 status)
162 xm list
163 ;;
164
165 *)
166 echo $"Usage: $0 {start|stop|status}"
167 ;;
168esac
169
170exit $RETVAL
This page took 0.063511 seconds and 4 git commands to generate.