Hi people,

We always clone SLES penguins here, so they need to get an identity on
boot. We made this (rather kludgy) script:

--snip--
#!/bin/bash
# script name: configvm.sh
chccwdev -e 191 2>&1 > /dev/null
udevadm settle
DISC=/dev/disk/by-path/ccw-0.0.0191
sleep 1

# Get data from USER.CONFIG
USERID=`vmcp q userid | awk '{print $1}'`
DATA=`cmsfscat -d $DISC -a user.config | grep $USERID`

if ! cmsfscat -d $DISC -a user.config | grep -q $USERID ; then
    # timeout no request, retry
    chccwdev -d 191
    sleep 1

    chccwdev -e 191 2>&1 > /dev/null
    # timeout protection
    udevadm settle
    DISC=/dev/disk/by-path/ccw-0.0.0191
    sleep 1

    # Try again to read USER.CONFIG
    USERID=`vmcp q userid | awk '{print $1}'`
    DATA=`cmsfscat -d $DISC -a user.config | grep $USERID`
fi

IP=`echo $DATA | awk '{print $2}'`
NETMASK=`echo $DATA | awk '{print $3}'`
GW=`echo $DATA | awk '{print $4}'`
HOSTNAME=`echo $DATA | awk '{print $5}'`

if [ "X$HOSTNAME" == "X" ] ; then
    echo "Guest not found on USER CONFIG. Script aborted."
    exit 1
fi

echo "Configuring $USERID"
echo -e "Hostname: $HOSTNAME \nIP: $IP \nNETMASK: $NETMASK \nGateway: $GW"

sed -i /etc/sysconfig/network/ifcfg-eth0 -e "s/^IPADDR=.*/IPADDR='$IP'/" -e
"s/^NETMASK.*/NETMASK='$NETMASK'/"
echo "default $GW - -" > /etc/sysconfig/network/routes
echo $HOSTNAME > /etc/HOSTNAME
echo "OK"

echo -n "Removing SSH host keys: "
rm -f /etc/ssh/*key*
echo "OK"


# reload networking
service network reload

# restart sshd to recreate host keys
service sshd restart

echo "Host configured"

--snip--

Our guests link the disk 500 from maint, and that disk contains the USER
CONFIG file, with this syntax:
GUEST IP NETMASK GATEWAY HOST
LNXSR1 10.100.1.2 255.255.255.0 10.100.1.1 lnxsrv1

Every time we clone a Linux, we just update this file. Upon first IPL, we
get in, run ./configvm.sh and get out. The guest is ready.


Mauro
http://mauro.limeiratem.com - registered Linux User: 294521
Scripture is both history, and a love letter from God.

2015-07-10 12:24 GMT-03:00 Romney White <[email protected]>:

> I believe that a lot of customers have developed their own schemes for
> dynamically configuring Linux guest IP addresses during boot, accommodating
> different environments (such as production, DR, and test). Does anyone have
> such a mechanism that they would be willing to share (scripts,
> configuration file structure, brief description)? New clients would prefer
> to start from something that is known to work rather than inventing their
> own approach from scratch.
>
> If you are willing to share, please get in touch with me off list.
>
> Romney
> ____________________
> Romney White
> Senior Technical Staff Member
> z Systems Architecture and Technology
> 607-785-3873
>
> ----------------------------------------------------------------------
> For LINUX-390 subscribe / signoff / archive access instructions,
> send email to [email protected] with the message: INFO LINUX-390 or
> visit
> http://www.marist.edu/htbin/wlvindex?LINUX-390
> ----------------------------------------------------------------------
> For more information on Linux on System z, visit
> http://wiki.linuxvm.org/
>

----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions,
send email to [email protected] with the message: INFO LINUX-390 or visit
http://www.marist.edu/htbin/wlvindex?LINUX-390
----------------------------------------------------------------------
For more information on Linux on System z, visit
http://wiki.linuxvm.org/

Reply via email to