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.

275 lines
7.3 KiB

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