27.12.2012 Views

The Virtualization Cookbook for SLES 10 SP2 - z/VM - IBM

The Virtualization Cookbook for SLES 10 SP2 - z/VM - IBM

The Virtualization Cookbook for SLES 10 SP2 - z/VM - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

echo "Error: unable to load module vmcp, check kernel version"<br />

exit<br />

fi<br />

fi<br />

wait_<strong>for</strong>_device /dev/vmcp<br />

[ $? -ne 0 ] && echo "Error: timed out waiting <strong>for</strong> /dev/vmcp" && exit<br />

}<br />

#+--------------------------------------------------------------------------+<br />

function wait_<strong>for</strong>_device<br />

# Call udevsettle, then if necessary sleep until a certain file exists<br />

# Arg1: <strong>The</strong> path of the file to sleep on.<br />

#+--------------------------------------------------------------------------+<br />

{<br />

device=$1<br />

sync<br />

$UDEVSETTLE<br />

<strong>for</strong> t in $(seq 1 20)<br />

do<br />

[ -e $device ] && return 0<br />

sleep 1<br />

done<br />

return 1<br />

}<br />

#+--------------------------------------------------------------------------+<br />

function autolog<br />

# Issue an XAUTOLOG command to bring up the new cloned image.<br />

#+--------------------------------------------------------------------------+<br />

{<br />

cp_cmd XAUTOLOG $target_linux_id<br />

rc=$?<br />

if [ $? != 0 ]; then<br />

echo "xautolog $target_linux_id failed with $rc"<br />

return 0<br />

fi<br />

echo "Booting $target_linux_id"<br />

}<br />

#+--------------------------------------------------------------------------+<br />

# main()<br />

# Only root can run this script<br />

[ $(id -u) != "0" ] && echo "Error: you must be root" && exit<br />

# Check if the user has defined any clone.sh configurations<br />

[ -f /etc/sysconfig/clone ] && . /etc/sysconfig/clone<br />

# Set defaults <strong>for</strong> clone.sh configurations<br />

[ -z "$PROMPT" ] && PROMPT="y"<br />

[ -z "$CLONE_MNT_PT" ] && CLONE_MNT_PT="/mnt/clone"<br />

# If the clone mount point does not exist then we'll create it <strong>for</strong> you<br />

[ ! -d $CLONE_MNT_PT ] && mkdir -p $CLONE_MNT_PT<br />

# Check if -v was specified on the command line<br />

if [ "$1" = "-v" ] ; then<br />

VERBOSE=1<br />

Appendix B. Source code 261

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!