Magellan Linux

Contents of /trunk/installer/gtk-gui/diskpartition.sh

Parent Directory Parent Directory | Revision Log Revision Log


Revision 719 - (show annotations) (download) (as text)
Fri Apr 18 20:40:28 2008 UTC (16 years ago) by niro
File MIME type: application/x-sh
File size: 6042 byte(s)
-first import

1 # $Header: /home/cvsd/magellan-cvs/magellan-src/installer/gtk-gui/diskpartition.sh,v 1.1 2008-04-18 20:40:28 niro Exp $
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>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>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>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>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 swap) export PARTITION_DISK_SWAP="${disk}" ;;
201 esac
202 done
203
204 case ${EXIT} in
205 abort)
206 echo "Aborted by user."
207 exit 1
208 ;;
209 back)
210 # placeholder
211 return 1
212 ;;
213 next)
214 if [[ -z ${PARTITION_DISK_ROOT} ]] || [[ -z ${PARTITION_DISK_SWAP} ]]
215 then
216 FAILURE_MESSAGE="You must at least select root (/) and a swap (SWAP) partition!" \
217 rundialog FAILURE_DIALOG
218 rundialog_partition_drive_list
219 fi
220 ;;
221 edit)
222 # a partition without a number must be the disk
223 if [[ ${SELECTED_DISK/[0-9]/} = ${SELECTED_DISK} ]]
224 then
225 ${sudo} gparted ${SELECTED_DISK}
226 rundialog_partition_drive_list
227 else
228 rundialog_setup_partition
229 fi
230 ;;
231 esac
232 }
233
234 rundialog_setup_partition()
235 {
236 rundialog SETUP_PARTITION
237
238 # delete stanza
239 query_partition_disk_setup --delete "${SELECTED_DISK}"
240 # set the new
241 export PARTITION_DISK_SETUP="${PARTITION_DISK_SETUP} ${SELECTED_DISK}:${FILESYSTEM}:${MOUNTPOINT}"
242
243 rundialog_partition_drive_list
244 }
245
246 # needed to be available in the gtk-dialog
247 export -f rundialog_setup_partition
248
249 main_diskpartition()
250 {
251 rundialog_partition_drive_list
252
253 # export all variables
254 export PARTITION_DISK_SETUP
255 export PARTITION_FS_SETUP
256 export PARTITION_DISK_ROOT
257 export PARTITION_FS_ROOT
258 export PARTITION_DISK_BOOT
259 export PARTITION_FS_BOOT
260 export PARTITION_DISK_HOME
261 export PARTITION_FS_HOME
262 export PARTITION_DISK_TMP
263 export PARTITION_FS_TMP
264 export PARTITION_DISK_USER
265 export PARTITION_FS_USER
266 export PARTITION_DISK_VAR
267 export PARTITION_FS_VAR
268 export PARTITION_DISK_SVR
269 export PARTITION_FS_SVR
270 export PARTITION_DISK_OPT
271 export PARTITION_FS_OPT
272 export PARTITION_DISK_SWAP
273 }