Contents of /trunk/installer/include/read_disk.sh
Parent Directory | Revision Log
Revision 1035 -
(show annotations)
(download)
(as text)
Sun May 30 18:37:54 2010 UTC (14 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 1900 byte(s)
Sun May 30 18:37:54 2010 UTC (14 years, 3 months ago) by niro
File MIME type: application/x-sh
File size: 1900 byte(s)
-code cleanup
1 | #!/bin/bash |
2 | # $Id$ |
3 | |
4 | source /etc/installer.conf |
5 | source ${INSTALLER_DIR}/include/hwdetection.sh |
6 | |
7 | # use C locale |
8 | export LC_ALL=C |
9 | |
10 | nocdrom() |
11 | { |
12 | local i |
13 | local item="$1" |
14 | |
15 | for i in ${ALL_CDROMS} |
16 | do |
17 | [[ ${i} = ${item} ]] && return 1 |
18 | done |
19 | |
20 | return 0 |
21 | } |
22 | |
23 | query_partition_disk_setup() |
24 | { |
25 | local i |
26 | local partition |
27 | local filesystem |
28 | local mountpoint |
29 | local command="$1" |
30 | local given_partition="$2" |
31 | |
32 | for i in ${PARTITION_DISK_SETUP} |
33 | do |
34 | partition=$(echo ${i} | cut -d: -f1) |
35 | filesystem=$(echo ${i} | cut -d: -f2) |
36 | mountpoint=$(echo ${i} | cut -d: -f3) |
37 | |
38 | if [[ ${partition} = ${given_partition} ]] |
39 | then |
40 | case ${command} in |
41 | --filesystem) echo "${filesystem}"; return 0;; |
42 | --mountpoint) echo "${mountpoint}"; return 0;; |
43 | --delete) export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP/${i}/}"; return 0;; |
44 | esac |
45 | fi |
46 | done |
47 | } |
48 | |
49 | # all disks, but exclude all ramdisks |
50 | ALL_DISKS="$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d' )" |
51 | ALL_CDROMS="$(get_hwinfo cdrom)" |
52 | |
53 | for disk in ${ALL_DISKS} |
54 | do |
55 | # exclude cdroms |
56 | nocdrom ${disk} || continue |
57 | |
58 | echo "${disk}|${disk}" |
59 | |
60 | while read partition blurb |
61 | do |
62 | # size |
63 | size="$(sfdisk -s ${partition})" |
64 | # fstype |
65 | fstype="$(mount -f --guess-fstype ${partition})" |
66 | # bootable flag |
67 | boot="$(fdisk -l ${disk} | grep ${partition} | grep \* | sed 's/.*\(*\).*/b/')" |
68 | # mountpoint, but detect any swap |
69 | mountpoint="$(query_partition_disk_setup --mountpoint ${partition})" |
70 | # filesystem to format |
71 | format="$(query_partition_disk_setup --filesystem ${partition})" |
72 | |
73 | # do not print unkown disk with a size of 1 |
74 | # these disks are containers for secondary partition types |
75 | if [[ ${fstype} = unknown ]] && [ ${size} -eq 1 ] |
76 | then |
77 | continue |
78 | fi |
79 | |
80 | echo -n "|${partition}" |
81 | echo -n "|${size}" |
82 | echo -n "|${fstype}" |
83 | echo -n "|${boot}" |
84 | echo -n "|${mountpoint}" |
85 | echo -n "|${format}" |
86 | echo |
87 | |
88 | done << EOF |
89 | $(get_hwinfo partition | grep ${disk}) |
90 | EOF |
91 | done |
Properties
Name | Value |
---|---|
svn:executable | * |