home *** CD-ROM | disk | FTP | other *** search
/ Piper's Pit BBS/FTP: ibm 0010 - 0019 / ibm0010-0019 / ibm0010.tar / ibm0010 / UNIX3862.ZIP / U386-06.ZIP / U386-6.TD0 / usr / lbin / installpkg.r < prev    next >
Encoding:
Text File  |  1988-06-26  |  3.3 KB  |  153 lines

  1. :
  2. #
  3. #ident    "@(#)pkging:installpkg.r    1.2.1.7"
  4. #
  5. # ----------------------------------------------------------------------
  6. # PURPOSE:  Install application software either 3b2 or PLUS style.
  7. # ----------------------------------------------------------------------
  8. # CONTENTS FILE LAYOUT:
  9. # KEY_NAME TYPE NAME
  10. # KEY_NAME is the date+pid+number if needed to make unique
  11. # TYPE is 1 of PLUS stlye and 2 for 3b2 style.
  12. # NAME is the Name file.
  13.  
  14. trap "trap '' 1 2 3 9 15; cd /; rm -rf ${TMPDIR} ${CPLOG} & echo You have canceled the installation.; exit 1" 1 2 3 9 15
  15.  
  16. INDIR=/usr/lib/installed
  17. CONTENTS=${INDIR}/CONTENTS
  18. TMPDIR=/usr/tmp/install$$
  19.  
  20. FDMESS="Please insert the floppy disk.\n\nIf the program installation \
  21. requires more than one floppy disk, be sure to insert the disks in the \
  22. proper order, starting with disk number 1.\nAfter the first floppy disk, \
  23. instructions will be provided for inserting the remaining floppy disks."
  24.  
  25. # Check if root is performing the operation
  26. id | grep "(root)" > /dev/null
  27. if [ "$?" = "0" ]
  28. then
  29.     id | grep "euid=" > /dev/null
  30.     if [ "$?" = "0" ] #Did get root above; no euid string
  31.     then
  32.         id | grep "euid=0(root)" > /dev/null
  33.         if [ "$?" = 0 ]
  34.         then
  35.             UID=0
  36.         else
  37.             UID=1
  38.         fi
  39.     else
  40.         UID=0
  41.     fi
  42. else
  43.     UID=1
  44. fi
  45. if [ "$UID" != 0 ]
  46. then echo "You must be root or super-user to install software."
  47.      exit 1
  48. fi
  49.  
  50. if [ -z "$TERM" ]
  51. then TERM=AT386-M
  52. fi
  53. CLEAR=`tput clear 2>/dev/null`
  54.  
  55. cd /
  56. if [ ! -d /usr/options ]
  57. then
  58.     rm -rf /usr/options
  59.     mkdir /usr/options
  60.     chmod 755 /usr/options
  61. fi
  62. if [ ! -d /install ]
  63. then
  64.     rm -rf /install
  65.     mkdir /install
  66.     chmod 755 /install
  67. fi
  68.  
  69. /etc/mount | grep "^/install" > /dev/null 2>&1
  70. if [ $? = 0 ]
  71. then
  72.     message -d "Cannot run installpkg.  The /install directory is currently \
  73. mounted.  Please unmount /install and then try again."
  74.     exit 1
  75. fi
  76.  
  77. MES1=
  78. /bin/dd if=/dev/rdsk/f1t count=1 2>&1 |     \
  79.     grep "No such device" 2>&1 > /dev/null
  80. if [ $? != 0 ]
  81. then
  82.     while true
  83.     do
  84.         echo "\nThis system has two floppy drives.\n\
  85. Strike ENTER to install from drive 0\n\
  86. or 1 to install from drive 1.  \c"
  87.         read ans
  88.         if [ "$ans" = 1 ]
  89.         then
  90.             DRIVE=/dev/dsk/f1
  91.             FDRIVE=/dev/rdsk/f1
  92.             FD=1
  93.             break
  94.         elif [ "$ans" = "" -o "$ans" = 0 ]
  95.         then
  96.             DRIVE=/dev/dsk/f0
  97.             FDRIVE=/dev/rdsk/f0
  98.             FD=0
  99.             break
  100.         fi
  101.     done
  102. else
  103.     DRIVE=/dev/dsk/f0
  104.     FDRIVE=/dev/rdsk/f0
  105.     FD=0
  106. fi
  107. while [ 1 ]
  108. do
  109.     message -c $MES1 $FDMESS
  110.     if [ $? != 0 ]
  111.     then exit 1
  112.     fi
  113.     echo "$CLEAR"
  114.     echo "\n\n\tInstallation is in progress -- do not remove the floppy disk."
  115.     /etc/mount $DRIVE /install -r > /dev/null 2>&1
  116.     if [ $? = 0 ]
  117.     then
  118.         /etc/umount $DRIVE > /dev/null 2>&1
  119.         break
  120.     fi
  121.  
  122.     dd if=$FDRIVE of=/dev/null bs=15b count=3 > /dev/null 2>&1
  123.     if [ $? = 0 ]
  124.     then exec /usr/lbin/Install.sh $FDRIVE $FD
  125.     fi
  126.  
  127.     MES1="Cannot determine the 'type' of floppy.\n"
  128. done
  129. /etc/mount $DRIVE /install -r > /dev/null 2>&1
  130. if [ ! -r /install/install/INSTALL ]
  131. then
  132.     echo "Improperly built software removable medium."
  133.     /etc/umount /install > /dev/null 2>&1
  134.     exit
  135. fi
  136. cd /tmp
  137. trap "trap '' 1 2 3 9 15; cd /; rm -f /tmp/$$*; /etc/umount /install; exit 1" 1 2 3
  138. cp /install/install/INSTALL $$INSTALL
  139. chmod +x $$INSTALL
  140. /tmp/$$INSTALL $DRIVE /install "`basename ${DRIVE}` drive" ||
  141.     echo 'WARNING: Installation may not have completed properly.'
  142. trap '' 1 2 3
  143. cd /
  144. rm -f $$INSTALL
  145. /etc/umount /install > /dev/null 2>&1
  146. rm -rf /tmp/$$*
  147. if [ -f /etc/.new_unix ]
  148. then
  149.     sync; sync
  150.     exec /etc/conf/bin/idreboot
  151. fi
  152. exit 0
  153.