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.

194 lines
5.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 -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. disk_add() {
  113. local x y=0
  114. cmd="$cmd 'Partition table of $1:' 'disk_action $1'"
  115. for x in $( cd /dev/$1 ; ls part* 2> /dev/null )
  116. do
  117. part_add $1 $x ; y=1
  118. done
  119. if [ $y = 0 ]; then
  120. cmd="$cmd 'Partition table is empty.' ''"
  121. fi
  122. cmd="$cmd '' ''"
  123. }
  124. main() {
  125. local cmd install_now=0
  126. while
  127. cmd="gui_menu install 'Partitioning your discs
  128. 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.'"
  129. # protect for the case no discs are present ...
  130. if [ -e /dev/discs ] ; then
  131. for x in $( cd /dev/discs
  132. ls -l * | grep ' -> ' | cut -f2- -d/ ; )
  133. do
  134. disk_add $x
  135. done
  136. else
  137. cmd="$cmd 'No hard-disc found!' ''"
  138. fi
  139. cmd="$cmd 'Install the system ...'"
  140. cmd="$cmd 'install_now=1'"
  141. eval "$cmd" && [ "$install_now" -eq 0 ]
  142. do : ; done
  143. if [ "$install_now" -ne 0 ] ; then
  144. $STONE packages
  145. cat > /mnt/target/tmp/stone_postinst.sh << EOT
  146. #!/bin/sh
  147. mount -v /dev
  148. mount -v /proc
  149. . /etc/profile
  150. stone setup
  151. umount -v /dev
  152. umount -v /proc
  153. EOT
  154. chmod +x /mnt/target/tmp/stone_postinst.sh
  155. grep ' /mnt/target[/ ]' /proc/mounts | \
  156. sed 's,/mnt/target/\?,/,' > /mnt/target/etc/mtab
  157. cd /mnt/target ; chroot . ./tmp/stone_postinst.sh
  158. rm -fv ./tmp/stone_postinst.sh
  159. echo
  160. echo "You might want to umount all filesystems now and reboot"
  161. echo "the system now using the commands:"
  162. echo
  163. echo " umount -arv"
  164. echo " reboot -f"
  165. echo
  166. echo "Or by executing 'shutdown -r' which will run the above commands."
  167. echo
  168. fi
  169. }