Here is a script that I have used, which reads the "A: drive" files which has 
the IP address, Hostname and other items to edit from the gold image to the 
server information.  I set it up to run once upon the initial boot.  Hope that 
helps.


#!/bin/bash
#
# /etc/init.d/boot.findself
#
### BEGIN INIT INFO
# Provides:          boot.findself
# Required-Start:    boot.localfs
# Required-Start:
# Required-Stop:
# Default-Start:     B
# Default-Stop:
# Description:       upon first boot find/modify IP@ + hostname, gen SSH keys
### END INIT INFO
#
# This script requires two SLES 10 parameter files to exist on the user ID's # 
191 disk: (1) the file S10RWMNT PARM-S10 and (2) $userid PARM-S10 where # 
$userid is the ID of the user that is running the script. It then modifies # 
the IP address, Host name and fully qualified domain name in three # 
configuration files that contain this info. It also regenerates SSH keys.
# The script then turns itself off via "chkconfig" so it only runs once. 
#
# IBM DOES NOT WARRANT OR REPRESENT THAT THE CODE PROVIDED IS COMPLETE # OR 
UP-TO-DATE.  IBM DOES NOT WARRANT,  REPRESENT OR IMPLY RELIABILITY, # 
SERVICEABILITY OR FUNCTION OF THE CODE.  IBM IS UNDER NO OBLIGATION TO # UPDATE 
 CONTENT NOR PROVIDE FURTHER SUPPORT.
# ALL CODE IS PROVIDED "AS IS," WITH NO WARRANTIES OR GUARANTEES WHATSOEVER.
# IBM EXPRESSLY DISCLAIMS TO THE  FULLEST EXTENT PERMITTED BY LAW ALL EXPRESS, 
# IMPLIED,  STATUTORY AND OTHER WARRANTIES, GUARANTEES, OR  REPRESENTATIONS, # 
INCLUDING, WITHOUT LIMITATION, THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR # 
A PARTICULAR  PURPOSE, AND NON-INFRINGEMENT OF PROPRIETARY AND INTELLECTUAL # 
PROPERTY RIGHTS.  YOU UNDERSTAND AND AGREE THAT  YOU USE THESE MATERIALS, # 
INFORMATION, PRODUCTS, SOFTWARE, PROGRAMS, AND SERVICES, AT YOUR OWN # 
DISCRETION AND  RISK AND THAT YOU WILL BE SOLELY RESPONSIBLE FOR ANY DAMAGES # 
THAT MAY RESULT, INCLUDING LOSS OF DATA OR DAMAGE TO YOUR COMPUTER SYSTEM.
# IN NO EVENT WILL IBM BE LIABLE TO ANY PARTY FOR ANY DIRECT, INDIRECT, # 
INCIDENTAL, SPECIAL, EXEMPLARY OR  CONSEQUENTIAL DAMAGES OF ANY TYPE # 
WHATSOEVER RELATED TO OR ARISING FROM USE OF THE CODE FOUND HEREIN, WITHOUT # 
LIMITATION, ANY LOST PROFITS, BUSINESS INTERRUPTION, LOST SAVINGS, LOSS OF # 
PROGRAMS OR OTHER DATA, EVEN IF IBM IS EXPRESSLY ADVISED OF THE POSSIBILITY # 
OF SUCH DAMAGES. THIS EXCLUSION AND WAIVER OF LIABILITY APPLIES TO ALL # CAUSES 
OF ACTION, WHETHER BASED ON CONTRACT, WARRANTY, TORT OR ANY OTHER # LEGAL 
THEORIES.
#
#+--------------------------------------------------------------------------+
function findID()
# Get my VM user ID - don't find self on S10RWMNT, S10RWTST or S10RWGLD 
#+--------------------------------------------------------------------------+
 {
  targetID=$(cat /proc/sysinfo | grep "VM00 Name" | awk '{print $3}')
  if [ $targetID = "S11RWMNT" ] || [ $targetID = "S11RWTST" ] || \
     [ $targetID = "S11ROGLD" ]; then # don't do anything on these three IDs
    exit
  fi
 }

#+--------------------------------------------------------------------------+
function enableAdisk()
# Enable my 191 (A) disk
#+--------------------------------------------------------------------------+
 {
  chccwdev -e 191 > /dev/null 2>&1
  rc=$?
  if [ $rc != 0 ]; then # unable to enable 191 disk
    echo "$0: Unable to enable 191, rc from chccwdev = $rc"
    exit 1
  fi
  sleep 1       # wait a sec to be sure disk is ready
  Adisk=/dev/$(egrep '^0.0.0191' /proc/dasd/devices | awk '{print $7}')  }

#+--------------------------------------------------------------------------+
function findSourceIP()
# Get the source IP address and hostName 
#+--------------------------------------------------------------------------+
 {
  sourceParm="$sourceID.$parmType"
  cmsfslst -d $Adisk | grep $sourceID | grep $parmType > /dev/null
  rc=$?
  if [ $rc != 0 ]; then
    echo "$0: $sourceParm not found on 191 minidisk. Exiting"
    exit 2
  fi
  export local $(cmsfscat -a -d $Adisk $sourceParm)
  # set global variable names escaping any dots (.) in the strings
  sourceName=$(echo "$Hostname" | sed -e 's:\.:\\\.:g')
  sourceHost=${Hostname%%.*}  # Chop domain name off to leave host name
  sourceIP=$(echo "$HostIP" | sed -e 's:\.:\\\.:g')
  sourceOSA=$(echo "$ReadChannel " | sed -e 's:\.:\\\.:g')
  sourceLdapIP=$(echo "$LdapIP" | sed -e 's:\.:\\\.:g')
  sourceLdapHost=$(echo "$LdapHostname" | sed -e 's:\.:\\\.:g')  }

