#!/sbin/runscript # # /etc/init.d/xendomains # Start / stop domains automatically when domain 0 boots / shuts down. # # chkconfig: 345 99 00 # description: Start / stop Xen domains. # # This script offers fairly basic functionality. It should work on Redhat # but also on LSB-compliant SuSE releases and on Debian with the LSB package # installed. (LSB is the Linux Standard Base) # # Based on the example in the "Designing High Quality Integrated Linux # Applications HOWTO" by Avi Alkalay # # depend() { need xend } start() { einfo "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 name=`sed -ne 's/^[ \t]*name[ \t]*=[ \t]*"\([^"]*\)"/\1/p' $dom` ebegin " Starting domain $name " xm create --quiet --defconfig $dom eend $? done fi } stop() { einfo "Shutting down all Xen domains" # Create all domains with config files in AUTODIR. for dom in $AUTODIR/*; do name=`sed -ne 's/^[ \t]*name[ \t]*=[ \t]*"\([^"]*\)"/\1/p' $dom` ebegin " Stopping domain $name " xm shutdown --halt --wait $name eend $? done } status() { xm list }