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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

# If there are still command line arguments then the user must have specified DASD<br />

# on the command line. Unset whatever we have in DASD (from the config files) and<br />

# set DASD equal to the rest of the arguments.<br />

[ $# -gt 0 ] && DASD="$@" && unset DASD_ROOT<br />

# Loop through all of the values that we require and double check that they have<br />

# values. If they don't then we will prompt the user to fill them in.<br />

<strong>for</strong> v in HOSTNAME IPADDR DNS GATEWAY NETMASK MTU SUBCHANNELS SEARCHDNS NETTYPE DASD<br />

do<br />

if [ -z "$(eval echo \$$v)" ]; then<br />

[ "$PROMPT" != "y" ] && echo "Error: missing required value <strong>for</strong> $v" && exit 1<br />

[ -z "$first" ] && echo "Please enter $target_linux_id's value <strong>for</strong>: " && first=1<br />

echo -n "$v: "<br />

read in<br />

eval $(echo $v=\"$in\")<br />

export $v<br />

echo "$v=$in" >> /etc/clone/${target_linux_id}.conf<br />

fi<br />

done<br />

# Expand DASD ranges if they have been defined<br />

if [ -n "$DASD" ] ; then<br />

split=$(echo $DASD | tr ',' ' ')<br />

DASD=""<br />

<strong>for</strong> s in $split<br />

do<br />

out=$(echo $s | grep \-)<br />

rc=$?<br />

[ $rc -eq 0 ] && DASD=${DASD}$(seq -s" " $(echo $s | tr '-' ' ' | tr '\n' ' '))<br />

[ $rc -ne 0 ] && DASD=${DASD}$(echo -n "$s ")<br />

done<br />

[ -n "$DASD_ROOT" ] && DASD=$(echo $DASD | sed "s/$DASD_ROOT//")<br />

DASD="$DASD_ROOT $DASD"<br />

# Assuming that if no DASD_ROOT is specified then the first DASD device will be<br />

# take as root<br />

if [ -z "$DASD_ROOT" ] ; then<br />

DASD_ROOT=$(echo $DASD | awk -F" " '{print $1}')<br />

fi<br />

export DASD<br />

fi<br />

# Grab just the hostname with out any DNS suffixes from the FQDN<br />

target_host=$(echo $target_fqhost | awk -F. '{print $1}')<br />

}<br />

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

function dd_copy<br />

# Use the dd command to copy one disk to another<br />

# Arg 1: Source minidisk - assumed to be online<br />

# Arg 2: Target minidisk - must be brought online and dasdfmt'd<br />

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

{<br />

ret_val=0<br />

source_mdisk=$1<br />

target_mdisk=$2<br />

# Bring the source and target devices online<br />

set_online $source_mdisk<br />

254 <strong>The</strong> <strong>Virtualization</strong> <strong>Cookbook</strong> <strong>for</strong> RHEL 6

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

Saved successfully!

Ooh no, something went wrong!