home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / bin / patch_sun_xnews < prev    next >
Encoding:
Text File  |  1997-07-08  |  4.3 KB  |  152 lines

  1. #!/bin/sh
  2. #
  3. #    $Id: patch_sun_xnews,v 1.4 1995/04/03 15:48:28 ali Exp $
  4. #
  5. # This script is used to apply the SunOs patch 100444-66 to the file
  6. # /usr/openwin/bin/xnews. This patch is needed to correct an error 
  7. # in the SunOs server that would cause idl/motif pulldown menus to
  8. # hang the server.     kdb 1/95
  9. #
  10. # arguments:
  11. #    Not required, but can be used if the defaults are not applicable.
  12. #    
  13. #    arg1     - The source directory
  14. #    arg2    - The dest directory
  15.  
  16. PROG_NAME=`basename $0`
  17. SRC_DIR=
  18. DST_DIR=
  19. NEWS_FILE=xnews
  20. OLD_FILE=xnews.30fcs
  21.  
  22. # Print an intro
  23.  
  24. echo ""
  25. echo "This script is used to apply the xnews portion of the SunOS patch"
  26. echo "number 100444-66. This patch is required to properly run IDL widgets"
  27. echo "on an open windows server. If this patch is not applied, the"
  28. echo "possibility exists that IDL widgets to hang your open windows server"
  29. echo "if run in the open windows environment. If you would prefer to perform"
  30. echo "this SunOS patch yourself, please contact your Sun supplier."
  31. echo ""
  32. echo "This script will replace the file \$OPENWINHOME/bin/xnews with"
  33. echo "the xnews file supplied in the SunOS patch # 100444-66. To run "
  34. echo "properly, you will need read/write permission in the bin directory"
  35. echo "of your open windows distribution. Also, this script should NOT be "
  36. echo "executed if the open windows server is currently running."
  37. echo ""
  38. echo -n "Are you sure you want to continue? Enter y to do so: "
  39. read ANSWER
  40.  
  41. if [ \( "$ANSWER" != "y" \) -a \( "$ANSWER" != "Y" \) ]; then 
  42.    echo "Aborting patch."
  43.    exit 1
  44. fi
  45.  
  46. # Now for the destination dir
  47.  
  48. for DIR in $2 /usr/openwin/bin $OPENWINHOME/bin
  49.    do
  50.    if [ -d $DIR ]; then 
  51.       if [ -f $DIR/xnews ]; then 
  52.      DST_DIR=$DIR
  53.      break
  54.       fi
  55.    fi
  56. done
  57.  
  58. # Now has the path already been applied?
  59.  
  60. PATCH_LVL=`strings $DST_DIR/xnews | grep "Patch #"`
  61. if [ "$PATCH_LVL" = "X11/NeWS Server - Patch #3000-114" ]; then 
  62.    echo "Patch has already been applied to your system. No need to continue"
  63.    exit 0
  64. fi
  65.  
  66. # Lets search for the IDL directory
  67.  
  68. for DIR in $1 . $IDL_DIR/bin.sunos.4.1 /usr/local/lib/idl/bin.sunos.4.1 /usr/local/idl/bin.sunos.4.1 ./bin.sunos.4.1 ../bin.sunos.4.1 $IDL_DIR/bin/bin.sunos.4.1 /usr/local/rsi/idl/bin/bin.sunos.4.1 /usr/local/idl/bin/bin.sunos.4.1 ./bin/bin.sunos.4.1 ../bin/bin.sunos.4.1 
  69.     do
  70.     if [ -d $DIR ]; then 
  71.        if [ \( -f $DIR/xnews.Z \) -o \( -f $DIR/xnews \) ]; then 
  72.       SRC_DIR=$DIR
  73.       break
  74.        fi
  75.     fi
  76. done
  77.  
  78. # Does the source directory exist?
  79.  
  80. if [ "$SRC_DIR" = "" ]; then
  81.    echo "Unable to find the source directory for the patch file."
  82.    echo "To specify the source directory at the command line, issue the "
  83.    echo "following command:"
  84.    echo "        % "$PROG_NAME " <source directory>"
  85.    exit 1
  86. fi
  87.  
  88. # Do the "are you sure?" prompt.
  89.  
  90. echo ""
  91. echo "The following has been detected:"
  92. echo "       Source directory of the patch:          "$SRC_DIR
  93. echo "       Destination directory for the patch:    "$DST_DIR
  94. echo ""
  95. echo -n "Are you sure you want to apply the patch? Enter y to do so: "
  96. read ANSWER
  97.  
  98. if [ \( "$ANSWER" != "y" \) -a \( "$ANSWER" != "Y" \) ]; then 
  99.    echo "Aborting patch."
  100.    exit 1
  101. fi
  102.  
  103. # Can we access the dst file
  104.  
  105. if [ \( ! -r $DST_DIR/xnews \) -o \( ! -w $DST_DIR/xnews \) ]; then 
  106.    echo ""
  107.    echo "Unable to read and/or write to the file $DST_DIR/xnews"
  108.    echo "Aborting."
  109.    exit 1
  110. fi
  111.  
  112. # if the replacement file is compressed, uncompress it
  113.  
  114. if [ -f $SRC_DIR/xnews.Z ]; then
  115.     uncompress $SRC_DIR/xnews.Z
  116. fi
  117.  
  118. # Rename the current file that contains xnews
  119.  
  120. mv $DST_DIR/xnews $DST_DIR/$OLD_FILE
  121. if [ "$?" != "0" ]; then 
  122.    echo "Error in renaming" $DST_DIR"/xnews to" $DST_DIR"/"$OLD_FILE
  123.    echo "Aborting"
  124.    exit 1
  125. fi
  126. echo ""
  127. echo "Renamed" $DST_DIR "/xnews to" $DST_DIR"/"$OLD_FILE
  128.  
  129. # Now copy in the new file, check for errors.
  130.  
  131. echo ""
  132. cp $SRC_DIR/xnews $DST_DIR/xnews
  133. if [ "$?" != "0" ]; then
  134.    echo "Error in copying" $SRC_DIR"/xnews to" $DST_DIR"/xnews"
  135.    echo "Restoring old version of xnews."
  136.    cp $DST_DIR/$OLD_FILE $DST_DIR/xnews
  137.    if [ "$?" != "0" ]; then 
  138.       echo "Error in restoring old version of xnews"
  139.       echo "Please copy file" $DST_DIR"/"$OLD_FILE "to" $DST_DIR"/xnews"
  140.    fi
  141.    exit 1
  142. fi
  143. chmod 755 $DST_DIR/xnews
  144.  
  145. echo "Copied" $SRC_DIR"/xnews to" $DST_DIR"/xnews"
  146. echo ""
  147. echo "The xnews portion of the SunOS patch # 100444-66 has now been applied"
  148. echo "to your system. IDL widgets should now operate correctly."
  149.  
  150.  
  151. exit 0
  152.