home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 1999 March B / SCO_CASTOR4RRT.iso / update701 / root.18 / usr / lib / vxvm / bin / vxunroot / vxunroot
Encoding:
Text File  |  1998-08-18  |  7.2 KB  |  248 lines

  1. #!/sbin/sh -
  2.  
  3. # Copyright (c) 1998 The Santa Cruz Operation, Inc.. All Rights Reserved. 
  4. #                                                                         
  5. #        THIS IS UNPUBLISHED PROPRIETARY SOURCE CODE OF THE               
  6. #                   SANTA CRUZ OPERATION INC.                             
  7. #                                                                         
  8. #   The copyright notice above does not evidence any actual or intended   
  9. #   publication of such source code.                                      
  10.  
  11. # @(#)cmd.vxvm:unixware/support/vxunroot.sh    1.4 5/21/98 17:00:46 - cmd.vxvm:unixware/support/vxunroot.sh
  12. #ident    "@(#)cmd.vxvm:unixware/support/vxunroot.sh    1.4"
  13.  
  14. # Copyright(C)1996 VERITAS Software Corporation.  ALL RIGHTS RESERVED.
  15. # UNPUBLISHED -- RIGHTS RESERVED UNDER THE COPYRIGHT
  16. # LAWS OF THE UNITED STATES.  USE OF A COPYRIGHT NOTICE
  17. # IS PRECAUTIONARY ONLY AND DOES NOT IMPLY PUBLICATION
  18. # OR DISCLOSURE.
  19. # THIS SOFTWARE CONTAINS CONFIDENTIAL INFORMATION AND
  20. # TRADE SECRETS OF VERITAS SOFTWARE.  USE, DISCLOSURE,
  21. # OR REPRODUCTION IS PROHIBITED WITHOUT THE PRIOR
  22. # EXPRESS WRITTEN PERMISSION OF VERITAS SOFTWARE.
  23. #               RESTRICTED RIGHTS LEGEND
  24. # USE, DUPLICATION, OR DISCLOSURE BY THE GOVERNMENT IS
  25. # SUBJECT TO RESTRICTIONS AS SET FORTH IN SUBPARAGRAPH
  26. # (C) (1) (ii) OF THE RIGHTS IN TECHNICAL DATA AND
  27. # COMPUTER SOFTWARE CLAUSE AT DFARS 252.227-7013.
  28. #               VERITAS SOFTWARE
  29. # 1600 PLYMOUTH STREET, MOUNTAIN VIEW, CA 94043
  30.  
  31. : ${VOLROOT_DIR:=$__VXVM_ROOT_DIR}
  32. . ${VOL_SCRIPTS_LIB:-$VOLROOT_DIR/usr/lib/vxvm/lib}/vxcommon
  33.  
  34. voladm_help_push yorn.help
  35. voladm_menu_push VolumeManager/Unroot
  36.  
  37. bail()
  38. {
  39.     quit 10
  40. }
  41.  
  42. eval `vxparms`
  43. if [ -z "$V_STAND" ]
  44. then
  45.     ewritemsg -M vxvmshm:261 \
  46.      "Internal error -- cannot determine slice tag for stand slice."
  47.     quit 10
  48. fi
  49.  
  50. ewritemsg -M vxvmshm:501 \
  51. "This operation will convert your root, stand and swap file systems from
  52.   volumes to regular partitions."
  53.  
  54. for vname in rootvol swapvol standvol
  55. do
  56.     vxprint -g rootdg -F "%pl_num" $vname > $tmpfile1
  57.     if [ $? -ne 0 ]
  58.     then
  59.         export vname; ewritemsg -M vxvmshm:575 \
  60. "WARNING: Cannot determine the count of plexes for the $vname volume"
  61.     else
  62.         if [ "X`cat $tmpfile1`" != X1 ]
  63.         then
  64. export tmpfile1 vname; ewritemsg -M vxvmshm:212 \
  65. "ERROR: There are `cat $tmpfile1` plexes associated with volume $vname
  66.          The vxunroot operation cannot proceed."
  67.             quit 10
  68.         fi
  69.     fi
  70. done
  71. rm -f $tmpfile1
  72.  
  73. set_rootdisk
  74.  
  75. $PRTVTOC -f $tmpfile1 /dev/rdsk/${rootdisk}${VOL_FULL_SLICE}
  76. exec 3<&0 < $tmpfile1
  77. standsl=
  78. rootsl=
  79. swapsl=
  80. usrsl=
  81. varsl=
  82. homesl=
  83. while read slice tag flags start size
  84. do
  85.     case $slice in
  86.     [0-9])    sliceno=$slice;;
  87.     10)    sliceno=a;;
  88.     11)    sliceno=b;;
  89.     12)    sliceno=c;;
  90.     13)    sliceno=d;;
  91.     14)    sliceno=e;;
  92.     15)    sliceno=f;;
  93.     '#'*)    continue;;
  94.     esac
  95.     case $tag in
  96.     $V_STAND)    [ -z "$standsl" ] && standsl=${rootdisk}s$sliceno;;
  97.     $V_ROOT)    [ -z "$rootsl" ]  && rootsl=${rootdisk}s$sliceno;;
  98.     $V_SWAP)    [ -z "$swapsl" ]  && swapsl=${rootdisk}s$sliceno;;
  99.     $V_USR)        [ -z "$usrsl" ]  && usrsl=${rootdisk}s$sliceno;;
  100.     $V_VAR)        [ -z "$varsl" ]  && varsl=${rootdisk}s$sliceno;;
  101.     $V_HOME)    [ -z "$homesl" ]  && homesl=${rootdisk}s$sliceno;;
  102.     esac
  103. done
  104. rm -f $tmpfile1
  105. if [ -z "$standsl" ]
  106. then
  107.     ewritemsg -M vxvmshm:182 \
  108. "Disk $rootdisk has no STAND partition.  The vxunroot operation
  109.   cannot proceed."
  110.     quit 10
  111. fi
  112. if [ -z "$rootsl" ]
  113. then
  114.     ewritemsg -M vxvmshm:181 \
  115. "Disk $rootdisk has no ROOT partition.  The vxunroot operation
  116.   cannot proceed."
  117.     quit 10
  118. fi
  119. if [ -z "$swapsl" ]
  120. then
  121.     ewritemsg -M vxvmshm:183 \
  122. "Disk $rootdisk has no SWAP partition.  The vxunroot operation
  123.   cannot proceed."
  124.     quit 10
  125. fi
  126.  
  127. addition=
  128. usrda=`vxprint -sF "%device" -e 'assoc.assoc="usr"' | sed -e 's/\(.*\)s./\1/g'`
  129. if [ "X$usrda" = "X${rootdisk}" ]
  130. then
  131.     export usrsl
  132.     egettxt "  Replace volume usr with $usrsl" vxvmshm:32
  133.     addition=true
  134. fi
  135.  
  136. varda=`vxprint -sF "%device" -e 'assoc.assoc="var"' | sed -e 's/\(.*\)s./\1/g'`
  137. if [ "X$varda" = "X${rootdisk}" ]
  138. then
  139.     export varsl
  140.     egettxt "  Replace volume var with $varsl" vxvmshm:33
  141.     addition=true
  142. fi
  143.  
  144. homeda=`vxprint -sF "%device" -e 'assoc.assoc="home"' | \
  145.                         sed -e 's/\(.*\)s./\1/g'`
  146. if [ "X$homeda" = "X${rootdisk}" ]
  147. then
  148.     export homesl
  149.     egettxt "  Replace volume home with $homesl" vxvmshm:31
  150.     addition=true
  151. fi
  152.  
  153. if [ ! -z "$addition" ]
  154. then
  155.     ewritemsg -M vxvmshm:246 "In addition to the following..."
  156. fi
  157.  
  158. export rootsl standsl swapsl; ewritemsg -M vxvmshm:337 \
  159. "Replace volume rootvol with $rootsl.
  160.   Replace volume swapvol with $swapsl.
  161.   Replace volume standvol with $standsl.
  162.  
  163.   This operation will require a system reboot.  If you choose to
  164.   continue with this operation, your kernel will be updated to
  165.   discontinue use of the Volume Manager for your root and swap
  166.   devices."
  167.  
  168. voladm_yorn -M vxvmshm:201 "Do you wish to do this now" y || quit 10
  169.  
  170. [ -d $STATEDIR ] || volmkdirs
  171.  
  172. cd $SAVEDIR
  173. ewritemsg -M vxvmshm:347 "Restoring kernel configuration..."
  174. [ "$verbose" ] && echo "! find . -type f -print | while read FILE do install -i -s $FILE \`dirname  ${VOLROOT}/${FILE}\'" >&5
  175. find . -type f -print | while read FILE
  176. do
  177.     install -i -s $FILE `dirname  ${VOLROOT}/${FILE}`
  178. done
  179.  
  180. if not doit /etc/conf/bin/idbuild -B; then
  181.     ewritemsg -M  vxvmshm:440 \
  182. "The kernel build failed. The Volume Manager cannot deconfigure
  183.   the root volume until a kernel can be built.  Correct the problem
  184.   and run this command again."
  185.     quit 1
  186. fi
  187. if not doit /etc/conf/bin/idcpunix; then
  188.     ewritemsg -M vxvmshm:391 \
  189. "The copy of the kernel failed.  Examine your /stand file system to
  190.   see if it is not mounted, or if it is full or damaged.  Correct the
  191.   problem and run this command again."
  192.     quit 1
  193. fi
  194.  
  195. #restore swap entry in inittabs
  196. [ -f $VOLROOT/oldswapdev ] && xcmd rm $VOLROOT/oldswapdev
  197.  
  198. if [ ! -f $DEVDIR/oldswapdev ]; then
  199.     ewritemsg -M vxvmshm:509\
  200. "Unable to determine old swap device. Either root, swap and stand are not
  201. currently mounted on volumes or else /etc/conf/init.d/kernel and /etc/inittab
  202. have to be edited manually."
  203.     quit 10
  204. else
  205. oldswapdev=`cat $DEVDIR/oldswapdev`
  206.  
  207. for file in $VOLROOT/etc/conf/init.d/kernel $VOLROOT/etc/inittab
  208. do
  209.     xcmd grep -v "/sbin/swap -a /dev/vx/dsk/swapvol" $file > $file.new
  210.     xcmd ed - $file.new <<-'!'
  211.         /^[^:]*::sysinit:\/sbin\/ckroot/i
  212.         swp1::sysinit:/sbin/swap -a /dev/swap >/dev/sysmsg 2>&1
  213.         .
  214.         w
  215.         q
  216.         !
  217.     xcmd mv $file.new $file
  218. done
  219.  
  220. xcmd sed -e "s?/dev/vx/dsk/swapvol?${oldswapdev}?" $VOLROOT/etc/swaptab > /tmp/swaptab
  221. xcmd mv /tmp/swaptab $VOLROOT/etc/swaptab
  222. xcmd rm $DEVDIR/oldswapdev
  223. fi
  224.  
  225. rm -f $tmpfile1
  226.  
  227. doit sed -e "s;/dev/vx/dsk/standvol\\([     ]\\);/dev/dsk/$standsl\\1;" \
  228.      -e "s;/dev/vx/rdsk/standvol\\([     ]\\);/dev/rdsk/$standsl\\1;" \
  229.      -e "s;/dev/vx/dsk/usr\\([     ]\\);/dev/dsk/$usrsl\\1;" \
  230.      -e "s;/dev/vx/rdsk/usr\\([     ]\\);/dev/rdsk/$usrsl\\1;" \
  231.      -e "s;/dev/vx/dsk/var\\([     ]\\);/dev/dsk/$varsl\\1;" \
  232.      -e "s;/dev/vx/rdsk/var\\([     ]\\);/dev/rdsk/$varsl\\1;" \
  233.      -e "s;/dev/vx/dsk/home\\([     ]\\);/dev/dsk/$homesl\\1;" \
  234.      -e "s;/dev/vx/rdsk/home\\([     ]\\);/dev/rdsk/$homesl\\1;" \
  235.         < $VOLROOT/etc/vfstab > $tmpfile1 || quit 10
  236. doit cp $tmpfile1 $VOLROOT/etc/vfstab || quit 10
  237.  
  238. doit rm -f $rootfile $rootsvfile $tmpfile1
  239.  
  240. ewritemsg -M vxvmshm:99 \
  241. "A shutdown is now required to install the new kernel.
  242.  After exiting the utility, use shutdown -g0 -i6 -y to
  243.  shutdown the machine, at your convenience."
  244.  
  245. quit 10
  246.