Try New Technology

Fixed an auto-create issue with Xen Domains (DomU’s)

by on Jun.06, 2009, under Techie

To get my Xen domains to auto-create with via service I have created my own /etc/init.d/xendomains Run-level Startup script. It will still not auto-create on boot up (after a halt/reboot) but at least I can start the files in /etc/xen/auto/ via “service xendomains start” now. This issue of not auto-creating the Xen domains is not an issue with this script, but rather my server I still need to debug. I did “mv /etc/init.d/xendomains /etc/init.d/xendomains.old.script” to backup the old script for later use, then I created a new /etc/init.d/xendomains file with the following script in it:

Custom xendomains Run-level Startup script:

#!/bin/bash
#
# Run-level Startup script for starting Xen domains
#
# chkconfig: 345 99 00
# Description: Starts and stops Xen domains

# Created to fix Xen auto-start issue on my CentOS 5.3 / Xen 3.0.3 Server
# Created by Logan Rogers-Follis on 06-06-2009

# Depending on parameter — startup, shutdown, restart, reload
# of the instance and listener or usage display

xen_auto=”/etc/xen/auto/”
lock_file=”/var/lock/subsys/xendomains”
sleep_time=40

# If the folder does not exist or is empty — display error

if [ ! -d $xen_auto ]
then
echo “Missing $xen_auto folder: cannot start”
exit 1
elif [ ! “$(ls -A $xen_auto)” ]
then
echo “No files in $xen_auto: cannot start”
exit 1
fi

case “$1” in
start)
# Check for lock_file & Create Xen domains
if [ -f $lock_file ]
then
echo “Xen domains are already running!”
else
echo “Create Xen domains:”
for u in $(ls $xen_auto*)
do
xm create $u
done
touch $lock_file
echo “Xen domains created!”
fi
;;
stop)
# Check for lock_file & Shutdown Xen domains
if [ ! -f $lock_file ]
then
echo “Xen domains are not running!”
else
echo -n “Shutdown Xen domains: ”
cd $xen_auto
for z in $(ls *)
do
xm shutdown $z
done
rm -f $lock_file
echo “OK”
fi
;;
reload|restart)
$0 stop
echo “Sleeping for $sleep_time second while the Xen domains finish their shutdown!”
sleep $sleep_time
$0 start
;;
*)
echo “Usage: $0 start|stop|restart|reload”
exit 1
esac
exit 0


Comments are closed.

Looking for something?

Use the form below to search the site:

Still not finding what you're looking for? Drop a comment on a post or contact us so we can take care of it!