mirror of the now-defunct rocklinux.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

247 lines
6.8 KiB

  1. # --- ROCK-COPYRIGHT-NOTE-BEGIN ---
  2. #
  3. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  4. # Please add additional copyright information _after_ the line containing
  5. # the ROCK-COPYRIGHT-NOTE-END tag. Otherwise it might get removed by
  6. # the ./scripts/Create-CopyPatch script. Do not edit this copyright text!
  7. #
  8. # ROCK Linux: rock-src/package/base/sysfiles/stone_mod_install.sh
  9. # ROCK Linux is Copyright (C) 1998 - 2006 Clifford Wolf
  10. #
  11. # This program is free software; you can redistribute it and/or modify
  12. # it under the terms of the GNU General Public License as published by
  13. # the Free Software Foundation; either version 2 of the License, or
  14. # (at your option) any later version. A copy of the GNU General Public
  15. # License can be found at Documentation/COPYING.
  16. #
  17. # Many people helped and are helping developing ROCK Linux. Please
  18. # have a look at http://www.rocklinux.org/ and the Documentation/TEAM
  19. # file for details.
  20. #
  21. # --- ROCK-COPYRIGHT-NOTE-END ---
  22. part_mounted_action() {
  23. if gui_yesno "Do you want to un-mount the filesystem on $1/$2?"
  24. then umount /dev/$1/$2; fi
  25. }
  26. part_swap_action() {
  27. if gui_yesno "Do you want to de-activate the swap space on $1/$2?"
  28. then swapoff /dev/$1/$2; fi
  29. }
  30. part_mount() {
  31. local dir
  32. gui_input "Mount device $1/$2 on directory
  33. (for example /, /home, /var, ...)" '/' dir
  34. if [ "$dir" ] ; then
  35. dir="$( echo $dir | sed 's,^/*,,; s,/*$,,' )"
  36. if [ -z "$dir" ] || grep -q " /mnt/target " /proc/mounts
  37. then
  38. mkdir -p /mnt/target/$dir
  39. mount /dev/$1/$2 /mnt/target/$dir
  40. else
  41. gui_message "Please mount a root filesystem first."
  42. fi
  43. fi
  44. }
  45. part_mkfs() {
  46. cmd="gui_menu part_mkfs 'Create filesystem on $1/$2'"
  47. cmd="$cmd 'ext3fs (journaling filesystem)'"
  48. cmd="$cmd 'mke2fs -j /dev/$1/$2'"
  49. cmd="$cmd 'ext2fs (non-journaling fs)'"
  50. cmd="$cmd 'mke2fs /dev/$1/$2'"
  51. cmd="$cmd 'reiserfs (journaling filesystem)'"
  52. cmd="$cmd 'mkreiserfs /dev/$1/$2'"
  53. if type -p jfs_mkfs > /dev/null ; then
  54. cmd="$cmd 'IBM JFS (journaling filesystem)'"
  55. cmd="$cmd 'jfs_mkfs /dev/$1/$2'"
  56. fi
  57. if type -p mkfs.xfs > /dev/null ; then
  58. cmd="$cmd 'SGI XFS (journaling filesystem)'"
  59. cmd="$cmd 'mkfs.xfs -f /dev/$1/$2'"
  60. fi
  61. eval "$cmd" && part_mount $1 $2
  62. }
  63. part_unmounted_action() {
  64. gui_menu part "$1/$2" \
  65. "Create a filesystem on the partition" \
  66. "part_mkfs $1 $2" \
  67. "Mount an existing filesystem from the partition" \
  68. "part_mount $1 $2" \
  69. "Create a swap space on the partition" \
  70. "mkswap /dev/$1/$2; swapon /dev/$1/$2" \
  71. "Activate an existing swap space on the partition" \
  72. "swapon /dev/$1/$2"
  73. }
  74. part_add() {
  75. local action="unmounted" location="currently not mounted"
  76. # Devices in /proc/swaps are listed with their real device file name,
  77. # while in /proc/mounts they are listed with the device file name that
  78. # was actually used for the mount (which may have been a symlink).
  79. if grep -q "^`readlink -fn /dev/$1/$2` " /proc/swaps; then
  80. action=swap ; location="swap <no mount point>"
  81. elif grep -q "^/dev/$1/$2 " /proc/mounts; then
  82. action=mounted
  83. location="`grep "^/dev/$1/$2 " /proc/mounts | cut -d ' ' -f 2 | \
  84. sed "s,^/mnt/target,," `"
  85. [ "$location" ] || location="/"
  86. fi
  87. # save partition information
  88. disktype /dev/$1/$2 > /tmp/stone-install
  89. type="`grep /tmp/stone-install -v -e '^ ' -e '^Block device' \
  90. -e '^Partition' -e '^---' | \
  91. sed -e 's/[,(].*//' -e '/^$/d' -e 's/ $//' | tail -n 1`"
  92. size="`grep 'Block device, size' /tmp/stone-install | \
  93. sed 's/.* size \(.*\) (.*/\1/'`"
  94. [ "$type" ] || type="undetected"
  95. cmd="$cmd '`printf "%-6s %-24s %-10s" $2 "$location" "$size"` $type' 'part_${action}_action $1 $2'"
  96. }
  97. disk_action() {
  98. if grep -q "^/dev/$1/" /proc/swaps /proc/mounts; then
  99. gui_message "Partitions from $1 are currently in use, so you
  100. can't modify this disks partition table."
  101. return
  102. fi
  103. cmd="gui_menu disk 'Edit partition table of $1'"
  104. for x in cfdisk fdisk pdisk mac-fdisk ; do
  105. fn=""
  106. [ -f /bin/$x ] && fn="/bin/$x"
  107. [ -f /sbin/$x ] && fn="/sbin/$x"
  108. [ -f /usr/bin/$x ] && fn="/usr/bin/$x"
  109. [ -f /usr/sbin/$x ] && fn="/usr/sbin/$x"
  110. [ "$fn" ] && \
  111. cmd="$cmd \"Edit partition table using '$x'\" \"$x /dev/$1/disc\""
  112. done
  113. eval $cmd
  114. }
  115. vg_action() {
  116. cmd="gui_menu vg 'Volume Group $1'"
  117. if [ -e /proc/lvm/VGs/$1 ]; then
  118. cmd="$cmd 'Display attributes of $1' 'gui_cmd \"display $1\" vgdisplay $1'"
  119. if grep -q "^/dev/$1/" /proc/swaps /proc/mounts; then
  120. cmd="$cmd \"LVs of $1 are currently in use, so you can't
  121. de-activate it.\" ''"
  122. else
  123. cmd="$cmd \"De-activate VG '$1'\" 'vgchange -an $1'"
  124. fi
  125. else
  126. cmd="$cmd 'Display attributes of $1' 'gui_cmd \"display $1\" vgdisplay -D $1'"
  127. cmd="$cmd \"Activate VG '$1'\" 'vgchange -ay $1'"
  128. fi
  129. eval $cmd
  130. }
  131. disk_add() {
  132. local x y=0
  133. cmd="$cmd 'Edit partition table of $1' 'disk_action $1'"
  134. for x in $( cd /dev/$1 ; ls part* 2> /dev/null )
  135. do
  136. part_add $1 $x ; y=1
  137. done
  138. if [ $y = 0 ]; then
  139. cmd="$cmd 'This disks partition table is empty.' ''"
  140. fi
  141. cmd="$cmd '' ''"
  142. }
  143. vg_add() {
  144. local x y=0
  145. cmd="$cmd 'Logical volumes of $1:' 'vg_action $1'"
  146. if [ -e /proc/lvm/VGs/$1 ] ; then
  147. for x in $( cd /proc/lvm/VGs/$1/LVs; ls -1 )
  148. do
  149. part_add $1 $x ; y=1
  150. done
  151. if [ $y = 0 ]; then
  152. cmd="$cmd 'No logical volumes.' ''"
  153. fi
  154. else
  155. cmd="$cmd 'Volume Group is not active.' ''"
  156. fi
  157. cmd="$cmd '' ''"
  158. }
  159. main() {
  160. local cmd install_now=0
  161. while
  162. cmd="gui_menu install 'Partitioning your discs
  163. This dialog allows you to modify your discs partition layout and to create filesystems and swap space - as well as mounting / activating it. Everything you can do using this tool can also be done manually on the command line.'"
  164. # protect for the case no discs are present ...
  165. if [ -e /dev/discs ] ; then
  166. for x in $( cd /dev/ ; ls discs/*/disc 2> /dev/null )
  167. do
  168. disk_add ${x%/disc}
  169. done
  170. for x in $( cat /etc/lvmtab 2> /dev/null )
  171. do
  172. vg_add "$x"
  173. done
  174. else
  175. cmd="$cmd 'No hard-disc found!' ''"
  176. fi
  177. cmd="$cmd 'Install the system ...' 'install_now=1'"
  178. eval "$cmd" && [ "$install_now" -eq 0 ]
  179. do : ; done
  180. if [ "$install_now" -ne 0 ] ; then
  181. $STONE packages
  182. cat > /mnt/target/tmp/stone_postinst.sh << EOT
  183. #!/bin/sh
  184. mount -v -t proc proc /proc
  185. mount -v -t sysfs sysfs /sys
  186. . /etc/profile
  187. stone setup
  188. umount -v /sys
  189. umount -v /proc
  190. EOT
  191. chmod +x /mnt/target/tmp/stone_postinst.sh
  192. grep ' /mnt/target[/ ]' /proc/mounts | \
  193. sed 's,/mnt/target/\?,/,' > /mnt/target/etc/mtab
  194. mount --bind /dev /mnt/target/dev
  195. cd /mnt/target ; chroot . ./tmp/stone_postinst.sh
  196. rm -fv ./tmp/stone_postinst.sh
  197. if gui_yesno "Do you want to un-mount the filesystems and reboot now?"
  198. then
  199. cd /
  200. sync
  201. umount -adrv
  202. shutdown -r now
  203. else
  204. echo
  205. echo "You might want to umount all filesystems now and reboot"
  206. echo "the system now using the commands:"
  207. echo
  208. echo " umount -adrv"
  209. echo " reboot -f"
  210. echo
  211. echo "Or by executing 'shutdown -r now' which will run the above commands."
  212. echo
  213. fi
  214. fi
  215. }