Contents of /trunk/installer/include/read_disk.sh
Parent Directory | Revision Log
Revision 774 -
(show annotations)
(download)
(as text)
Wed Sep 24 11:07:50 2008 UTC (16 years ago) by niro
File MIME type: application/x-sh
File size: 2538 byte(s)
Wed Sep 24 11:07:50 2008 UTC (16 years ago) by niro
File MIME type: application/x-sh
File size: 2538 byte(s)
-moved helper-scripts into include/ directory
1 | #!/bin/bash |
2 | # $Header: /home/cvsd/magellan-cvs/magellan-src/installer/include/read_disk.sh,v 1.2 2008-09-24 11:07:50 niro Exp $ |
3 | |
4 | source include/hwdetection.sh |
5 | |
6 | # use C locale |
7 | export LC_ALL=C |
8 | |
9 | nocdrom() |
10 | { |
11 | local i |
12 | local item="$1" |
13 | |
14 | for i in ${ALL_CDROMS} |
15 | do |
16 | [[ ${i} = ${item} ]] && return 1 |
17 | done |
18 | |
19 | return 0 |
20 | } |
21 | |
22 | # converts partition id to filesystem name |
23 | partition_id_2_fs_name() |
24 | { |
25 | local x="$1" |
26 | local id |
27 | local desc |
28 | |
29 | while read id desc |
30 | do |
31 | if [[ ${x} = ${id} ]] |
32 | then |
33 | echo "${desc}" |
34 | return 0 |
35 | fi |
36 | done << EOF |
37 | $(/sbin/sfdisk -T) |
38 | EOF |
39 | |
40 | # if we get here the id is unkown |
41 | echo "unkown" |
42 | } |
43 | |
44 | query_partition_disk_setup() |
45 | { |
46 | local i |
47 | local partition |
48 | local filesystem |
49 | local mountpoint |
50 | local command="$1" |
51 | local given_partition="$2" |
52 | |
53 | # |
54 | #--overwrite |
55 | |
56 | for i in ${PARTITION_DISK_SETUP} |
57 | do |
58 | partition=$(echo ${i} | cut -d: -f1) |
59 | filesystem=$(echo ${i} | cut -d: -f2) |
60 | mountpoint=$(echo ${i} | cut -d: -f3) |
61 | |
62 | if [[ ${partition} = ${given_partition} ]] |
63 | then |
64 | case ${command} in |
65 | --filesystem) echo "${filesystem}"; return 0;; |
66 | --mountpoint) echo "${mountpoint}"; return 0;; |
67 | --delete) export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP/${i}/}"; return 0;; |
68 | esac |
69 | fi |
70 | done |
71 | } |
72 | |
73 | #ALL_DISKS="$(get_hwinfo disk)" |
74 | # exclude all ramdisks |
75 | ALL_DISKS="$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d' )" |
76 | ALL_CDROMS="$(get_hwinfo cdrom)" |
77 | |
78 | for disk in ${ALL_DISKS} |
79 | do |
80 | # exclude cdroms |
81 | nocdrom ${disk} || continue |
82 | |
83 | OLDIFS="$IFS" |
84 | IFS=, |
85 | |
86 | echo "${disk}|${disk}" |
87 | while read partition size id boot |
88 | do |
89 | # partition name |
90 | partition="$(echo ${partition} | cut -d: -f1 | sed -e s:$'\t'::g -e s:\ ::g)" |
91 | # size |
92 | size="$(echo ${size} | sed -e s:size=::g -e s:\ ::g)" |
93 | # id but converted |
94 | id="$(echo ${id} | sed -e s:Id=::g -e s:\ ::g)" |
95 | idname="$(IFS=${OLDIFS} partition_id_2_fs_name ${id})" |
96 | # bootable flag |
97 | boot="$(echo ${boot} | sed -e s:\ ::g -e s:bootable:b:g)" |
98 | |
99 | # # swap |
100 | # if [[ ${id} = 82 ]] |
101 | # then |
102 | # mountpoint="swap" |
103 | # format="swap" |
104 | # export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP} ${disk}:swap:swap" |
105 | # else |
106 | # mountpoint, but detect any swap |
107 | mountpoint="$(IFS=${OLDIFS} query_partition_disk_setup --mountpoint ${partition})" |
108 | # filesystem to format |
109 | format="$(IFS=${OLDIFS} query_partition_disk_setup --filesystem ${partition})" |
110 | # fi |
111 | |
112 | echo -n "|${partition}" |
113 | echo -n "|${size}" |
114 | echo -n "|${idname}" |
115 | echo -n "|${boot}" |
116 | echo -n "|${mountpoint}" |
117 | echo -n "|${format}" |
118 | echo |
119 | |
120 | done << EOF |
121 | $(${sudo} /sbin/sfdisk --dump ${disk} | sed '1,3d') |
122 | EOF |
123 | IFS="${OLDIFS}" |
124 | done |
Properties
Name | Value |
---|---|
svn:executable | * |