#!/sbin/runscripts # Copyright 1999-2004 Gentoo Foundation # Distributed under the terms of the GNU General Public License, v2 # $Header: $ # Adopted from packaged init.d script for Gentoo # # /etc/init.d/xendomains # Start / stop domains automatically when domain 0 boots / shuts down. # # chkconfig: 345 99 00 # description: Start / stop Xen domains. # AUTODIR=/etc/xen/auto LOCKFILE=/var/lock/subsys/xendomains depend() { use xend } start() { if [ -f $LOCKFILE ]; then return; fi ebegin "Starting auto Xen domains" # We expect config scripts for auto starting domains to be in # AUTODIR - they could just be symlinks to files elsewhere if [ -d $AUTODIR ] && [ $(ls $AUTODIR | wc -l) -gt 0 ]; then touch $LOCKFILE # Create all domains with config files in AUTODIR. for dom in $AUTODIR/*; do xm create --quiet --defconfig $dom if [ $? -ne 0 ]; then RETVAL=$? fi done fi eend $? } stop() { # NB. this shuts down ALL Xen domains (politely), not just the ones in # AUTODIR/* # This is because it's easier to do ;-) but arguably if this script is run # on system shutdown then it's also the right thing to do. ebegin "Shutting down all Xen domains" xm shutdown --all --wait --halt RETVAL=$? [ $RETVAL -eq 0 ] && rm -f $LOCKFILE eend $? } # This does NOT necessarily restart all running domains: instead it # stops all running domains and then boots all the domains specified in # AUTODIR. If other domains have been started manually then they will # not get restarted. # Commented out to avoid confusion! # #restart() #{ # stop # start #} # same as restart for now - commented out to avoid confusion #reload() #{ # restart #} status() { xm list ;; }