OpenSDE Packages Database (without history before r20070)
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.

228 lines
6.1 KiB

  1. # --- T2-COPYRIGHT-NOTE-BEGIN ---
  2. # This copyright note is auto-generated by ./scripts/Create-CopyPatch.
  3. #
  4. # T2 SDE: package/.../stone/stone_mod_install.sh
  5. # Copyright (C) 2004 - 2006 The T2 SDE Project
  6. # Copyright (C) 1998 - 2003 Clifford Wolf
  7. #
  8. # More information can be found in the files COPYING and README.
  9. #
  10. # This program is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; version 2 of the License. A copy of the
  13. # GNU General Public License can be found in the file COPYING.
  14. # --- T2-COPYRIGHT-NOTE-END ---
  15. part_mounted_action() {
  16. if gui_yesno "Do you want to un-mount the filesystem on $1?"
  17. then umount /dev/$1; fi
  18. }
  19. part_swap_action() {
  20. if gui_yesno "Do you want to de-activate the swap space on $1?"
  21. then swapoff /dev/$1; fi
  22. }
  23. part_mount() {
  24. local dir
  25. gui_input "Mount device $1 on directory
  26. (for example /, /home, /var, ...)" '/' dir
  27. if [ "$dir" ] ; then
  28. dir="$( echo $dir | sed 's,^/*,,; s,/*$,,' )"
  29. if [ -z "$dir" ] || grep -q " /mnt/target " /proc/mounts
  30. then
  31. mkdir -p /mnt/target/$dir
  32. mount /dev/$1 /mnt/target/$dir
  33. else
  34. gui_message "Please mount a root filesystem first."
  35. fi
  36. fi
  37. }
  38. part_mkfs() {
  39. dev=$1
  40. cmd="gui_menu part_mkfs 'Create filesystem on $dev'"
  41. maybe_add () {
  42. if grep -q $1 /proc/filesystems && type -p $3 > /dev/null ; then
  43. cmd="$cmd '$1 ($2 filesystem)' '$3 $4 /dev/$dev'"
  44. fi
  45. }
  46. maybe_add ext3 'journaling' 'mkfs.ext2' '-j'
  47. maybe_add ext2 'non-journaling' 'mkfs.ext2'
  48. maybe_add reiserfs 'journaling' 'mkfs.reiserfs'
  49. maybe_add reiser4 'high-performance journaling' 'mkfs.reiser4'
  50. maybe_add jfs 'IBM journaling' 'mkfs.jfs'
  51. maybe_add xfs 'Sgi journaling' 'mkfs.xfs' '-f'
  52. eval "$cmd" && part_mount $dev
  53. }
  54. part_unmounted_action() {
  55. gui_menu part "$1" \
  56. "Mount an existing filesystem from the partition" \
  57. "part_mount $1" \
  58. "Create a filesystem on the partition" \
  59. "part_mkfs $1" \
  60. "Activate an existing swap space on the partition" \
  61. "swapon /dev/$1" \
  62. "Create a swap space on the partition" \
  63. "mkswap /dev/$1; swapon /dev/$1"
  64. }
  65. part_add() {
  66. local action="unmounted" location="currently not mounted"
  67. if grep -q "^/dev/$1 " /proc/swaps; then
  68. action=swap ; location="swap <no mount point>"
  69. elif grep -q "^/dev/$1 " /proc/mounts; then
  70. action=mounted
  71. location="`grep "^/dev/$1 " /proc/mounts | cut -d ' ' -f 2 |
  72. sed "s,^/mnt/target,," `"
  73. [ "$location" ] || location="/"
  74. fi
  75. # save partition information
  76. disktype /dev/$1 > /tmp/stone-install
  77. type="`grep /tmp/stone-install -v -e '^ ' -e '^Block device' \
  78. -e '^Partition' -e '^---' | \
  79. sed -e 's/[,(].*//' -e '/^$/d' -e 's/ $//' | tail -n 1`"
  80. size="`grep 'Block device, size' /tmp/stone-install | \
  81. sed 's/.* size \(.*\) (.*/\1/'`"
  82. [ "$type" ] || type="undetected"
  83. cmd="$cmd '`printf "%-6s %-24s %-10s" ${1#*/} "$location" "$size"` $type' 'part_${action}_action $1 $2'"
  84. }
  85. disk_action() {
  86. if grep -q "^/dev/$1 " /proc/swaps /proc/mounts; then
  87. gui_message "Partitions from $1 are currently in use, so you
  88. can't modify this disks partition table."
  89. return
  90. fi
  91. cmd="gui_menu disk 'Edit partition table of $1'"
  92. for x in parted cfdisk fdisk pdisk mac-fdisk ; do
  93. type -p $x > /dev/null &&
  94. cmd="$cmd \"Edit partition table using '$x'\" \"$x /dev/$1\""
  95. done
  96. eval $cmd
  97. }
  98. vg_action() {
  99. cmd="gui_menu vg 'Volume Group $1'"
  100. if [ -d /dev/$1 ]; then
  101. cmd="$cmd 'Display attributes of $1' 'gui_cmd \"display $1\" vgdisplay $1'"
  102. if grep -q "^/dev/$1/" /proc/swaps /proc/mounts; then
  103. cmd="$cmd \"LVs of $1 are currently in use, so you can't
  104. de-activate it.\" ''"
  105. else
  106. cmd="$cmd \"De-activate VG '$1'\" 'vgchange -an $1'"
  107. fi
  108. else
  109. cmd="$cmd 'Display attributes of $1' 'gui_cmd \"display $1\" vgdisplay -D $1'"
  110. cmd="$cmd \"Activate VG '$1'\" 'vgchange -ay $1'"
  111. fi
  112. eval $cmd
  113. }
  114. disk_add() {
  115. local x y=0
  116. cmd="$cmd 'Edit partition table of $1:' 'disk_action $1'"
  117. for x in $( cd /dev/ ; ls $1[0-9]* 2> /dev/null )
  118. do
  119. part_add $x ; y=1
  120. done
  121. [ $y = 0 ] && cmd="$cmd 'Partition table is empty.' ''"
  122. cmd="$cmd '' ''"
  123. }
  124. vg_add() {
  125. local x= y=0
  126. cmd="$cmd 'Logical volumes of $1:' 'vg_action $1'"
  127. if [ -d /dev/$1 ] ; then
  128. for x in $( cd /dev/ ; ls -1 $1/* ); do
  129. part_add $x ; y=1
  130. done
  131. if [ $y = 0 ]; then
  132. cmd="$cmd 'No logical volumes.' ''"
  133. fi
  134. else
  135. cmd="$cmd 'Volume Group is not active.' ''"
  136. fi
  137. cmd="$cmd '' ''"
  138. }
  139. main() {
  140. $STONE general set_keymap
  141. local cmd install_now=0
  142. while
  143. cmd="gui_menu install 'Disc setup (partitions and mount-points)
  144. 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.'"
  145. # protect for the case no discs are present ...
  146. found=0
  147. for x in $( cd /dev/; ls hd[a-z] sd[a-z] 2> /dev/null ); do
  148. grep -q cdrom /proc/ide/$x/media 2>/dev/null && continue
  149. disk_add $x
  150. found=1
  151. done
  152. for x in $( cat /etc/lvmtab 2> /dev/null ); do
  153. vg_add "$x"
  154. found=1
  155. done
  156. [ -x /sbin/vgs ] && for x in $( vgs --noheadings -o name 2> /dev/null ); do
  157. vg_add "$x"
  158. found=1
  159. done
  160. if [ $found = 0 ]; then
  161. cmd="$cmd 'No hard-disc found!' ''"
  162. fi
  163. cmd="$cmd 'Install the system ...' 'install_now=1'"
  164. eval "$cmd" && [ "$install_now" -eq 0 ]
  165. do : ; done
  166. if [ "$install_now" -ne 0 ] ; then
  167. $STONE packages
  168. mount -v /dev /mnt/target/dev --bind
  169. cat > /mnt/target/tmp/stone_postinst.sh << EOT
  170. #!/bin/sh
  171. mount -v /proc
  172. mount -v /sys
  173. . /etc/profile
  174. stone setup
  175. umount -v /dev
  176. umount -v /proc
  177. umount -v /sys
  178. EOT
  179. chmod +x /mnt/target/tmp/stone_postinst.sh
  180. grep ' /mnt/target[/ ]' /proc/mounts | \
  181. sed 's,/mnt/target/\?,/,' > /mnt/target/etc/mtab
  182. cd /mnt/target ; chroot . ./tmp/stone_postinst.sh
  183. rm -fv ./tmp/stone_postinst.sh
  184. if gui_yesno "Do you want to un-mount the filesystems and reboot now?"
  185. then
  186. shutdown -r now
  187. else
  188. echo
  189. echo "You might want to umount all filesystems now and reboot"
  190. echo "the system now using the commands:"
  191. echo
  192. echo " umount -arv"
  193. echo " reboot -f"
  194. echo
  195. echo "Or by executing 'shutdown -r now' which will run the above commands."
  196. echo
  197. fi
  198. fi
  199. }