Cover V04, I04
Article
Figure 1
Figure 2
Listing 1

jul95.tar


Listing 1: The install client script

#! /bin/csh
################################################################################
#
# ic - install client
#
################################################################################
#
# Automates Operating System Configuration
#
# Jack Tuszynski 5/31/94
#
################################################################################
#
################################################################################
# Install Client Instructions
################################################################################
#
# server:
#
# - enter hostname in server's /etc/hosts table
# - enter hostname in server's /etc/netgroup table
# - do a /var/yp/make on server
#
################################################################################
#
# clients:
#
# first ic run ----
#
# - install OS from CD-ROM
# - do the minimum necessary steps to prepare for ic (see clients/doc/prep)
# - reboot (NIS and automount NFS should be running after reboot)
#
# first and subsequent ic runs ----
#
# - ftp ic from server:/usr/local/adm/clients/bin/ic to /tmp
# - chmod 755 ic
# - run ic
# - reboot
#
# first ic run ----
#
# - do the necessary steps after running ic (see clients/doc/post)
#
################################################################################

# set top directory and path
set tdir = /usr/local/adm/clients

# set up the multi-platform prefix path and suffix path
set prefixpath = ( . ~/bin )
set suffixpath = ( /usr/bin/X11 /usr/local/bin )

# unalias rm and mv
unalias rm
unalias mv

################################################################################
# Initialize OS variables switch
################################################################################

switch("`uname -s`")

case 'SunOS':

if ("`uname -r | cut -c1`" == "5") then
# Solaris 2.X

set myarc="sol"
set path=( $prefixpath /bin /sbin \
/usr/bin /usr/ccs/bin /usr/sadm/bin \
/usr/sbin /usr/ucb  /usr/openwin/bin \
$suffixpath )
else
# Solaris 1.X
set myarc="sun"
set path=( $prefixpath /usr/bin /bin /usr/etc \
/usr/ucb /usr/5bin \
/usr/openwin/bin $suffixpath )
endif

set uniqid = `/usr/bin/date +%m_%d_%y_%H%M%S`
breaksw

case 'HP-UX':
set myarc="hp"
set path=($prefixpath /usr/ucb /bin /usr/bin /etc /usr/etc $suffixpath)
set uniqid = `/bin/date +%m_%d_%y_%H%M%S`
breaksw

case 'IRIX':
set myarc="sgi"
set path = ( $prefixpath /usr/etc /etc /usr/sbin /usr/bsd /usr/bin \
/bin $suffixpath )
set uniqid = `/bin/date +%m_%d_%y_%H%M%S`
breaksw

default:

echo "This is not a valid computer that our install client supports"
breaksw

endsw

################################################################################
# bootstrap - make /usr/local/adm available to script
################################################################################

cd /usr
if (-f local) then
rm local >&! /dev/null
endif
if (-d local) then
mv local local.$uniqid
endif

rm /i2
ln -s /stargate/i2 /i2
ln -s /i2/sw /usr/sw
ln -s /usr/sw/local/$myarc /usr/local

################################################################################
# prep configuration
################################################################################

if (-f /etc/sendmail.pid) then
echo "stop sendmail daemon"
kill -15 `head -1 /etc/sendmail.pid`
endif

################################################################################
# main configuration loop
################################################################################

foreach i (`cat $tdir/lib/ic.txt`)
set loc = `echo $i | cut -d":" -f1`
set src = `echo $i | cut -d":" -f2`
set dst = `echo $i | cut -d":" -f3`
set arc = `echo $i | cut -d":" -f4`
set orig = `echo $i | cut -d":" -f5`
set typ = `echo $i | cut -d":" -f6`
set prot = `echo $i | cut -d":" -f7`
set uid = `echo $i | cut -d":" -f8`
set gid = `echo $i | cut -d":" -f9`

if ("`echo $loc | cut -c1`" == "#") then
# comment - print and do not take action
echo "$i"
else
if ("$arc" == "$myarc" || "$arc" == "all") then
cd $loc

# originally (CD-ROM installation) the file being acted
# on was of type, l -link, f - file, or d - directory
switch("$orig")
case 'l':
# link - remove the link
rm $src  >&! /dev/null
breaksw
case 'f':
# file - copy it to a saved version
if (-f $src) then
mv $src $src.$uniqid >&! /dev/null
endif
breaksw
case 'd':
# directory - move it to a saved version
if (-d $src) then
mv $src $src.$uniqid >&! /dev/null
endif
breaksw
default:
breaksw
endsw

# the install client script wants to change the file being
# acted on to one of type, l -link, f - file, or d - directory
switch("$typ")
case 'l':
# link - create the new link
rm $src  >&! /dev/null
echo "ln -s $dst $loc/$src"
ln -s $dst $src
breaksw
case 'f':
# file - copy the file into place and set own,prot
if (-f $src) then
mv $src $src.$uniqid >&! /dev/null
endif
echo "cp $src $loc/$src"
cp $tdir/lib/$myarc/$src .
chown $uid $src
chgrp $gid $src
chmod $prot $src
breaksw
case 'd':
# directory - create a new directory and set own,prot
if (-d $src) then
mv $src $src.$uniqid >&! /dev/null
endif
echo "mkdir $src"
mkdir $src
breaksw
default:
breaksw
endsw
endif
endif

end # main install client configuration loop

################################################################################
# post configuration
################################################################################

switch("`uname -s`")

case 'SunOS':

if ("`uname -r | cut -c1`" == "5") then
# Solaris 2.X


else
# Solaris 1.X
# create and initialize printer log directories
if !(-d /var/spool/mylp) then
echo "making printer spool directories"
/usr/local/adm/printcaps/bin/mklogdirs
endif

echo "creating printcap files"
/usr/local/adm/printcaps/bin/pstart

echo "install openwin"
/usr/local/bin/run_ow /usr/openwin/bin/install_openwin
end

breaksw

case 'HP-UX':

# create device for xcd
if ( -f /dev/rscsi ) then
/etc/mknod /dev/rscsi c  47 0x201200
chmod 777 /dev/rscsi
endif

echo "ic: you still need to set up printers with SAM"

breaksw

case 'IRIX':

# create and initialize printer client
if !(-d /var/spool/mylp) then
echo "making printer spool directories"
/usr/local/adm/printcaps/bin/mklogdirs
endif
echo "creating printcap files"
/usr/local/adm/printcaps/bin/pstart

breaksw

default:

echo "This is not a valid computer that our install clients supports"
breaksw
endsw

################################################################################
# start sendmail daemon - common to all platforms
################################################################################

echo "start sendmail daemon"
/usr/local/bin/startmail

################################################################################
# end install client
################################################################################