Annotation of /trunk/installer/gtk-gui/diskpartition.sh
Parent Directory | Revision Log
Revision 773 -
(hide annotations)
(download)
(as text)
Wed Sep 24 10:54:00 2008 UTC (16 years ago) by niro
File MIME type: application/x-sh
File size: 6130 byte(s)
Wed Sep 24 10:54:00 2008 UTC (16 years ago) by niro
File MIME type: application/x-sh
File size: 6130 byte(s)
-moved helper-scripts into include/ directory
1 | niro | 773 | # $Header: /home/cvsd/magellan-cvs/magellan-src/installer/gtk-gui/diskpartition.sh,v 1.4 2008-09-24 10:54:00 niro Exp $ |
2 | niro | 719 | |
3 | export PARTITION_DRIVE_LIST=' | ||
4 | <window title="Disk Management" icon-name="gtk-harddisk" window_position="1"> | ||
5 | <vbox> | ||
6 | <pixmap> | ||
7 | niro | 772 | <input file>data/header.png</input> |
8 | niro | 719 | </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 | niro | 773 | <input>include/read_disk.sh</input> |
23 | niro | 719 | </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 | niro | 772 | <input file>data/header.png</input> |
48 | niro | 719 | </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>ext2</item> | ||
77 | <item>ext3</item> | ||
78 | <item>reiserfs</item> | ||
79 | <item>swap</item> | ||
80 | </list> | ||
81 | <list> | ||
82 | <width>40</width><height>175</height> | ||
83 | <variable>MOUNTPOINT</variable> | ||
84 | <item>/</item> | ||
85 | <item>/boot</item> | ||
86 | <item>/home</item> | ||
87 | <item>/tmp</item> | ||
88 | <item>/usr</item> | ||
89 | <item>/var</item> | ||
90 | <item>/svr</item> | ||
91 | <item>/opt</item> | ||
92 | <item>swap</item> | ||
93 | </list> | ||
94 | </hbox> | ||
95 | </frame> | ||
96 | <hbox> | ||
97 | <button cancel> | ||
98 | </button> | ||
99 | <button ok> | ||
100 | </button> | ||
101 | </hbox> | ||
102 | </vbox> | ||
103 | </window> | ||
104 | ' | ||
105 | |||
106 | query_partition_disk_setup() | ||
107 | { | ||
108 | local i | ||
109 | local partition | ||
110 | local filesystem | ||
111 | local mountpoint | ||
112 | local command="$1" | ||
113 | local given_partition="$2" | ||
114 | |||
115 | # | ||
116 | #--overwrite | ||
117 | |||
118 | for i in ${PARTITION_DISK_SETUP} | ||
119 | do | ||
120 | partition=$(echo ${i} | cut -d: -f1) | ||
121 | filesystem=$(echo ${i} | cut -d: -f2) | ||
122 | mountpoint=$(echo ${i} | cut -d: -f3) | ||
123 | |||
124 | if [[ ${partition} = ${given_partition} ]] | ||
125 | then | ||
126 | case ${command} in | ||
127 | --filesystem) echo "${filesystem}"; return 0;; | ||
128 | --mountpoint) echo "${mountpoint}"; return 0;; | ||
129 | --delete) export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP/${i}/}"; return 0;; | ||
130 | esac | ||
131 | fi | ||
132 | done | ||
133 | } | ||
134 | |||
135 | edit_disk_or_partition() | ||
136 | { | ||
137 | if [[ ! -z ${SELECTED_DISK} ]] | ||
138 | then | ||
139 | ${sudo} gparted ${SELECTED_DISK} | ||
140 | rundialog_partition_drive_list | ||
141 | else | ||
142 | rundialog_setup_partition | ||
143 | fi | ||
144 | } | ||
145 | # needed to be available in the gtk-dialog | ||
146 | export -f edit_disk_or_partition | ||
147 | |||
148 | rundialog_partition_drive_list() | ||
149 | { | ||
150 | rundialog PARTITION_DRIVE_LIST | ||
151 | echo "DEBUG: EXIT='${EXIT}'" | ||
152 | |||
153 | # save given variables in env | ||
154 | # they will be shown as default on error | ||
155 | export SELECTED_DISK | ||
156 | export PARTITION_DISK_SETUP | ||
157 | |||
158 | # convert to some useable vars | ||
159 | local disk | ||
160 | local mount | ||
161 | local fs | ||
162 | for disk in ${PARTITION_DISK_SETUP} | ||
163 | do | ||
164 | disk="$(echo ${disk} | cut -d: -f1)" | ||
165 | mount=$(query_partition_disk_setup --mountpoint ${disk}) | ||
166 | fs=$(query_partition_disk_setup --filesystem ${disk}) | ||
167 | case ${mount} in | ||
168 | /) | ||
169 | export PARTITION_DISK_ROOT="${disk}" | ||
170 | export PARTITION_FS_ROOT="${fs}" | ||
171 | ;; | ||
172 | /boot) | ||
173 | export PARTITION_DISK_BOOT="${disk}" | ||
174 | export PARTITION_FS_BOOT="${fs}" | ||
175 | ;; | ||
176 | /home) | ||
177 | export PARTITION_DISK_HOME="${disk}" | ||
178 | export PARTITION_FS_HOME="${fs}" | ||
179 | ;; | ||
180 | /tmp) | ||
181 | export PARTITION_DISK_TMP="${disk}" | ||
182 | export PARTITION_FS_TMP="${fs}" | ||
183 | ;; | ||
184 | /usr) | ||
185 | export PARTITION_DISK_USER="${disk}" | ||
186 | export PARTITION_FS_USER="${fs}" | ||
187 | ;; | ||
188 | /var) | ||
189 | export PARTITION_DISK_VAR="${disk}" | ||
190 | export PARTITION_FS_VAR="${fs}" | ||
191 | ;; | ||
192 | /svr) | ||
193 | export PARTITION_DISK_SVR="${disk}" | ||
194 | export PARTITION_FS_SVR="${fs}" | ||
195 | ;; | ||
196 | /opt) | ||
197 | export PARTITION_DISK_OPT="${disk}" | ||
198 | export PARTITION_FS_OPT="${fs}" | ||
199 | ;; | ||
200 | niro | 764 | swap) |
201 | export PARTITION_DISK_SWAP="${disk}" | ||
202 | export PARTITION_FS_SWAP="swap" | ||
203 | ;; | ||
204 | niro | 719 | esac |
205 | done | ||
206 | |||
207 | case ${EXIT} in | ||
208 | abort) | ||
209 | echo "Aborted by user." | ||
210 | exit 1 | ||
211 | ;; | ||
212 | back) | ||
213 | # placeholder | ||
214 | return 1 | ||
215 | ;; | ||
216 | next) | ||
217 | if [[ -z ${PARTITION_DISK_ROOT} ]] || [[ -z ${PARTITION_DISK_SWAP} ]] | ||
218 | then | ||
219 | FAILURE_MESSAGE="You must at least select root (/) and a swap (SWAP) partition!" \ | ||
220 | rundialog FAILURE_DIALOG | ||
221 | rundialog_partition_drive_list | ||
222 | fi | ||
223 | ;; | ||
224 | edit) | ||
225 | # a partition without a number must be the disk | ||
226 | if [[ ${SELECTED_DISK/[0-9]/} = ${SELECTED_DISK} ]] | ||
227 | then | ||
228 | ${sudo} gparted ${SELECTED_DISK} | ||
229 | rundialog_partition_drive_list | ||
230 | else | ||
231 | rundialog_setup_partition | ||
232 | fi | ||
233 | ;; | ||
234 | esac | ||
235 | } | ||
236 | |||
237 | rundialog_setup_partition() | ||
238 | { | ||
239 | rundialog SETUP_PARTITION | ||
240 | |||
241 | # delete stanza | ||
242 | query_partition_disk_setup --delete "${SELECTED_DISK}" | ||
243 | # set the new | ||
244 | export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP} ${SELECTED_DISK}:${FILESYSTEM}:${MOUNTPOINT}" | ||
245 | |||
246 | rundialog_partition_drive_list | ||
247 | } | ||
248 | |||
249 | # needed to be available in the gtk-dialog | ||
250 | export -f rundialog_setup_partition | ||
251 | |||
252 | main_diskpartition() | ||
253 | { | ||
254 | rundialog_partition_drive_list | ||
255 | |||
256 | # export all variables | ||
257 | export PARTITION_DISK_SETUP | ||
258 | export PARTITION_FS_SETUP | ||
259 | export PARTITION_DISK_ROOT | ||
260 | export PARTITION_FS_ROOT | ||
261 | export PARTITION_DISK_BOOT | ||
262 | export PARTITION_FS_BOOT | ||
263 | export PARTITION_DISK_HOME | ||
264 | export PARTITION_FS_HOME | ||
265 | export PARTITION_DISK_TMP | ||
266 | export PARTITION_FS_TMP | ||
267 | export PARTITION_DISK_USER | ||
268 | export PARTITION_FS_USER | ||
269 | export PARTITION_DISK_VAR | ||
270 | export PARTITION_FS_VAR | ||
271 | export PARTITION_DISK_SVR | ||
272 | export PARTITION_FS_SVR | ||
273 | export PARTITION_DISK_OPT | ||
274 | export PARTITION_FS_OPT | ||
275 | export PARTITION_DISK_SWAP | ||
276 | niro | 764 | export PARTITION_FS_SWAP |
277 | niro | 719 | } |