This appendix provides samples of the user-supplied scripts that are invoked during a Full or Update Installation:
Example B-1
contains a sample
preinstall
script, which sets site-specific attributes in an
install.cdf
file for an Installation Cloning from CD-ROM.
The
preinstall
script is invoked just before the file system creation and software
subset load phases of a Full Installation.
Example B-1: Sample preinstall Script
#!/sbin/sh # # This script takes a generic install.cdf file which has # dummy-variables defined for the attributes "hostname", # "locality", and "timezone", and substitutes real values # for the system being installed. # # This script assumes the name of the generic CDF is # install.cdf.generic. By using this namespace, the # installation process will not find, nor attempt to use # this generic version. The resulting install.cdf file is saved to the # file /var/tmp/install.cdf so that the installation process # will use the modified version. # # The relevant portion of the file install.cdf.generic is: # # install: # _item=Inst_cinstall # kernel_option=mandatory # timeset=yes # password=gyq\Qy7xgNJZqXk # timezone=TIMEZONE # locality=LOCALITY # _action=create # hostname=HOSTNAME # # Set the real values for the dummy variables HOSTNAME=aries LOCALITY=America TIMEZONE=New_York # # Substitute for the dummy variables # sed -e "s/HOSTNAME/$HOSTNAME/" -e "s/LOCALITY/$LOCALITY/" \ -e "s/TIMEZONE/$TIMEZONE/" ./install.cdf.generic > /var/tmp/install.cdf if [ "$?" = "0" ] then # # If the CDF was properly created, display a success # message, and exit with good status. # echo "/var/tmp/install.cdf successfully created" exit 0 else # # The CDF could not be created successfully. # Cause the installation process to stop. # echo " /var/tmp/install.cdf could not be created" exit 1 fi
B.2 Sample update_preinstall File
Example B-2
shows a sample
update_preinstall
script, which is executed just before the initial window is displayed
during the analysis phase of an Update Installation.
Example B-2: Sample update_preinstall File
#!/bin/sh # # This is a sample script that demonstrates # the type of operations that can be performed using # the update_preinstall script. Creating # backup files of any file shipped with the operating # system product is not strictly necessary because any # user customizations are either merged automatically or # saved to a .PreUPD extension. # BACKUP_LIST="/etc/passwd \ /etc/fstab \ /etc/group" for FILE in $BACKUP_LIST do # # Save each file to a .BACKUP extension if the # file exists (-f $FILE) and a backup file does # not already exist (! -f $FILE.BACKUP) # [ -f $FILE -a ! -f $FILE.BACKUP ] && { cp $FILE $FILE.BACKUP } done
Example B-3
contains a sample
postload
script, which sets multiple host-specific attributes in a generic
config.cdf
file to perform configuration cloning of many systems.
The script is identifying each host name and associated IP address because
each system must have a unique identity on the network.
The
postload
script is invoked after the file systems have been created and
software subsets have been loaded during a Full Installation process.
Example B-3: Sample postload Script
#!/usr/bin/posix/sh # # This is a generic postload script that expects # to operate on a generic configuration cdf file named "config.cdf.generic" # also found in the same directory. This script will # query the host name of the system being installed and dynamically # modify the hostname and IP address in the config.cdf.generic file, # and place the file in the /var/tmp directory as config.cdf. The # installation process will then find the resulting CDF file in # /var/tmp. # # The relevant portion of the config.cdf.generic file is: # # # debug=false # devName=tu1 # hasDynamicNetAddr=false # hasRCInfo=true # hopCountMetric=0 # ifaceNum=1 # maxTransUnit=1500 # networkAddress=IPADDRESS # netMask=255.255.252.0 # operational=true # receiveAll=false # receiveMulticast=false # speed=not_applicable # systemName=HOSTNAME # type=ETHERNET # useArp=true # # All other host name and IP address references FOR THE CLIENT BEING # INSTALLED should be replaced by dummy-variables in the file # config.cdf.generic. # MOUNT=/mnt RCMGR=/usr/sbin/rcmgr # # Must use the mount-relative version of ./etc/rc.config, because # file systems are still mounted relative to /mnt. # RC_CONFIG=$MOUNT/etc/rc.config; export RC_CONFIG # # Define a table of hostname to IPaddress to network adapter mapping # aries=0; IP[aries]=16.69.56.100; DEV[aries]=tu0 taurus=1; IP[taurus]=16.69.56.111; DEV[taurus]=tu0 gemini=2; IP[gemini]=16.69.56.222; DEV[gemini]=ln0 cancer=3; IP[cancer]=16.69.56.105; DEV[cancer]=tu0 leo=4; IP[leo]=16.69.56.123; DEV[leo]=tu0 virgo=5; IP[virgo]=16.69.56.75; DEV[virgo]=tu0 libra=6; IP[libra]=16.69.56.50; DEV[libra]=ln0 scorpio=7; IP[scorpio]=16.69.56.55; DEV[scorpio]=tu0 sagittarius=8; IP[sagittarius]=16.69.56.60; DEV[sagittarius]=tu0 capricorn=9; IP[capricorn]=16.69.56.66; DEV[capricorn]=ln0 aquarius=10; IP[aquarius]=16.69.56.70; DEV[aquarius]=tu0 pisces=11; IP[pisces]=16.69.56.77; DEV[pisces]=tu0 GetIPAddress() { eval host=\$$1 echo ${IP[host]} } GetDevName() { eval host=\$$1 echo ${DEV[host]} } Main() { # # Get the host name of the system being installed. Use # the host name to index into a table of IP addresses, and pull # the correct IP address for this system. Then, dynamically # update the host name and IP address in the config.cdf file. # HOSTNAME=`$RCMGR get HOSTNAME` IPADDRESS=`GetIPAddress $HOSTNAME` echo "Host is $HOSTNAME; IP is $IPADDRESS" # # Now modify the version of config.cdf.generic that exists in the # current working directory, and copy it to the /var/tmp # directory so that it is found by the installation process. # sed -e "s/HOSTNAME/$HOSTNAME/g" -e "s/IPADDRESS/$IPADDRESS/g" \ ./config.cdf.generic > /var/tmp/config.cdf [ -s /var/tmp/config.cdf ] && echo "/var/tmp/config.cdf successfully created" # # Always exit with good status; the process is too far # to exit the installation at this point. # exit 0 } Main "$@"
B.4 Sample update_postload File
Example B-4
contains a sample script, which
archives all
*.PreUPD
and
*.PreMRG
files left over from an Update Installation.
This operation is meant as an
example of what can be done during the update process.
It is recommended
that you use the Update Installation Cleanup application (/usr/sbin/updadmin
) to archive these types of files instead of archiving them using
the
update_postload
script.
The
update_postload
script is executed after the operating system software is loaded
but before the first reboot.
Example B-4: Sample update_postload File
#!/bin/ksh # LOGDIR=/var/adm/smlogs BACKUPDIR=/mybackups PREMRG_FILE=$LOGDIR/upd_PreMRG_files PREUPD_FILE=$LOGDIR/upd_custom_files if [ ! -d $BACKUPDIR ] then mkdir -p $BACKUPDIR fi cd / for FILE in `cat $PREMRG_FILE $PREUPD_FILE` do cp $FILE $BACKUPDIR done
Example B-5
contains a sample
postreboot
script which, among other things, loads additional software subsets
from a RIS server, adds entries to the
/etc/fstab
file,
adds users to the
.rhosts
file and allows remote root
logins.
The
postreboot
script is invoked after the system
reboots after a Full Installation.
Example B-5: Sample postreboot File
#!/usr/bin/posix/sh # # This script is executed during the c-install phase of the # full installation process. At the time of execution, all network # services will be available assuming that the system was configured # using the 'sysman -clone' capability. # echo "Executing postreboot script" # # Load reference page software subsets from the # RIS server. # SERVER=`rcmgr get INST_SERVER` 2>&1 /usr/sbin/setld -l $SERVER: OSFMANOS505 OSFCDEMANOS505 \ OSFMANWOS505 OSFCDEMANOP505 OSFMANWOP505 OSFDCMTEXT505 # # Add an entry to the /etc/fstab file to provide an # NFS-mount from an exporting NFS-server # cp /etc/fstab /etc/fstab.ORIG echo "/mnt1@giants /nfs-mount nfs ro,bg 0 0" >> /etc/fstab # # Make a local mount-relative directory on which to mount # the NFS-mounted directory # mkdir -p /nfs-mount # # Add the Engineering team members to the .rhosts file on this system. # cat <> /.rhosts aries.company.com jsmith aries jsmith libra.company.com mwang libra mwang virgo.company.com rhurley virgo rhurley leo.company.com jcruz leo jcruz taurus.company.com gwilliams taurus gwilliams $(hostname) EOF # # Allow root logins from remote systems. # echo ptys >> /etc/securettys # # Use the Korn shell as the default shell for root. # sed "s@/bin/sh@/bin/ksh@" /etc/passwd > /tmp/passwd [[ -s /tmp/passwd ]] && mv /tmp/passwd /etc/passwd chmod 644 /etc/passwd # # Make changes to .profile to change default editor to vi # echo "EDITOR=vi; export EDITOR" >> /.profile # # Additions to sysconfigtab that help our testing. # cp /etc/sysconfigtab /etc/sysconfigtab.ORIG cat <> /etc/sysconfigtab streams: nstrpush=15 advfs: AdvfsPanicLevel=1 proc: maxusers=1024 max-proc-per-user=256 max-threads-per-user=512 vfs: revoke_tty_only=0 kdebug: kdebug_escape = iseeme kdebug_stop_on_panic = 0 EOF exit 0