#+--------------------------------------------------------------------------+
function findTargetIP()
# Get my new IP address and hostname
#+--------------------------------------------------------------------------+
 {
  targetParm="$targetID.$parmType"
  cmsfslst -d $Adisk | grep $targetID | grep $parmType > /dev/null
  rc=$?
  if [ $rc != 0 ]; then
    echo "$0: $targetParm not found on 191 minidisk. Exiting"
    exit 3
  fi
  export local $(cmsfscat -a -d $Adisk $targetParm)
  targetName=$Hostname
  targetHost=${Hostname%%.*}  # Chop domain name off to leave host name
  targetIP=$HostIP
  targetLdapIP=$LdapIP
  targetLdapHost=$LdapHostname
 }

#+--------------------------------------------------------------------------+
function modifyIP()
# Modify IP address and host name in /etc/HOSTNAME, /etc/hosts and #  
/etc/sysconfig/network/ifcfg-qeth-bus-ccw-$ReadChannel
#+--------------------------------------------------------------------------+
 {
  # TODO: this function should also modify, DNS, Gateway, broadcast, etc.
  eth0file="/etc/sysconfig/network/ifcfg-eth0"
  ldapfile="/etc/ldap.conf"
  echo ""
  echo "$0: changing (escaped) $sourceName to $targetName in /etc/HOSTNAME"
  sed --in-place -e "s/$sourceName/$targetName/g" /etc/HOSTNAME
  echo "$0: changing $sourceHost to $targetHost and IP address in /etc/hosts"
  sed --in-place -e "s/$sourceHost/$targetHost/g" \
                 -e "s/$sourceIP/$targetIP/g" /etc/hosts
  echo "$0: changing (escaped) $sourceIP to $targetIP in $eth0file"
  sed --in-place -e "s/$sourceIP/$targetIP/g" $eth0file
  echo "$0: changing (escaped) $sourceLdapIP to $targetLdapIP in $ldapfile"
  sed --in-place -e "s/$sourceLdapIP/$targetLdapIP/g" $ldapfile
  echo "$0: changing (escaped) $sourceLdapHost to $targetLdapHost in $ldapfile"
  sed --in-place -e "s/$sourceLdapHost/$targetLdapHost/g" $ldapfile
  hostname $targetHost
 }

#+--------------------------------------------------------------------------+
function genSSHkeys()
# Regenerate a set of SSH keys
#+--------------------------------------------------------------------------+
 {
  rm /etc/ssh/ssh_host_*
  ssh-keygen -t rsa -N "" -q -f /etc/ssh/ssh_host_rsa_key
  ssh-keygen -t dsa -N "" -q -f /etc/ssh/ssh_host_dsa_key
  ssh-keygen -t rsa1 -N "" -q -f /etc/ssh/ssh_host_key  }

# main()
# global variables
sourceID="S11RWMNT"       # VM user ID where first Linux was installed
parmType="PARM-S11"       # File type of parameter file on 191 disk

# function calls
findID
enableAdisk
findSourceIP
findTargetIP
modifyIP
genSSHkeys
chkconfig boot.findself off  # run only once => turn self off


-----Original Message-----
From: Linux on 390 Port [mailto:LINUX-390@VM.MARIST.EDU] On Behalf Of Feller, 
Paul
Sent: Wednesday, July 25, 2018 1:06 PM
To: LINUX-390@VM.MARIST.EDU
Subject: Issue cloning RHEL server

One of my team members is trying to run the cloning process described in "The 
Virtualization Cookbook for z/VM 6.3, RHEL 6.4 and SLES 11 SP3 October 2013, 
January 2014 (SG-248147-00)".  I believe the process has worked in the past.  
But as things go the environment has changed over time.


Here is the question from the team member.

We are still using the cloning process documented in, and scripts provided 
with, "The Virtualization Cookbook for z/VM 6.3, RHEL 6.4 and SLES 11 SP3 
October 2013, January 2014 (SG-248147-00)".  It's been sometime since I last 
used the process to create a new zLinux system and when I try now I'm finding 
that the procedure to update the IP information on the clone copy corrupts one 
or more of the copy's file systems.  I can use DDR to build a bootable system 
from the gold image so I'm fairly sure the dasd copy process is working ok.  
The gold image is not corrupted.  It boots without an error and so does the DDR 
copy.

We're currently running z/VM 6.4 (RSU1801).  The 'LNXADMIN' system is running 
Linux version 2.6.32-504.8.1.el6.s390x (Red Hat 4.4.7-4) and that's what we're 
cloning.  Has anyone experienced this problem and found a work around?


Thanks..

Paul Feller
AGT Mainframe Technical Support




----------------------------------------------------------------------
For LINUX-390 subscribe / signoff / archive access instructions, send email to 
lists...@vm.marist.edu 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 lists...@vm.marist.edu 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