home *** CD-ROM | disk | FTP | other *** search
Korn shell script | 1996-06-13 | 4.3 KB | 198 lines |
- #!/bin/ksh
- #
- # Installation procedure for Hewlett Packard Workstations
- # procedure name : HPSETUP
-
- # Handles answer to interactive question
- yesno()
- {
- msg="$1"
- def="$2"
- while true ; do
- echo " "
- echo "$msg\c"
- read answer
- if [ "$answer" ] ; then
- case "$answer" in
- y|Y|yes|YES)
- return 0
- ;;
- n|N|no|NO)
- return 1
- ;;
- *)
- echo " "
- echo "ERROR: Invalid response, expected \"yes\" or \"no\"."
- continue
- ;;
- esac
- else
- return $def
- fi
- done
- }
-
- function main
- # Initial controls
- {
-
- # Check if user is root
- if [ $LOGNAME != root ]
- then
- print '\n Must login as root !\n '
- exit
- else
- continue
- fi
-
- # Check if user is in the right CD directory
- if [ -d $PWD/STONLINE ] && [ -d $PWD/INSTALL ] && [ -r $PWD/HPSETUP* ]
- then
- stonlineroot="$PWD/STONLINE"
- cdmountpoint="$PWD"
- continue
- else
- print ' \n Please change directory on /your_cdrom_mount_point \n'
- exit
- fi
-
- # Questions for installation directory
- if [ "`type uname`" != "uname not found" ] ; then
- OSrelease=`uname -r`
- else
- OSrelease=unknown
- fi
-
- case "$OSrelease" in
- *.09.*) defdir="/usr/dataondisc" ;;
- *.10.*) defdir="/opt/dataondisc" ;;
- *) defdir="/opt/dataondisc" ;;
- esac
-
- if [ -z "$installdir" ] ; then
- installdir="$defdir"
- fi
-
- echo "\n Enter installation directory for DATA on DISC [${installdir}] \c"
- read answer
-
- case "$answer" in
- "")
- ;;
- /stonline)
- echo "\n Please choose a different installation directory \n "
- exit 1
- ;;
- *)
- installdir="$answer"
- ;;
- esac
-
- if [ ! -d "$installdir" ]
- then
- echo ""
- if yesno "Directory \"$installdir\" does not exist create it now? [y] \c " 0
- then
- mkdir -p "$installdir"
- else
- echo "\n Installation aborted \n"
- exit 1
- fi
-
- if [ ! -d "$installdir" ]
- then
- echo " "
- echo "ERROR: Cannot make directory \"$installdir\"."
- installdir=""
- exit 1
- fi
-
- else
- echo " "
- echo " Directory \"$installdir\" exists, please rename or delete it"
- print ' and rerun this procedure \n '
- exit
- fi
-
- # Links to CD content: check if preexisting dir
-
- if [ -r /stonline ]
- then
- print '\n Directory /stonline exists, please rename or delete it'
- print ' and rerun this procedure \n '
- exit
- else
- mkdir /stonline
- fi
-
- echo "\n starting local structure creation --- wait \n"
- echo "Creating local structure"
- find $stonlineroot -type d -exec $setupdir/HPSETUP* makedir {} $installdir \;
- mkdir $installdir/SUN_HP
- echo "Creating local links --- takes a while "
- find $cdmountpoint/INSTALL/SUN_HP -type f -exec $setupdir/HPSETUP* linkfileinstall {} $installdir/SUN_HP \;
- find $stonlineroot -type f -exec $setupdir/HPSETUP* linkfile {} $installdir \;
- ln -s $installdir/stonline/* /stonline
-
- # Show Acrobat Reader installation guide
- echo ""
- if yesno "Do you want to read the Acrobat Search installation guide ? [y] " 0
- then
- more $installdir/SUN_HP/INSTGUID.TXT*
- else
- continue
- fi
-
- # Run Acrobat Reader installation script
- $installdir/SUN_HP/INSTALL*
- rm -r $installdir/SUN_HP
- print '\n End procedure \n'
-
- exit
- }
-
- # Creates local directory structure
- function makedir
- {
- cddir="$1"
- installdir="$2"
- hddir=/stonline`echo $cddir | awk -F'STONLINE' '{print $2}'`
- mkdir $installdir$hddir 2>/dev/null
- }
-
- # Creates soft link on local directory structure pointing to CD files
- function linkfileinstall
- {
- cdfile="$1"
- installdir="$2"
- HDFILE=`basename $cdfile |cut -d ';' -f 1`
- ln -s $cdfile $installdir/$HDFILE
- echo ".\c"
- }
-
- # Creates soft link on local directory structure pointing to CD files
- function linkfile
- {
- cdfile="$1"
- installdir="$2"
- tmp=/stonline`echo $cdfile | awk -F'STONLINE' '{print $2}'`
- hdfile=`echo $tmp|cut -d ';' -f 1`
- ln -s $cdfile $installdir$hdfile
- echo ".\c"
- }
-
- # Common: recursive call for local directory structure and soft link to CD files creation
- setupdir="$PWD"
- action="$1"
- param1="$2"
- param2="$3"
- trap "echo '\n Forced exit \n'; exit 1" 1 2 3
- typeset -l hddir hdfile tmp
- typeset -u HDFILE
- case $action in
- makedir ) makedir "$param1" "$param2" ;;
- linkfile ) linkfile "$param1" "$param2" ;;
- linkfileinstall ) linkfileinstall "$param1" "$param2" ;;
- * ) main ;;
- esac
-