home *** CD-ROM | disk | FTP | other *** search
/ Data on Disc 1997 (1st Edition) / stdatalib.iso / hpsetup next >
Encoding:
Korn shell script  |  1996-06-13  |  4.3 KB  |  198 lines

  1. #!/bin/ksh
  2. #
  3. # Installation procedure for Hewlett Packard Workstations
  4. # procedure name : HPSETUP
  5.  
  6. # Handles answer to interactive question
  7. yesno()
  8. {
  9.   msg="$1"
  10.   def="$2"
  11.   while true ; do
  12.     echo " "
  13.     echo "$msg\c"
  14.     read answer
  15.     if [ "$answer" ] ; then
  16.       case "$answer" in
  17.         y|Y|yes|YES)
  18.           return 0
  19.           ;;
  20.         n|N|no|NO)
  21.           return 1
  22.           ;;
  23.         *)
  24.           echo " "
  25.           echo "ERROR: Invalid response, expected \"yes\" or \"no\"."
  26.           continue
  27.           ;;
  28.       esac
  29.     else
  30.       return $def
  31.     fi
  32.   done
  33. }
  34.  
  35. function main
  36. # Initial controls
  37. {
  38.  
  39. # Check if user is root
  40. if [ $LOGNAME != root ]
  41. then
  42.         print '\n Must login as root !\n '
  43.         exit
  44. else
  45.         continue
  46. fi
  47.  
  48. # Check if user is  in the right CD directory
  49. if [ -d $PWD/STONLINE ] && [ -d $PWD/INSTALL ]  && [ -r $PWD/HPSETUP* ]
  50. then
  51.         stonlineroot="$PWD/STONLINE"
  52.         cdmountpoint="$PWD"
  53.         continue
  54. else
  55.         print ' \n Please change directory on /your_cdrom_mount_point \n'
  56.         exit
  57. fi
  58.  
  59. # Questions for installation directory
  60. if [ "`type uname`" != "uname not found" ] ; then
  61.   OSrelease=`uname -r`
  62. else
  63.   OSrelease=unknown
  64. fi
  65.  
  66. case "$OSrelease" in
  67.         *.09.*) defdir="/usr/dataondisc" ;;
  68.         *.10.*) defdir="/opt/dataondisc" ;;
  69.              *) defdir="/opt/dataondisc" ;;
  70. esac
  71.  
  72.     if [ -z "$installdir" ] ; then
  73.       installdir="$defdir"
  74.     fi
  75.  
  76.     echo "\n Enter installation directory for DATA on DISC [${installdir}] \c"
  77.     read answer
  78.  
  79.     case "$answer" in
  80.       "")
  81.         ;;
  82.       /stonline) 
  83.         echo "\n Please choose a different installation directory \n "
  84.         exit 1
  85.         ;;
  86.       *)
  87.         installdir="$answer"
  88.         ;;
  89.     esac    
  90.  
  91. if [ ! -d "$installdir" ]
  92. then
  93.     echo ""
  94.     if yesno "Directory \"$installdir\" does not exist create it now? [y] \c " 0
  95.     then
  96.         mkdir -p "$installdir"
  97.     else
  98.             echo "\n Installation aborted \n"
  99.             exit 1
  100.     fi
  101.  
  102.     if [ ! -d "$installdir" ]
  103.     then
  104.             echo " "
  105.             echo "ERROR: Cannot make directory \"$installdir\"."
  106.             installdir=""
  107.             exit 1
  108.     fi
  109.  
  110. else
  111.         echo " "
  112.         echo " Directory \"$installdir\" exists, please rename or delete it"
  113.         print ' and rerun this procedure \n '
  114.         exit
  115. fi
  116.  
  117. # Links to CD content: check if preexisting dir
  118.  
  119. if [ -r /stonline ]
  120. then
  121.         print '\n Directory /stonline exists, please rename or delete it'
  122.         print ' and rerun this procedure \n '
  123.         exit
  124. else
  125.     mkdir /stonline
  126. fi
  127.  
  128. echo "\n starting local structure creation --- wait \n"
  129. echo "Creating local structure"
  130. find $stonlineroot -type d -exec $setupdir/HPSETUP* makedir {} $installdir \;
  131. mkdir $installdir/SUN_HP
  132. echo "Creating local links --- takes a while "
  133. find $cdmountpoint/INSTALL/SUN_HP -type f -exec $setupdir/HPSETUP* linkfileinstall {}  $installdir/SUN_HP \;
  134. find $stonlineroot -type f -exec $setupdir/HPSETUP* linkfile {}  $installdir \;
  135. ln -s $installdir/stonline/* /stonline
  136.  
  137. # Show Acrobat Reader installation guide
  138. echo ""
  139. if yesno "Do you want to read the  Acrobat Search installation guide ? [y] " 0 
  140. then
  141.         more $installdir/SUN_HP/INSTGUID.TXT*
  142. else
  143.        continue 
  144. fi
  145.  
  146. # Run Acrobat Reader installation script
  147. $installdir/SUN_HP/INSTALL*
  148. rm -r $installdir/SUN_HP
  149. print '\n End procedure \n'
  150.  
  151. exit
  152. }
  153.  
  154. # Creates local directory structure
  155. function makedir
  156. {
  157. cddir="$1"
  158. installdir="$2"
  159. hddir=/stonline`echo $cddir | awk -F'STONLINE' '{print $2}'`
  160. mkdir $installdir$hddir 2>/dev/null
  161. }
  162.  
  163. # Creates soft link on local directory structure pointing to CD files
  164. function linkfileinstall
  165. {
  166. cdfile="$1"
  167. installdir="$2"
  168. HDFILE=`basename $cdfile |cut -d ';' -f 1`
  169. ln -s $cdfile $installdir/$HDFILE
  170. echo ".\c"
  171. }
  172.  
  173. # Creates soft link on local directory structure pointing to CD files
  174. function linkfile
  175. {
  176. cdfile="$1"
  177. installdir="$2"
  178. tmp=/stonline`echo $cdfile | awk -F'STONLINE' '{print $2}'`
  179. hdfile=`echo $tmp|cut -d ';' -f 1`
  180. ln -s $cdfile $installdir$hdfile
  181. echo ".\c"
  182. }
  183.  
  184. # Common: recursive call for local directory structure and soft link to CD files creation
  185. setupdir="$PWD"
  186. action="$1"
  187. param1="$2"
  188. param2="$3"
  189. trap "echo '\n Forced exit \n'; exit 1" 1 2 3
  190. typeset -l hddir hdfile tmp
  191. typeset -u HDFILE
  192. case $action in
  193.         makedir         ) makedir "$param1" "$param2" ;;
  194.         linkfile        ) linkfile "$param1" "$param2" ;;
  195.         linkfileinstall ) linkfileinstall "$param1" "$param2" ;;
  196.         *               ) main ;;
  197. esac
  198.