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.

241 lines
6.5 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 - 2003 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. if grep -q "^/dev/$1/$2 " /proc/swaps; then
  77. action=swap ; location="swap <no mount point>"
  78. elif grep -q "^/dev/$1/$2 " /proc/mounts; then
  79. action=mounted
  80. location="`grep "^/dev/$1/$2 " /proc/mounts | cut -d ' ' -f 2 | \
  81. sed "s,^/mnt/target,," `"
  82. [ "$location" ] || location="/"
  83. fi
  84. # save partition information
  85. disktype /dev/$1/$2 > /tmp/stone-install
  86. type="`grep /tmp/stone-install -v -e '^ ' -e '^Block device' \
  87. -e '^Partition' -e '^---' | \
  88. sed -e 's/[,(].*//' -e '/^$/d' -e 's/ $//' | tail -n 1`"
  89. size="`grep 'Block device, size' /tmp/stone-install | \
  90. sed 's/.* size \(.*\) (.*/\1/'`"
  91. [ "$type" ] || type="undetected"
  92. cmd="$cmd '`printf "%-6s %-24s %-10s" $2 "$location" "$size"` $type' 'part_${action}_action $1 $2'"
  93. }
  94. disk_action() {
  95. if grep -q "^/dev/$1/" /proc/swaps /proc/mounts; then
  96. gui_message "Partitions from $1 are currently in use, so you
  97. can't modify this disks partition table."
  98. return
  99. fi
  100. cmd="gui_menu disk 'Edit partition table of $1'"
  101. for x in cfdisk fdisk pdisk mac-fdisk ; do
  102. fn=""
  103. [ -f /bin/$x ] && fn="/bin/$x"
  104. [ -f /sbin/$x ] && fn="/sbin/$x"
  105. [ -f /usr/bin/$x ] && fn="/usr/bin/$x"
  106. [ -f /usr/sbin/$x ] && fn="/usr/sbin/$x"
  107. [ "$fn" ] && \
  108. cmd="$cmd \"Edit partition table using '$x'\" \"$x /dev/$1/disc\""
  109. done
  110. eval $cmd
  111. }
  112. vg_action() {
  113. cmd="gui_menu vg 'Volume Group $1'"
  114. if [ -e /proc/lvm/VGs/$1 ]; then
  115. cmd="$cmd 'Display attributes of $1' 'gui_cmd \"display $1\" vgdisplay $1'"
  116. if grep -q "^/dev/$1/" /proc/swaps /proc/mounts; then
  117. cmd="$cmd \"LVs of $1 are currently in use, so you can't
  118. de-activate it.\" ''"
  119. else
  120. cmd="$cmd \"De-activate VG '$1'\" 'vgchange -an $1'"
  121. fi
  122. else
  123. cmd="$cmd 'Display attributes of $1' 'gui_cmd \"display $1\" vgdisplay -D $1'"
  124. cmd="$cmd \"Activate VG '$1'\" 'vgchange -ay $1'"
  125. fi
  126. eval $cmd
  127. }
  128. disk_add() {
  129. local x y=0
  130. cmd="$cmd 'Partition table of $1:' 'disk_action $1'"
  131. for x in $( cd /dev/$1 ; ls part* 2> /dev/null )
  132. do
  133. part_add $1 $x ; y=1
  134. done
  135. if [ $y = 0 ]; then
  136. cmd="$cmd 'Partition table is empty.' ''"
  137. fi
  138. cmd="$cmd '' ''"
  139. }
  140. vg_add() {
  141. local x y=0
  142. cmd="$cmd 'Logical volumes of $1:' 'vg_action $1'"
  143. if [ -e /proc/lvm/VGs/$1 ] ; then
  144. for x in $( cd /proc/lvm/VGs/$1/LVs; ls -1 )
  145. do
  146. part_add $1 $x ; y=1
  147. done
  148. if [ $y = 0 ]; then
  149. cmd="$cmd 'No logical volumes.' ''"
  150. fi
  151. else
  152. cmd="$cmd 'Volume Group is not active.' ''"
  153. fi
  154. cmd="$cmd '' ''"
  155. }
  156. main() {
  157. local cmd install_now=0
  158. while
  159. cmd="gui_menu install 'Partitioning your discs
  160. This dialog allows you to modify your discs parition layout and to create filesystems and swap-space - as well as mouting / activating it. Everything you can do using this tool can also be done manually on the command line.'"
  161. # protect for the case no discs are present ...
  162. if [ -e /dev/discs ] ; then
  163. for x in $( cd /dev/discs
  164. ls -l * | grep ' -> ' | cut -f2- -d/ ; )
  165. do
  166. disk_add $x
  167. done
  168. for x in $( cat /etc/lvmtab 2> /dev/null )
  169. do
  170. vg_add "$x"
  171. done
  172. else
  173. cmd="$cmd 'No hard-disc found!' ''"
  174. fi
  175. cmd="$cmd 'Install the system ...' 'install_now=1'"
  176. eval "$cmd" && [ "$install_now" -eq 0 ]
  177. do : ; done
  178. if [ "$install_now" -ne 0 ] ; then
  179. $STONE packages
  180. cat > /mnt/target/tmp/stone_postinst.sh << EOT
  181. #!/bin/sh
  182. mount -v /dev
  183. mount -v /proc
  184. . /etc/profile
  185. stone setup
  186. umount -v /dev
  187. umount -v /proc
  188. EOT
  189. chmod +x /mnt/target/tmp/stone_postinst.sh
  190. grep ' /mnt/target[/ ]' /proc/mounts | \
  191. sed 's,/mnt/target/\?,/,' > /mnt/target/etc/mtab
  192. cd /mnt/target ; chroot . ./tmp/stone_postinst.sh
  193. rm -fv ./tmp/stone_postinst.sh
  194. if gui_yesno "Do you want to un-mount the filesystems and reboot now?"
  195. then
  196. shutdown -r now
  197. else
  198. echo
  199. echo "You might want to umount all filesystems now and reboot"
  200. echo "the system now using the commands:"
  201. echo
  202. echo " umount -arv"
  203. echo " reboot -f"
  204. echo
  205. echo "Or by executing 'shutdown -r now' which will run the above commands."
  206. echo
  207. fi
  208. fi
  209. }