ここでは,フル・インストレーションおよびアップデート・インストレーションの際に起動される,以下のユーザ提供ファイルのサンプルを示します。
preinstall
ファイル (B.1 節)
update_preinstall
ファイル (B.2 節)
postload
ファイル (B.3 節)
update_postload
ファイル (B.4 節)
postreboot
ファイル (B.5 節)
例 B-1
に示すのは,preinstall
スクリプトの例です。
このスクリプトは,CD-ROM からのインストレーション・クローニングのための
install.cdf
ファイルにサイト固有属性を設定します。
preinstall
スクリプトは,フル・インストレーションでファイル・システムが作成されソフトウェア・サブセットがロードされる直前に起動されます。
例 B-1: preinstall スクリプトの例
#!/sbin/sh
#
# This script takes a generic install.cdf file which has
# 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 variables
HOSTNAME=aries
LOCALITY=America
TIMEZONE=New_York
#
# Substitute for the 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
に示すのは,update_preinstall
スクリプトの例です。
このスクリプトは,アップデート・インストレーションの分析フェーズで,初期画面が表示される直前に実行されます。
例 B-2: update_preinstall ファイルの例
#!/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
例 B-3
に示すのは,postload
スクリプトの例です。
このスクリプトは,複数システムの構成クローニングを実行するための複数のホスト固有属性を汎用の
config.cdf
ファイルに設定します。
このスクリプトは,ネットワーク上で各システムを認識するための各ホスト名とその IP アドレスを設定します。
postload
スクリプトは,フル・インストレーションでファイル・システムが作成されソフトウェア・サブセットがロードされた後に起動されます。
例 B-3: postload スクリプトの例
#!/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 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
に示すのは,update_postload
スクリプトの例です。
このスクリプトは,アップデート・インストレーション中に残されたすべての
*.PreUPD
および
*.PreMRG
ファイルをアーカイブします。
この処理は,アップデート処理中に行われることの例の 1 つです。
update_postload
スクリプトを使用する代りに,アップデート・インストレーション・クリーンアップ・アプリケーション (/usr/sbin/updadmin) を使用して,この種のファイルをアーカイブすることをお勧めします。
update_postload
スクリプトは,オペレーティング・システム・ソフトウェアがロードされた後,最初のリブートの前に実行されます。
例 B-4: update_postload ファイルの例
#!/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
例 B-5
に示すのは,postreboot
スクリプトの例です。
このスクリプトは,RIS サーバからの追加のソフトウェア・サブセットのロード,/etc/fstab
ファイルへのエントリ追加,.rhosts
ファイルへのユーザの追加,リモートからの root ログインの許可などを行います。
postreboot
スクリプトは,フル・インストレーションの後のシステム・リブート後に起動されます。
例 B-5: postreboot ファイルの例
#!/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: OSFMANOS540 OSFCDEMANOS540 \
OSFMANWOS540 OSFCDEMANOP540 OSFMANWOP540 OSFDCMTEXT540
#
# 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