3 # /etc/init.d/xendomains
4 # Start / stop domains automatically when domain 0 boots / shuts down.
7 # description: Start / stop Xen domains.
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)
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/>
18 # Provides: xendomains
19 # Required-Start: $syslog $remote_fs xend
21 # Required-Stop: $syslog $remote_fs xend
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
30 if ! [ -e /proc/xen/privcmd ]; then
39 LOCKFILE=/var/lock/subsys/xendomains
41 if [ -e /lib/lsb ]; then
42 # assume an LSB-compliant distro (Debian with LSB package,
43 # recent-enough SuSE, others...)
45 . /lib/lsb/init-functions # source LSB standard functions
49 if [ $RETVAL -eq 0 ]; then
55 elif [ -r $INITD/functions ]; then
56 # assume a Redhat-like distro
57 . $INITD/functions # source Redhat functions
61 if [ $RETVAL -eq 0 ]; then
71 LOCKFILE=/var/lock/xendomains
82 if [ -f $LOCKFILE ]; then return; fi
84 echo -n $"Starting auto Xen domains:"
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
91 # Create all domains with config files in AUTODIR.
92 for dom in $AUTODIR/*; do
93 xm create --quiet --defconfig $dom
106 # NB. this shuts down ALL Xen domains (politely), not just the ones in
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.
111 echo -n $"Shutting down all Xen domains:"
113 xm shutdown --all --wait --halt
117 [ $RETVAL -eq 0 ] && rm -f $LOCKFILE
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
126 # Commented out to avoid confusion!
134 # same as restart for now - commented out to avoid confusion
150 # The following are commented out to disable them by default to avoid confusion
151 # - see the notes above
166 echo $"Usage: $0 {start|stop|status}"