Contents of /tags/installer-0_1_2/gtk-gui/diskpartition.sh
Parent Directory | Revision Log
Revision 1008 -
(show annotations)
(download)
(as text)
Sun May 30 17:32:26 2010 UTC (14 years, 4 months ago) by niro
Original Path: trunk/installer/gtk-gui/diskpartition.sh
File MIME type: application/x-sh
File size: 6040 byte(s)
Sun May 30 17:32:26 2010 UTC (14 years, 4 months ago) by niro
Original Path: trunk/installer/gtk-gui/diskpartition.sh
File MIME type: application/x-sh
File size: 6040 byte(s)
-fixed header -added keep-as-is support -make use of debug() function
1 | # $Id$ |
2 | |
3 | export PARTITION_DRIVE_LIST=' |
4 | <window title="Disk Management" icon-name="gtk-harddisk" window_position="1"> |
5 | <vbox> |
6 | <pixmap> |
7 | <input file>data/header.png</input> |
8 | </pixmap> |
9 | <hbox spacing="200"> |
10 | <pixmap> |
11 | <input file stock="gtk-harddisk"></input> |
12 | </pixmap> |
13 | <text> |
14 | <label>Select a disk to run the partition-manager, select a partition to setup filesystem and mountpoints </label> |
15 | </text> |
16 | </hbox> |
17 | |
18 | <tree exported_column="1"> |
19 | <width>550</width><height>250</height> |
20 | <variable>SELECTED_DISK</variable> |
21 | <label>disk|partition|size|type|flags|mount|format</label> |
22 | <input>include/read_disk.sh</input> |
23 | </tree> |
24 | |
25 | <hbox> |
26 | <button> |
27 | <label>back</label> |
28 | <input file stock="gtk-go-back"></input> |
29 | </button> |
30 | <button> |
31 | <label>next</label> |
32 | <input file stock="gtk-go-forward"></input> |
33 | </button> |
34 | <button> |
35 | <label>edit</label> |
36 | <input file stock="gtk-edit"></input> |
37 | </button> |
38 | </hbox> |
39 | </vbox> |
40 | </window> |
41 | ' |
42 | |
43 | export SETUP_PARTITION=' |
44 | <window title="Disk Management" icon-name="gtk-harddisk" window_position="1"> |
45 | <vbox> |
46 | <pixmap> |
47 | <input file>data/header.png</input> |
48 | </pixmap> |
49 | <hbox spacing="10"> |
50 | <pixmap> |
51 | <input file stock="gtk-harddisk"></input> |
52 | </pixmap> |
53 | <text> |
54 | <label>Choose an appropriate mountpoint and filesystem</label> |
55 | </text> |
56 | </hbox> |
57 | <frame> |
58 | <hbox spacing="70"> |
59 | <text> |
60 | <label>Partition</label> |
61 | </text> |
62 | <text> |
63 | <label>Filesystem</label> |
64 | </text> |
65 | <text> |
66 | <label>Mountpoint</label> |
67 | </text> |
68 | </hbox> |
69 | <hbox> |
70 | <text> |
71 | <input>echo "${SELECTED_DISK}"</input> |
72 | </text> |
73 | <list> |
74 | <width>40</width><height>175</height> |
75 | <variable>FILESYSTEM</variable> |
76 | <item>keep-as-is</item> |
77 | <item>ext2</item> |
78 | <item>ext3</item> |
79 | <item>reiserfs</item> |
80 | <item>swap</item> |
81 | </list> |
82 | <list> |
83 | <width>40</width><height>175</height> |
84 | <variable>MOUNTPOINT</variable> |
85 | <item>/</item> |
86 | <item>/boot</item> |
87 | <item>/home</item> |
88 | <item>/tmp</item> |
89 | <item>/usr</item> |
90 | <item>/var</item> |
91 | <item>/svr</item> |
92 | <item>/opt</item> |
93 | <item>swap</item> |
94 | </list> |
95 | </hbox> |
96 | </frame> |
97 | <hbox> |
98 | <button cancel> |
99 | </button> |
100 | <button ok> |
101 | </button> |
102 | </hbox> |
103 | </vbox> |
104 | </window> |
105 | ' |
106 | |
107 | query_partition_disk_setup() |
108 | { |
109 | local i |
110 | local partition |
111 | local filesystem |
112 | local mountpoint |
113 | local command="$1" |
114 | local given_partition="$2" |
115 | |
116 | # |
117 | #--overwrite |
118 | |
119 | for i in ${PARTITION_DISK_SETUP} |
120 | do |
121 | partition=$(echo ${i} | cut -d: -f1) |
122 | filesystem=$(echo ${i} | cut -d: -f2) |
123 | mountpoint=$(echo ${i} | cut -d: -f3) |
124 | |
125 | if [[ ${partition} = ${given_partition} ]] |
126 | then |
127 | case ${command} in |
128 | --filesystem) echo "${filesystem}"; return 0;; |
129 | --mountpoint) echo "${mountpoint}"; return 0;; |
130 | --delete) export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP/${i}/}"; return 0;; |
131 | esac |
132 | fi |
133 | done |
134 | } |
135 | |
136 | edit_disk_or_partition() |
137 | { |
138 | if [[ ! -z ${SELECTED_DISK} ]] |
139 | then |
140 | ${sudo} gparted ${SELECTED_DISK} |
141 | rundialog_partition_drive_list |
142 | else |
143 | rundialog_setup_partition |
144 | fi |
145 | } |
146 | # needed to be available in the gtk-dialog |
147 | export -f edit_disk_or_partition |
148 | |
149 | rundialog_partition_drive_list() |
150 | { |
151 | rundialog PARTITION_DRIVE_LIST |
152 | debug "EXIT='${EXIT}'" |
153 | |
154 | # save given variables in env |
155 | # they will be shown as default on error |
156 | export SELECTED_DISK |
157 | export PARTITION_DISK_SETUP |
158 | |
159 | # convert to some useable vars |
160 | local disk |
161 | local mount |
162 | local fs |
163 | for disk in ${PARTITION_DISK_SETUP} |
164 | do |
165 | disk="$(echo ${disk} | cut -d: -f1)" |
166 | mount=$(query_partition_disk_setup --mountpoint ${disk}) |
167 | fs=$(query_partition_disk_setup --filesystem ${disk}) |
168 | |
169 | case ${mount} in |
170 | /) |
171 | export PARTITION_DISK_ROOT="${disk}" |
172 | export PARTITION_FS_ROOT="${fs}" |
173 | ;; |
174 | /boot) |
175 | export PARTITION_DISK_BOOT="${disk}" |
176 | export PARTITION_FS_BOOT="${fs}" |
177 | ;; |
178 | /home) |
179 | export PARTITION_DISK_HOME="${disk}" |
180 | export PARTITION_FS_HOME="${fs}" |
181 | ;; |
182 | /tmp) |
183 | export PARTITION_DISK_TMP="${disk}" |
184 | export PARTITION_FS_TMP="${fs}" |
185 | ;; |
186 | /usr) |
187 | export PARTITION_DISK_USER="${disk}" |
188 | export PARTITION_FS_USER="${fs}" |
189 | ;; |
190 | /var) |
191 | export PARTITION_DISK_VAR="${disk}" |
192 | export PARTITION_FS_VAR="${fs}" |
193 | ;; |
194 | /svr) |
195 | export PARTITION_DISK_SVR="${disk}" |
196 | export PARTITION_FS_SVR="${fs}" |
197 | ;; |
198 | /opt) |
199 | export PARTITION_DISK_OPT="${disk}" |
200 | export PARTITION_FS_OPT="${fs}" |
201 | ;; |
202 | swap) |
203 | export PARTITION_DISK_SWAP="${disk}" |
204 | export PARTITION_FS_SWAP="swap" |
205 | ;; |
206 | esac |
207 | done |
208 | |
209 | case ${EXIT} in |
210 | abort) |
211 | echo "Aborted by user." |
212 | exit 1 |
213 | ;; |
214 | back) |
215 | # placeholder |
216 | return 1 |
217 | ;; |
218 | next) |
219 | if [[ -z ${PARTITION_DISK_ROOT} ]] || [[ -z ${PARTITION_DISK_SWAP} ]] |
220 | then |
221 | FAILURE_MESSAGE="You must at least select root (/) and a swap (SWAP) partition!" \ |
222 | rundialog FAILURE_DIALOG |
223 | rundialog_partition_drive_list |
224 | fi |
225 | ;; |
226 | edit) |
227 | # a partition without a number must be the disk |
228 | if [[ ${SELECTED_DISK/[0-9]/} = ${SELECTED_DISK} ]] |
229 | then |
230 | ${sudo} gparted ${SELECTED_DISK} |
231 | rundialog_partition_drive_list |
232 | else |
233 | rundialog_setup_partition |
234 | fi |
235 | ;; |
236 | esac |
237 | } |
238 | |
239 | rundialog_setup_partition() |
240 | { |
241 | rundialog SETUP_PARTITION |
242 | |
243 | # delete stanza |
244 | query_partition_disk_setup --delete "${SELECTED_DISK}" |
245 | # set the new |
246 | export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP} ${SELECTED_DISK}:${FILESYSTEM}:${MOUNTPOINT}" |
247 | |
248 | rundialog_partition_drive_list |
249 | } |
250 | |
251 | # needed to be available in the gtk-dialog |
252 | export -f rundialog_setup_partition |
253 | |
254 | main_diskpartition() |
255 | { |
256 | rundialog_partition_drive_list |
257 | |
258 | # export all variables |
259 | export PARTITION_DISK_SETUP |
260 | export PARTITION_FS_SETUP |
261 | export PARTITION_DISK_ROOT |
262 | export PARTITION_FS_ROOT |
263 | export PARTITION_DISK_BOOT |
264 | export PARTITION_FS_BOOT |
265 | export PARTITION_DISK_HOME |
266 | export PARTITION_FS_HOME |
267 | export PARTITION_DISK_TMP |
268 | export PARTITION_FS_TMP |
269 | export PARTITION_DISK_USER |
270 | export PARTITION_FS_USER |
271 | export PARTITION_DISK_VAR |
272 | export PARTITION_FS_VAR |
273 | export PARTITION_DISK_SVR |
274 | export PARTITION_FS_SVR |
275 | export PARTITION_DISK_OPT |
276 | export PARTITION_FS_OPT |
277 | export PARTITION_DISK_SWAP |
278 | export PARTITION_FS_SWAP |
279 | } |