home *** CD-ROM | disk | FTP | other *** search
/ minnie.tuhs.org / unixen.tar / unixen / Other / Coherent / base / disk1.4.10.dd / etc / build.u < prev    next >
Encoding:
Text File  |  1994-05-04  |  3.0 KB  |  150 lines

  1. # /etc/build.u
  2. # Tue Nov 16 12:35:00 1993 CST
  3.  
  4. # Save any special files before update just in case the user wants to
  5. # get the old ones back...
  6.  
  7. # /etc/build does "/etc/build.u /mnt"
  8.  
  9. . /usr/lib/shell_lib.sh
  10.  
  11. MNT=$1
  12.  
  13. if [ ! -d "$MNT" ]; then
  14.     echo "$0: Can't access system directory \"$MNT\""
  15.     exit 1
  16. fi
  17.  
  18. /bin/echo "About to save old system files."
  19.  
  20. # Older systems contain a /bin/shutdown so we need to move it
  21. # so 1) they can still shutdown if they abort and 2) it will
  22. # be overwritten by the update
  23.  
  24. if [ -f /bin/shutdown ]
  25. then
  26.     /bin/echo "Moving /bin/shutdown to /etc/shutdown...\n"
  27.     mv /bin/shutdown /etc/shutdown
  28. fi
  29.  
  30. # See if there is already an archive out there.
  31.  
  32. SKIP_SAVE=n
  33.  
  34. _ARCHIVE=old_coh.taz
  35. while [ -f $MNT/$_ARCHIVE ]; do
  36.  
  37.     echo "
  38. WARNING: Archive $_ARCHIVE already exists, probably has saved system
  39. files from a previous update.\n"
  40.  
  41.     read_input "Overwrite old archive $_ARCHIVE" \
  42.     yesno "n" require_yes_or_no
  43.  
  44.     is_yes $yesno && break
  45.  
  46.     read_input "Skip saving system files" SKIP_SAVE "n" require_yes_or_no
  47.  
  48.     is_yes $SKIP_SAVE && {
  49.         /bin/echo "System files not saved."
  50.         break
  51.     }
  52.  
  53.     read_input "Name for new save archive" _ARCHIVE
  54.  
  55. done
  56.  
  57. # Make list of files in upd_save which are on the present system.
  58.  
  59. is_yes $SKIP_SAVE || {
  60.     cd $MNT
  61.     TMPLIST=/tmp/upd_save
  62.     > $TMPLIST
  63.     for F in $(cat /conf/upd_save); do
  64.         for G in $(echo $F); do
  65.             if [ -f $G ] ; then
  66.                 echo $G >> $TMPLIST
  67.             fi
  68.         done
  69.     done
  70.  
  71. # Use gtar to make the archive.
  72.  
  73.     cd $MNT
  74.     echo "Saving files..."
  75.     /usr/bin/gtar -czf $_ARCHIVE $(cat $TMPLIST)
  76.     rm -f $TMPLIST
  77.     sync
  78.  
  79. # Sign-off.
  80.  
  81.     echo "Your system files are saved to $_ARCHIVE.  After updating, you can type
  82.     /usr/bin/gtar -tzf /$_ARCHIVE
  83. for a listing of saved files.
  84. Hit <Enter> "
  85.     read JUNK
  86. }
  87.  
  88. # Do conf-related cleanup during update.
  89.  
  90. # Validation for new directory name entry.
  91. require_new_mnt () {
  92.     if [ -d $MNT/$1 -o -f $MNT/$1 ]; then
  93.         echo "$1 already exists.  Please use a different name."
  94.         return 1
  95.     else
  96.         return 0
  97.     fi
  98. }
  99.  
  100. # Remove old /conf/id-* files - they will just add to the confusion.
  101. /bin/rm -f $MNT/conf/id-cmd $MNT/conf/id-var
  102.  
  103. # Fix permission problem in 4.0.1A
  104. /bin/chmog 755 bin bin $MNT/usr/include/sys
  105.  
  106. # Default: rename etc/conf on MNT to OLD_CONF.
  107.  
  108. SAV_CONF="etc/old_conf"
  109.  
  110. ETC_CONF=etc/conf
  111. MNT_ETC_CONF=$MNT/$ETC_CONF
  112.  
  113. # If etc/conf exists
  114. #   If want to delete it
  115. #     Delete old etc/conf
  116. #   If want to rename it
  117. #     Do forever
  118. #       Get new name for etc/conf
  119. #       If  able to rename etc/conf, exit loop
  120. #       Else report error
  121. #     Done
  122. if [ -d $MNT_ETC_CONF ]; then
  123.  
  124.     echo "
  125. WARNING: Directory etc/conf already exists, probably has config
  126. files from a previous installation.\n"
  127.     
  128.     read_input "Delete config directory $ETC_CONF" \
  129.     yesno "n" require_yes_or_no
  130.  
  131.     if is_yes $yesno; then
  132.         /bin/echo "Deleting old config directory."
  133.         /bin/rm -rf $MNT_ETC_CONF
  134.     else
  135.         while :; do
  136.             /bin/echo "Will rename $ETC_CONF"
  137.  
  138.             read_input "New name" SAV_CONF $SAV_CONF \
  139.             require_new_mnt
  140.  
  141.             MNT_SAV_CONF=$MNT/$SAV_CONF
  142.             if /etc/mvdir $MNT_ETC_CONF $MNT_SAV_CONF; then
  143.                 break
  144.             fi
  145.         done
  146.     fi
  147. fi
  148. sync
  149. exit 0
  150.