home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 11 / 11.iso / n / n003 / 8.ddi / ADDLOCKD.SH next >
Encoding:
Linux/UNIX/POSIX Shell Script  |  1991-02-13  |  5.2 KB  |  231 lines

  1. #! /bin/sh
  2. # @(#)addlockd.sh    1.2 91/02/05
  3. #
  4. # Addlockd.sh is a bourne shell script to uncompress, tar 
  5. # and install files for three architecures of the lock daemon
  6. # and associated kernel files. The architectures and machine
  7. # reference are where the lockd and kernel files can be installed:
  8. #
  9. #   sun3 - 3/50, 3/60, 3/75, 3/110,3/140, 3/160, 3/180, 3/260, 3/280
  10. #   sun3x - 3/80, 3/460, 3/470, 3/480
  11. #   sun4 (for sun4 and sun4c architectures) - 
  12. #     4/110, 4/260, 4/280, SPARCsystem 330, SPARCserver 390, 
  13. #       SPARCserver 470, SPARCserver 490, SPARCstation 1, SPARCstation 2
  14. #
  15. # The kernel files are:
  16. #
  17. #   kern_descrip.o, klm_lockmgr.o, ufs_lockf.o
  18. #
  19. # and the lockd is: rpc.lockd
  20. #
  21. # The intent is to have a new lockd installed that is consistent with
  22. # SUN's CTE level 6 lock daemon.
  23. #
  24. #
  25.  
  26. fatalerror ()   # handle fatal errors
  27. {
  28.     echo "" ; echo "*** FATAL ERROR: $@" 1>&2 ; exit 1
  29. }
  30.  
  31. DIR=`pwd`
  32. HOST=`hostname`
  33. ARCH=`arch -k`
  34. SYSDIR=/usr/sys/$ARCH/OBJ
  35. CONFDIR=/usr/sys/$ARCH/conf
  36. LOCKDDIR=/usr/etc
  37. PRODUCT="Lock Daemon Patch"
  38. VERSION="- version CTE level 100075-06"
  39. COPYRIGHT="Copyright 1991 Sun Microsystems, Inc."
  40.  
  41.  
  42. if [ `whoami` != root ]
  43. then
  44.     fatalerror "You must be root to run $0."
  45. fi
  46.  
  47. printheader()  # print installation header
  48. {
  49.     clear ; cat <<ENDHEADER
  50. #############################################################
  51. #
  52. #         $PRODUCT $VERSION $PATCH
  53. #
  54. #         $COPYRIGHT
  55. #
  56. #############################################################
  57. ENDHEADER
  58. }
  59.  
  60. Proceed()
  61. {
  62.         echo
  63.         echo -n "DO you wish to continue? [y/n] "
  64.         while read choice
  65.         do
  66.           case "$choice" in
  67.                 [Yy]* ) break;;
  68.                 [Nn]* ) exit 1;;
  69.                 * ) echo -n "Please answer y or n:  ";;
  70.           esac
  71.         done
  72. }
  73.  
  74. printheader
  75.  
  76. case "$ARCH" in
  77.     sun3)         
  78.         LOCKD=lockd3
  79.         rm -f lockd3x.tar lockd4.tar
  80.         ;;
  81.     sun3x) 
  82.         LOCKD=lockd3x
  83.         rm -f lockd3.tar lockd4.tar
  84.         ;;
  85.     sun4|sun4c)
  86.         LOCKD=lockd4
  87.         rm -f lockd3.tar lockd3x.tar
  88.         ;;
  89.     *)  fatalerror "$0: cannot install lockd for architecture $ARCH. ***" ;;
  90. esac
  91.  
  92. if [ ! -f $LOCKD.tar ]
  93. then
  94.     fatalerror "The compressed tar file $LOCKD.tar is missing." 
  95. fi
  96.  
  97. FILE=`file $LOCKD.tar | awk '{print $2}'`
  98.  
  99. if [ $FILE = "compressed" ]
  100. then
  101.     echo
  102.     echo "Uncompressing the $LOCKD.tar file..."
  103.     mv $LOCKD.tar $LOCKD.tar.Z
  104.     uncompress $LOCKD.tar
  105.     if [ $? != 0 ] ; then
  106.         fatalerror "Uncompresing $LOCKD.tar failed."
  107.     fi
  108. fi
  109.  
  110. echo
  111. echo "Unpacking the $LOCKD.tar file..."
  112. tar xvf $LOCKD.tar
  113. if [ $? != 0 ] ; then
  114.     fatalerror "Extracting files from $LOCKD.tar failed."
  115. fi
  116.  
  117. if [ -d $SYSDIR ]
  118. then
  119.     echo
  120.     echo "Saving kernel files..."
  121.     if [ -f $SYSDIR/kern_descrip.o ] && [ ! -f $SYSDIR/kern_descrip.org ]
  122.     then
  123.         mv $SYSDIR/kern_descrip.o $SYSDIR/kern_descrip.org
  124.         chmod 444 $SYSDIR/kern_descrip.org
  125.     fi
  126.     if [ -f $SYSDIR/klm_lockmgr.o ]  && [ ! -f $SYSDIR/klm_lockmgr.org ]
  127.     then
  128.         mv $SYSDIR/klm_lockmgr.o $SYSDIR/klm_lockmgr.org
  129.         chmod 444 $SYSDIR/klm_lockmgr.org
  130.     fi
  131.     if [ -f $SYSDIR/ufs_lockf.o ] && [ ! -f $SYSDIR/ufs_lockf.org ]
  132.     then
  133.         mv $SYSDIR/ufs_lockf.o $SYSDIR/ufs_lockf.org
  134.         chmod 444 $SYSDIR/ufs_lockf.org
  135.     fi
  136.     echo
  137.     echo "Installing kernel file kern_descrip.o in $SYSDIR..."
  138.     cp kern_descrip.o $SYSDIR
  139.     if [ $? != 0 ]
  140.     then
  141.         fatalerror "Installing kern_descrip.o failed."
  142.     fi
  143.     echo
  144.     echo "Installing kernel file klm_lockmgr.o in $SYSDIR..."
  145.     cp klm_lockmgr.o $SYSDIR
  146.     if [ $? != 0 ]
  147.     then
  148.         fatalerror "Installing klm_lockmgr.o failed."
  149.     fi
  150.     echo
  151.     echo "Installing kernel file ufs_lockf.o in $SYSDIR..."
  152.     cp ufs_lockf.o $SYSDIR
  153.     if [ $? != 0 ]
  154.     then
  155.         fatalerror "Installing ufs_lockf.o failed."
  156.     fi
  157. else
  158.     fatalerror "The kernel directory $SYSDIR does not exist."
  159. fi
  160.  
  161. if [ ! -f $LOCKDDIR/rpc.lockd.org ]
  162. then
  163.     mv $LOCKDDIR/rpc.lockd $LOCKDDIR/rpc.lockd.org
  164. fi
  165. echo
  166. echo "Installing lockd in $LOCKDDIR..."
  167. cp rpc.lockd /usr/etc
  168. if [ $? != 0 ]
  169. then
  170.     fatalerror "Installing lockd failed."
  171. fi
  172. CONFIG=`strings /vmunix | grep "SunOS Release" | sed -e "s/^.*(//" | sed -e "s/).*//"`
  173. echo
  174. echo "Your system name is $HOST and is a $ARCH machine that is running"
  175. echo "a kernel which was built from the configuration file $CONFIG."
  176. echo
  177. echo -n "Do you wish to use the configuration file $CONFIG to rebuild the kernel? [Y|N] "
  178. while read choice
  179. do
  180.     case "$choice" in
  181.         [Yy]* ) break ;;
  182.         [Nn]* ) echo -n "Enter the name of configuration file: " 
  183.             while read ans
  184.             do
  185.               if [ -f $CONFDIR/$ans ]
  186.               then
  187.                 CONFIG=$ans
  188.                 break
  189.               else
  190.                 echo -n "Please enter the correct file name: "
  191.               fi
  192.             done ;;
  193.         * ) echo -n "Please answer y or n:  " ;;
  194.     esac
  195.     break
  196. done
  197.  
  198. cd $CONFDIR
  199. echo
  200. echo "Configuring a new lockd kernel..."
  201. /etc/config $CONFIG
  202. cd $CONFDIR/../$CONFIG
  203. echo
  204. echo "Rebuilding a new lockd kernel..."
  205. make 
  206. if [ $? != 0 ]
  207. then
  208.     fatalerror "Making a new kernel failed."
  209. fi
  210. if [ ! -f /vmunix.org ]
  211. then
  212.     mv /vmunix /vmunix.org
  213. else
  214.     echo
  215.     echo "WARNING: unable to save the original kernel file to the name vmunix.org."
  216.     Proceed
  217. fi
  218. echo
  219. echo "Installing the new kernel in / (root) directory."
  220. cp $CONFDIR/../$CONFIG/vmunix /
  221. if [ $? != 0 ]
  222. then
  223.     fatalerror "Installing the new lockd kernel (vmunix) failed."
  224. fi
  225. sync; sync; sync
  226. echo
  227. echo "*** Installation of the LOCK DAEMON is complete. ***"
  228. echo 
  229. echo "RUN /etc/fastboot FOR THE CHANGES TO WORK."
  230. echo
  231.