rev |
line source |
domcox@0
|
1 #!/bin/sh
|
domcox@0
|
2 #
|
domcox@0
|
3 # Main CGI interface for Tazinst, the SliTaz installer.
|
domcox@0
|
4 #
|
domcox@17
|
5 # Copyright (C) 2012-2014 SliTaz GNU/Linux - BSD License
|
domcox@0
|
6 #
|
domcox@0
|
7 # Authors : Dominique Corbex <domcox@slitaz.org>
|
domcox@0
|
8 #
|
domcox@0
|
9
|
domcox@0
|
10
|
domcox@2
|
11 # restricted path
|
domcox@2
|
12 PATH="/usr/sbin:/usr/bin:/sbin:/bin"
|
domcox@0
|
13
|
domcox@19
|
14 VERSION=3.92
|
domcox@2
|
15
|
domcox@13
|
16 # Common functions from libtazpanel
|
domcox@13
|
17 . lib/libtazpanel
|
domcox@13
|
18 get_config
|
domcox@2
|
19
|
domcox@13
|
20 TITLE=$(gettext 'TazPanel - Installer')
|
domcox@0
|
21
|
domcox@2
|
22 # export package name for gettext.
|
domcox@2
|
23 TEXTDOMAIN='installer'
|
domcox@2
|
24 export TEXTDOMAIN
|
domcox@0
|
25
|
domcox@2
|
26 # tazinst required version
|
domcox@2
|
27 TAZINST_MINIMUM_VERSION="3.8"
|
domcox@2
|
28 TAZINST_MAXIMUM_VERSION="4.99"
|
domcox@0
|
29
|
domcox@2
|
30 # tazinst setup file
|
domcox@2
|
31 INSTFILE=/root/tazinst.conf
|
domcox@0
|
32
|
pascal@22
|
33 #------
|
pascal@22
|
34 # menu
|
pascal@22
|
35 #------
|
pascal@22
|
36 case "$1" in
|
pascal@22
|
37 menu) [ "$REMOTE_USER" == "root" ] && cat << EOT
|
pascal@22
|
38 <li><a href="/installer.cgi">$(gettext 'Install')</a>
|
pascal@22
|
39 <ul>
|
pascal@22
|
40 <li><a href="/installer.cgi?page=menu_install"><img
|
pascal@22
|
41 src="/styles/default/images/tux.png" />$(gettext 'Install SliTaz')</a></li>
|
pascal@22
|
42 <li><a href="/installer.cgi?page=menu_upgrade"><img
|
pascal@22
|
43 src="/styles/default/images/recharge.png" />$(gettext 'Upgrade system')</a></li>
|
pascal@22
|
44 </ul>
|
pascal@22
|
45 </li>
|
pascal@22
|
46 EOT
|
pascal@22
|
47 exit
|
pascal@22
|
48 esac
|
domcox@0
|
49
|
domcox@2
|
50 #-----------
|
domcox@2
|
51 # home page
|
domcox@2
|
52 #-----------
|
domcox@0
|
53
|
domcox@0
|
54 select_action()
|
domcox@0
|
55 {
|
domcox@13
|
56 comment "Welcome message"
|
domcox@13
|
57 open_div 'id="wrapper"'
|
domcox@13
|
58 h4 "$(gettext "Welcome to the Slitaz Installer!")"
|
domcox@13
|
59 p "$(gettext "The SliTaz Installer installs or upgrades SliTaz to a \
|
al@6
|
60 hard disk drive from a device like a Live-CD or LiveUSB key, from a SliTaz \
|
domcox@13
|
61 ISO file, or from the web by downloading an ISO file.")"
|
domcox@13
|
62 h5 "$(gettext "Which type of installation do you want to start?")"
|
domcox@2
|
63 close_div
|
domcox@0
|
64 }
|
domcox@0
|
65
|
domcox@0
|
66 select_install()
|
domcox@0
|
67 {
|
domcox@13
|
68 comment "Install message"
|
domcox@13
|
69 open_div 'class="box"'
|
domcox@13
|
70 h4 "$(gettext 'Install')"
|
domcox@13
|
71 p "$(gettext "Install SliTaz on a partition of your hard disk drive. If \
|
domcox@13
|
72 you decide to format your partition, all data will be lost. If you do not \
|
paul@16
|
73 format, all data except for any existing /home directory will be removed \
|
paul@16
|
74 (the home directory will be kept as is).")"
|
domcox@13
|
75 p "$(gettext "Before installation, you may need to create or resize \
|
al@6
|
76 partitions on your hard disk drive in order to make space for SliTaz \
|
domcox@13
|
77 GNU/Linux. You can graphically manage your partitions with Gparted")"
|
domcox@2
|
78 close_div
|
al@6
|
79 button "install" \
|
al@6
|
80 "$(gettext 'Install SliTaz')" \
|
al@6
|
81 "$(gettext 'Proceed to a new SliTaz installation')"
|
domcox@0
|
82 }
|
domcox@0
|
83
|
domcox@0
|
84 select_upgrade()
|
domcox@0
|
85 {
|
domcox@13
|
86 comment "Upgrade message"
|
domcox@13
|
87 open_div 'class="box"'
|
domcox@13
|
88 h4 "$(gettext 'Upgrade')"
|
domcox@13
|
89 p "$(gettext "Upgrade an already installed SliTaz system on your hard disk \
|
al@6
|
90 drive. Your /home /etc /var/www directories will be kept, all other \
|
al@6
|
91 directories will be removed. Any additional packages added to your old \
|
domcox@13
|
92 Slitaz system will be updated as long you have an active internet connection.")"
|
domcox@2
|
93 close_div
|
al@6
|
94 button "upgrade" \
|
al@6
|
95 "$(gettext 'Upgrade SliTaz')" \
|
al@6
|
96 "$(gettext 'Upgrade an existing SliTaz system')"
|
domcox@2
|
97 }
|
domcox@0
|
98
|
domcox@2
|
99 #--------------------
|
domcox@2
|
100 # partitionning page
|
domcox@2
|
101 #--------------------
|
domcox@0
|
102
|
domcox@2
|
103 exec_gparted()
|
domcox@2
|
104 {
|
domcox@13
|
105 /bin/su - -c \
|
domcox@13
|
106 "exec env DISPLAY=':0.0' XAUTHORITY='/var/run/slim.auth' /usr/sbin/gparted"
|
domcox@0
|
107 }
|
domcox@0
|
108
|
domcox@0
|
109 select_gparted()
|
domcox@0
|
110 {
|
domcox@13
|
111 comment "GParted message"
|
domcox@13
|
112 h5 "$(gettext "Partitioning")"
|
domcox@13
|
113 open_div 'class="box"'
|
domcox@13
|
114 p "$(gettext "On most used systems, the hard drive is already dedicated to \
|
al@6
|
115 partitions for Windows<sup>™</sup>, or Linux, or another operating \
|
al@6
|
116 system. You'll need to resize these partitions in order to make space for \
|
al@6
|
117 SliTaz GNU/Linux. SliTaz will co-exist with other operating systems already \
|
domcox@13
|
118 installed on your hard drive.")"
|
domcox@13
|
119 p "$(gettext "The amount of space needed depends on how much software you \
|
al@6
|
120 plan to install and how much space you require for users. It's conceivable \
|
al@6
|
121 that you could run a minimal SliTaz system in 300 megs or less, but 2 gigs \
|
domcox@13
|
122 is indeed more comfy.")"
|
domcox@13
|
123 p "$(gettext "A separate home partition, and a partition that will be used \
|
al@6
|
124 as Linux swap space may be created if needed. Slitaz detects and uses swap \
|
domcox@13
|
125 partitions automatically.")"
|
domcox@2
|
126 close_div
|
domcox@13
|
127 open_div 'class="box"'
|
domcox@13
|
128 p "$(gettext "You can graphically manage your partitions with GParted. \
|
al@6
|
129 GParted is a partition editor for graphically managing your disk partitions. \
|
al@6
|
130 GParted allows you to create, destroy, resize and copy partitions without \
|
domcox@13
|
131 data loss.")"
|
domcox@13
|
132 p "$(gettext "GParted supports ext2, ext3, ext4, linux swap, ntfs and \
|
domcox@13
|
133 fat32 filesystems right out of the box. Support for xjs, jfs, hfs and other \
|
al@6
|
134 filesystems is available as well but you first need to add drivers for these \
|
al@6
|
135 filesystems by installing the related packages xfsprogs, jfsutils, linux-hfs \
|
domcox@13
|
136 and so on.")"
|
domcox@2
|
137 close_div
|
domcox@13
|
138 comment "Launch GParted"
|
al@6
|
139 button "gparted" \
|
al@6
|
140 "$(gettext 'Execute GParted')" \
|
al@6
|
141 "$(gettext 'Launch GParted, the partition editor tool')"
|
domcox@13
|
142 h5 "$(gettext "Continue installation")"
|
domcox@13
|
143 p "$(gettext "Once you've made room for SliTaz on your drive, you should \
|
domcox@13
|
144 be able to continue installation.")"
|
domcox@0
|
145 }
|
domcox@0
|
146
|
domcox@2
|
147 #------------
|
domcox@2
|
148 # input page
|
domcox@2
|
149 #------------
|
domcox@2
|
150
|
domcox@2
|
151
|
domcox@2
|
152 select_source()
|
domcox@0
|
153 {
|
domcox@2
|
154 local media="$(/usr/sbin/tazinst get media "$INSTFILE")"
|
domcox@2
|
155 local source="$(/usr/sbin/tazinst get source "$INSTFILE")"
|
domcox@2
|
156 local list_media="$(/usr/sbin/tazinst list media)"
|
domcox@13
|
157 local error
|
domcox@2
|
158
|
domcox@13
|
159 # set default media
|
domcox@2
|
160 [ "$media" ] || media="$(tazinst list media | cut -d ' ' -f1)"
|
domcox@13
|
161
|
domcox@13
|
162 comment "Source selection"
|
domcox@2
|
163 # cdrom
|
domcox@13
|
164 if printf '%s' "$list_media" | grep -q "cdrom"; then
|
al@6
|
165 input_media "cdrom" \
|
al@6
|
166 "$media"
|
al@6
|
167 label_media "cdrom" \
|
al@6
|
168 "$(gettext 'LiveCD')" \
|
al@6
|
169 "$media" \
|
al@6
|
170 "$(gettext 'Use the SliTaz LiveCD')"
|
domcox@2
|
171 br
|
domcox@2
|
172 fi
|
domcox@2
|
173 # usb
|
domcox@13
|
174 if printf '%s' "$list_media" | grep -q "usb"; then
|
al@6
|
175 input_media "usb" \
|
al@6
|
176 "$media"
|
al@6
|
177 label_media "usb" \
|
al@6
|
178 "$(gettext 'LiveUSB:')" \
|
al@6
|
179 "$media" \
|
domcox@13
|
180 "$(gettext 'Enter the partition where SliTaz Live is located on
|
domcox@13
|
181 your USB Key')"
|
domcox@2
|
182 error="$?"
|
domcox@19
|
183 select "$(/usr/sbin/tazinst list usb "$INSTFILE" | cut -d' ' -f2)" \
|
al@6
|
184 "$source" \
|
al@6
|
185 "SRC_USB"
|
al@6
|
186 error_msg "$error" \
|
al@6
|
187 "source" \
|
al@6
|
188 2
|
domcox@2
|
189 br
|
domcox@2
|
190 fi
|
domcox@2
|
191 # iso
|
al@6
|
192 input_media "iso" \
|
al@6
|
193 "$media"
|
al@6
|
194 label_media "iso" \
|
al@6
|
195 "$(gettext 'ISO file:')" \
|
al@6
|
196 "$media" \
|
al@6
|
197 "$(gettext 'Select a SliTaz ISO file located on a local disk')"
|
domcox@2
|
198 error="$?"
|
domcox@2
|
199 if [ "$media" == "iso" ]; then
|
al@6
|
200 input "text" \
|
al@6
|
201 "src_iso" \
|
al@6
|
202 "$source" "" \
|
domcox@13
|
203 "$(gettext 'Select an ISO or enter the full path to the ISO file')"\
|
domcox@2
|
204 "iso"
|
domcox@2
|
205 else
|
al@6
|
206 input "text" \
|
al@6
|
207 "src_iso" \
|
al@6
|
208 "" \
|
al@6
|
209 "none" \
|
domcox@13
|
210 "$(gettext 'Select an ISO or enter the full path to the ISO file')"\
|
domcox@2
|
211 "iso"
|
domcox@2
|
212 fi
|
al@6
|
213 datalist "$(/usr/sbin/tazinst list iso "$INSTFILE")" \
|
al@6
|
214 "src_iso"
|
al@6
|
215 error_msg "$error" \
|
al@6
|
216 "source"
|
domcox@2
|
217 br
|
domcox@2
|
218 # web
|
al@6
|
219 input_media "web" \
|
al@6
|
220 "$media"
|
al@6
|
221 label_media "web" \
|
al@6
|
222 "$(gettext 'Web:')" \
|
al@6
|
223 "$media" \
|
al@6
|
224 "$(gettext 'Select a SliTaz version on the Web')"
|
domcox@2
|
225 error="$?"
|
domcox@2
|
226
|
domcox@2
|
227 if [ "$media" == "web" ]; then
|
al@6
|
228 input "text" \
|
al@6
|
229 "src_web" \
|
al@6
|
230 "$source" "" \
|
domcox@13
|
231 "$(gettext 'Select a version or enter the full url to an ISO file')"\
|
domcox@2
|
232 "web"
|
domcox@2
|
233 else
|
al@6
|
234 input "text" \
|
al@6
|
235 "src_web" \
|
al@6
|
236 "" \
|
al@6
|
237 "none" \
|
domcox@13
|
238 "$(gettext 'Select a version or enter the full url to an ISO file')"\
|
domcox@2
|
239 "web"
|
domcox@2
|
240 fi
|
al@6
|
241 datalist "$(/usr/sbin/tazinst help web "$INSTFILE")" \
|
al@6
|
242 "src_web"
|
al@6
|
243 error_msg "$error" \
|
al@6
|
244 "source"
|
domcox@2
|
245 }
|
domcox@2
|
246
|
domcox@2
|
247 select_root_uuid()
|
domcox@2
|
248 {
|
domcox@2
|
249 local root_uuid="$(/usr/sbin/tazinst get root_uuid "$INSTFILE")"
|
domcox@2
|
250 local mode="$(/usr/sbin/tazinst get mode "$INSTFILE")"
|
domcox@2
|
251 comment "root_uuid selection"
|
domcox@2
|
252 if [ "$mode" == "upgrade" ]; then
|
al@6
|
253 label "root_uuid" \
|
al@6
|
254 "$(gettext 'Existing SliTaz partition to upgrade:')" \
|
al@6
|
255 "$(gettext 'Specify the partition containing the system to upgrade')"
|
domcox@2
|
256 error="$?"
|
domcox@2
|
257 else
|
al@6
|
258 label "root_uuid" \
|
al@6
|
259 "$(gettext 'Install Slitaz to partition:')" \
|
al@6
|
260 "$(gettext 'Specify the partition where to install SliTaz')"
|
domcox@2
|
261 error="$?"
|
domcox@2
|
262 fi
|
al@6
|
263 select "$(/usr/sbin/tazinst list uuid "$INSTFILE")" \
|
al@6
|
264 "$root_uuid" \
|
al@6
|
265 "ROOT_UUID" \
|
al@6
|
266 2
|
al@6
|
267 error_msg "$error" \
|
al@6
|
268 "root_uuid" \
|
al@6
|
269 2
|
domcox@2
|
270 br
|
domcox@2
|
271 }
|
domcox@2
|
272
|
domcox@2
|
273 select_root_format()
|
domcox@2
|
274 {
|
domcox@2
|
275 local root_format="$(/usr/sbin/tazinst get root_format "$INSTFILE")"
|
domcox@2
|
276 comment "root_format selection"
|
al@6
|
277 format "$(/usr/sbin/tazinst list format "$INSTFILE")" \
|
al@6
|
278 "$root_format" \
|
al@6
|
279 "ROOT_FORMAT"
|
domcox@2
|
280 }
|
domcox@2
|
281
|
domcox@2
|
282 select_options()
|
domcox@2
|
283 {
|
domcox@13
|
284 printf '<h4 id="options">%s</h4>' "$(gettext 'Options')"
|
domcox@2
|
285 }
|
domcox@2
|
286
|
domcox@2
|
287 select_home_uuid()
|
domcox@2
|
288 {
|
domcox@2
|
289 local home_uuid="$(/usr/sbin/tazinst get home_uuid "$INSTFILE")"
|
domcox@2
|
290 comment "home_uuid selection"
|
domcox@19
|
291 h5 "$(gettext "home partition")"
|
al@6
|
292 label "home_uuid" \
|
al@6
|
293 "$(gettext 'Separate partition for /home:')" \
|
al@6
|
294 "$(gettext 'Specify the partition containing /home')"
|
al@6
|
295 select "$(/usr/sbin/tazinst list uuid "$INSTFILE")" \
|
al@6
|
296 "$home_uuid" \
|
al@6
|
297 "HOME_UUID" \
|
al@6
|
298 2
|
domcox@2
|
299 br
|
domcox@2
|
300 }
|
domcox@2
|
301
|
domcox@2
|
302 select_home_format()
|
domcox@2
|
303 {
|
domcox@2
|
304 local home_format="$(/usr/sbin/tazinst get home_format "$INSTFILE")"
|
domcox@2
|
305 comment "home_format selection"
|
al@6
|
306 format "$(/usr/sbin/tazinst list format "$INSTFILE")" \
|
al@6
|
307 "$home_format" \
|
al@6
|
308 "HOME_FORMAT"
|
domcox@2
|
309 }
|
domcox@2
|
310
|
domcox@2
|
311 select_hostname()
|
domcox@2
|
312 {
|
domcox@2
|
313 local hostname="$(/usr/sbin/tazinst get hostname "$INSTFILE")" error
|
domcox@2
|
314 comment "hostname selection"
|
domcox@19
|
315 h5 "$(gettext "Hostname")"
|
al@6
|
316 label "hostname" \
|
al@6
|
317 "$(gettext 'Set Hostname to:')" \
|
al@6
|
318 "$(gettext 'Hostname configuration allows you to specify the machine name')"
|
domcox@2
|
319 error=$?
|
al@6
|
320 input "text" \
|
al@6
|
321 "HOSTNAME" \
|
al@6
|
322 "$hostname" \
|
al@6
|
323 "" \
|
al@6
|
324 "$(gettext 'Name of your system')"
|
al@6
|
325 error_msg "$error" \
|
al@6
|
326 "hostname" \
|
al@6
|
327 2
|
domcox@2
|
328 }
|
domcox@2
|
329
|
domcox@2
|
330 select_root_pwd()
|
domcox@2
|
331 {
|
domcox@2
|
332 local root_pwd="$(/usr/sbin/tazinst get root_pwd "$INSTFILE")" error
|
domcox@2
|
333 comment "root_pwd selection"
|
domcox@19
|
334 h5 "$(gettext "Root superuser")"
|
al@6
|
335 label "root_pwd" \
|
al@6
|
336 "$(gettext 'Root passwd:')" \
|
al@6
|
337 "$(gettext 'Enter the password for root')"
|
domcox@2
|
338 error="$?"
|
al@6
|
339 input "text" \
|
al@6
|
340 "ROOT_PWD" \
|
al@6
|
341 "$root_pwd" \
|
al@6
|
342 "" \
|
al@6
|
343 "$(gettext 'Password of root')"
|
al@6
|
344 error_msg "$error" \
|
al@6
|
345 "root_pwd"
|
domcox@2
|
346 }
|
domcox@2
|
347
|
domcox@2
|
348 select_user_login()
|
domcox@2
|
349 {
|
domcox@2
|
350 local user_login="$(/usr/sbin/tazinst get user_login "$INSTFILE")" error
|
domcox@2
|
351 comment "user_login selection"
|
domcox@19
|
352 h5 "$(gettext "User")"
|
al@6
|
353 label "user_login" \
|
al@6
|
354 "$(gettext 'User login:')" \
|
al@6
|
355 "$(gettext 'Enter the name of the first user')"
|
domcox@2
|
356 error="$?"
|
al@6
|
357 input "text" \
|
al@6
|
358 "USER_LOGIN" \
|
al@6
|
359 "$user_login" \
|
al@6
|
360 "" \
|
domcox@2
|
361 "$(gettext 'Name of the first user')"
|
al@6
|
362 error_msg "$error" \
|
al@6
|
363 "user_login" \
|
al@6
|
364 2
|
domcox@2
|
365 br
|
domcox@2
|
366 }
|
domcox@2
|
367
|
domcox@2
|
368 select_user_pwd()
|
domcox@2
|
369 {
|
domcox@2
|
370 local user_pwd="$(/usr/sbin/tazinst get user_pwd "$INSTFILE")" error
|
al@6
|
371 label "user_pwd" \
|
al@6
|
372 "$(gettext 'User passwd:')" \
|
al@6
|
373 "$(gettext 'The password for default user')"
|
domcox@2
|
374 error="$?"
|
al@6
|
375 input "text" \
|
al@6
|
376 "USER_PWD" \
|
al@6
|
377 "$user_pwd" \
|
al@6
|
378 "" \
|
domcox@2
|
379 "$(gettext 'Password of the first user')"
|
al@6
|
380 error_msg "$error" \
|
al@6
|
381 "user_pwd"
|
domcox@2
|
382 }
|
domcox@2
|
383
|
domcox@2
|
384 select_bootloader()
|
domcox@2
|
385 {
|
domcox@2
|
386 local bootloader="$(/usr/sbin/tazinst get bootloader "$INSTFILE")" error
|
domcox@2
|
387 comment "bootloader selection"
|
domcox@19
|
388 h5 "$(gettext "Bootloader")"
|
al@6
|
389 input "checkbox" \
|
al@6
|
390 "bootloader" \
|
al@6
|
391 "auto" \
|
al@6
|
392 "$bootloader"
|
al@6
|
393 label "bootloader" \
|
al@6
|
394 "$(gettext 'Install a bootloader.')" \
|
domcox@13
|
395 "$(gettext "Usually you should answer yes, unless you want to install \
|
domcox@13
|
396 a bootloader by hand yourself.")"
|
domcox@2
|
397 error="$?"
|
al@6
|
398 error_msg "$error" \
|
al@6
|
399 "bootloader"
|
domcox@2
|
400 br
|
domcox@2
|
401 }
|
domcox@2
|
402
|
domcox@2
|
403 select_winboot()
|
domcox@2
|
404 {
|
domcox@2
|
405 local winboot="$(/usr/sbin/tazinst get winboot "$INSTFILE")" error
|
domcox@2
|
406 comment "winboot selection"
|
al@6
|
407 input "checkbox" \
|
al@6
|
408 "winboot" \
|
al@6
|
409 "auto" \
|
al@6
|
410 "$winboot"
|
al@6
|
411 label "winboot" \
|
al@6
|
412 "$(gettext 'Enable Windows Dual-Boot.')" \
|
domcox@13
|
413 "$(gettext "At start-up, you will be asked whether you want to boot \
|
domcox@13
|
414 into Windows™ or SliTaz GNU/Linux.")"
|
domcox@2
|
415 error="$?"
|
al@6
|
416 error_msg "$error" \
|
al@6
|
417 "winboot"
|
domcox@2
|
418 }
|
domcox@2
|
419
|
domcox@2
|
420 errors_msg()
|
domcox@2
|
421 {
|
domcox@2
|
422 if [ "$CHECK" ]; then
|
domcox@13
|
423 echo '<span class="alert">'
|
al@6
|
424 p $(gettext "Errors found. Please check your settings.")
|
domcox@13
|
425 echo '</span>'
|
domcox@2
|
426 fi
|
domcox@2
|
427 }
|
domcox@2
|
428
|
domcox@2
|
429 select_settings()
|
domcox@2
|
430 {
|
domcox@2
|
431 local settings="$(/usr/sbin/tazinst get settings "$INSTFILE")"
|
domcox@2
|
432 CHECK=$(GET CHECK)
|
domcox@2
|
433 errors_msg
|
domcox@13
|
434 h4 "$(gettext "Select source media:")"
|
domcox@13
|
435 open_div 'class="box"'
|
domcox@13
|
436 open_div 'class="media"'
|
domcox@2
|
437 select_source
|
domcox@2
|
438 close_div
|
domcox@2
|
439 close_div
|
domcox@13
|
440 h4 "$(gettext "Select destination")"
|
domcox@13
|
441 open_div 'class="box"'
|
domcox@2
|
442 select_root_uuid
|
domcox@13
|
443 printf '%s' "$settings" | grep -q "root_format" \
|
domcox@2
|
444 && select_root_format
|
domcox@2
|
445 close_div
|
domcox@2
|
446 select_options
|
domcox@13
|
447 open_div 'class="options"'
|
domcox@13
|
448 printf '%s' "$settings" | grep -q "home_uuid" && select_home_uuid
|
domcox@13
|
449 printf '%s' "$settings" | grep -q "home_format" \
|
domcox@2
|
450 && select_home_format
|
domcox@13
|
451 printf '%s' "$settings" | grep -q "hostname" && select_hostname
|
domcox@13
|
452 printf '%s' "$settings" | grep -q "root_pwd" && select_root_pwd
|
domcox@13
|
453 printf '%s' "$settings" | grep -q "user_login" && select_user_login
|
domcox@13
|
454 printf '%s' "$settings" | grep -q "user_pwd" && select_user_pwd
|
domcox@2
|
455 close_div
|
domcox@13
|
456 open_div 'class="bootloader"'
|
domcox@13
|
457 printf '%s' "$settings" | grep -q "bootloader" && select_bootloader
|
domcox@13
|
458 printf '%s' "$settings" | grep -q "winboot" && select_winboot
|
domcox@2
|
459 close_div
|
domcox@2
|
460 br
|
domcox@2
|
461 }
|
domcox@2
|
462
|
domcox@2
|
463 #--------------
|
domcox@2
|
464 # execute page
|
domcox@2
|
465 #--------------
|
domcox@2
|
466
|
domcox@2
|
467 save_settings()
|
domcox@2
|
468 {
|
domcox@19
|
469 h5 "$(gettext "Checking settings...")"
|
domcox@2
|
470 # install type
|
domcox@2
|
471 /usr/sbin/tazinst set media "$(GET MEDIA)" "$INSTFILE"
|
domcox@2
|
472 # source File
|
domcox@2
|
473 case "$(/usr/sbin/tazinst get media "$INSTFILE")" in
|
domcox@2
|
474 usb)
|
domcox@2
|
475 /usr/sbin/tazinst set source "$(GET SRC_USB)" "$INSTFILE" ;;
|
domcox@2
|
476 iso)
|
domcox@2
|
477 /usr/sbin/tazinst set source "$(GET SRC_ISO)" "$INSTFILE" ;;
|
domcox@2
|
478 web)
|
domcox@2
|
479 /usr/sbin/tazinst set source "$(GET SRC_WEB)" "$INSTFILE" ;;
|
domcox@2
|
480 esac
|
domcox@2
|
481 # set defined url
|
domcox@2
|
482 [ $(GET URL) ] && SRC_WEB=$(GET URL)
|
domcox@2
|
483 # root Partition
|
domcox@2
|
484 /usr/sbin/tazinst set root_uuid "$(GET ROOT_UUID)" "$INSTFILE"
|
domcox@2
|
485 # format root partition
|
domcox@2
|
486 [ "$(GET ROOT_FORMAT)" ] \
|
domcox@2
|
487 && /usr/sbin/tazinst set root_format "$(GET ROOT_FORMAT)" "$INSTFILE" \
|
domcox@2
|
488 || /usr/sbin/tazinst unset root_format "$INSTFILE"
|
domcox@2
|
489 # home Partition
|
domcox@2
|
490 if [ "$(GET HOME_UUID)" ] ; then
|
domcox@2
|
491 /usr/sbin/tazinst set home_uuid "$(GET HOME_UUID)" "$INSTFILE"
|
domcox@2
|
492 [ "$(GET HOME_FORMAT)" ] \
|
domcox@2
|
493 && /usr/sbin/tazinst set home_format "$(GET HOME_FORMAT)" \
|
domcox@2
|
494 "$INSTFILE" \
|
domcox@2
|
495 || /usr/sbin/tazinst unset home_format "$INSTFILE"
|
domcox@2
|
496 else
|
domcox@2
|
497 /usr/sbin/tazinst unset home_uuid "$INSTFILE"
|
domcox@2
|
498 /usr/sbin/tazinst unset home_format "$INSTFILE"
|
domcox@2
|
499 fi
|
domcox@2
|
500 # hostname
|
domcox@2
|
501 /usr/sbin/tazinst set hostname "$(GET HOSTNAME)" "$INSTFILE"
|
domcox@2
|
502 # root pwd
|
domcox@2
|
503 /usr/sbin/tazinst set root_pwd "$(GET ROOT_PWD)" "$INSTFILE"
|
domcox@2
|
504 # user Login
|
domcox@2
|
505 /usr/sbin/tazinst set user_login "$(GET USER_LOGIN)" "$INSTFILE"
|
domcox@2
|
506 # user Pwd
|
domcox@2
|
507 /usr/sbin/tazinst set user_pwd "$(GET USER_PWD)" "$INSTFILE"
|
domcox@2
|
508 # win Dual-Boot
|
domcox@2
|
509 /usr/sbin/tazinst set winboot "$(GET WINBOOT)" "$INSTFILE"
|
domcox@2
|
510 # bootloader
|
domcox@2
|
511 if [ "$(GET BOOTLOADER)" == "auto" ]; then
|
domcox@2
|
512 /usr/sbin/tazinst set bootloader "auto" "$INSTFILE"
|
domcox@2
|
513 else
|
domcox@2
|
514 /usr/sbin/tazinst unset bootloader "$INSTFILE"
|
domcox@2
|
515 /usr/sbin/tazinst unset winboot "$INSTFILE"
|
domcox@2
|
516 fi
|
domcox@2
|
517 input_hidden "CHECK" "yes"
|
domcox@2
|
518 }
|
domcox@2
|
519
|
domcox@2
|
520 tazinst_run()
|
domcox@2
|
521 {
|
domcox@2
|
522 local mode="$(/usr/sbin/tazinst get mode "$INSTFILE")" error
|
domcox@2
|
523 h4 "Proceeding to: $mode"
|
domcox@2
|
524 /usr/sbin/tazinst execute "$INSTFILE" | /bin/busybox awk '{
|
domcox@2
|
525 num=$1+0
|
domcox@2
|
526 if (num>0 && num<=100){
|
domcox@2
|
527 print "<script type=\"text/javascript\">"
|
domcox@2
|
528 printf "document.write(\047<div id=\"progress\">"
|
domcox@2
|
529 printf "<img src=\"/styles/default/images/loader.gif\" />"
|
domcox@2
|
530 printf $1 "% " substr($0, length($1)+2, 40)
|
domcox@2
|
531 print "</div>\047)"
|
domcox@2
|
532 print "</script>"
|
domcox@2
|
533 }
|
domcox@2
|
534 }'
|
domcox@2
|
535 # end_of_install
|
domcox@2
|
536 if /usr/sbin/tazinst log | grep -q "x-x-" ; then
|
domcox@2
|
537 error=1
|
domcox@2
|
538 echo "<script type=\"text/javascript\">"
|
domcox@2
|
539 printf "document.write(\047<div id=\"progress\">"
|
domcox@2
|
540 printf "<img src=\"/styles/default/images/stop.png\" />"
|
al@6
|
541 printf "$(gettext 'Errors encountered.')"
|
domcox@2
|
542 printf "</div>\047)\n"
|
domcox@2
|
543 echo "</script>"
|
domcox@2
|
544 br
|
domcox@2
|
545 br
|
domcox@2
|
546 /usr/sbin/tazinst log | \
|
domcox@2
|
547 /bin/busybox awk '$1 == "-x-x-",$1 == "x-x-x"' | sed 's/-x-x-/ /' \
|
domcox@2
|
548 | grep -v "x-x-x"
|
domcox@2
|
549 else
|
domcox@2
|
550 error=0
|
domcox@2
|
551 echo "<script type=\"text/javascript\">"
|
domcox@2
|
552 printf "document.write(\047<div id=\"progress\">"
|
domcox@2
|
553 printf "<img src=\"/styles/default/images/tux.png\" />"
|
al@6
|
554 printf "$(gettext 'Process completed!')"
|
domcox@2
|
555 printf "</div>\047)\n"
|
domcox@2
|
556 echo "</script>"
|
domcox@2
|
557 br
|
domcox@2
|
558 br
|
domcox@2
|
559 br
|
al@6
|
560 p $(gettext "Installation is now finished, you can exit the installer \
|
al@6
|
561 or reboot on your new SliTaz GNU/Linux operating system.")
|
domcox@2
|
562 fi
|
domcox@2
|
563 return "$error"
|
domcox@2
|
564
|
domcox@2
|
565 }
|
domcox@2
|
566
|
domcox@2
|
567 tazinst_log()
|
domcox@2
|
568 {
|
domcox@13
|
569 h4 "$(gettext "Tazinst log")"
|
domcox@13
|
570 printf '<pre>%s</pre>' "$(/usr/sbin/tazinst log | sed 's/\%/ percent/g')"
|
domcox@2
|
571 }
|
domcox@2
|
572
|
domcox@2
|
573
|
domcox@2
|
574 #-----------------
|
domcox@2
|
575 # page navigation
|
domcox@2
|
576 #-----------------
|
domcox@2
|
577
|
domcox@2
|
578 display_mode()
|
domcox@2
|
579 {
|
domcox@2
|
580 local mode="$(/usr/sbin/tazinst get mode "$INSTFILE")"
|
domcox@2
|
581 case $mode in
|
domcox@0
|
582 install)
|
domcox@13
|
583 open_div 'id="wrapper"'
|
domcox@13
|
584 h4 "$(gettext "Install SliTaz")"
|
domcox@13
|
585 p "$(gettext "You're going to install SliTaz on a partition of \
|
domcox@13
|
586 your hard disk drive. If you decide to format your HDD, all data will be \
|
al@6
|
587 lost. If you do not format, all data except for any existing /home \
|
paul@16
|
588 directory will be removed (the home directory will be kept as is).")"
|
domcox@2
|
589 close_div
|
domcox@0
|
590 ;;
|
domcox@0
|
591 upgrade)
|
domcox@13
|
592 open_div 'id="wrapper"'
|
domcox@13
|
593 h4 "$(gettext "Upgrade SliTaz")"
|
domcox@13
|
594 p "$(gettext "You're going to upgrade an already installed SliTaz \
|
al@6
|
595 system on your hard disk drive. Your /home /etc /var/www directories \
|
al@6
|
596 will be kept, all other directories will be removed. Any additional \
|
al@6
|
597 packages added to your old Slitaz system will be updated as long you \
|
domcox@13
|
598 have an active internet connection.")"
|
domcox@2
|
599 close_div
|
domcox@0
|
600 ;;
|
domcox@0
|
601 esac
|
domcox@0
|
602 }
|
domcox@0
|
603
|
domcox@2
|
604 moveto_page()
|
domcox@0
|
605 {
|
domcox@13
|
606 local back_page="$1" next_page="$2" back_msg next_msg
|
domcox@13
|
607 case "$back_page" in
|
domcox@2
|
608 partitioning)
|
domcox@2
|
609 back_msg=$(gettext 'Back to partitioning') ;;
|
domcox@2
|
610 input)
|
domcox@2
|
611 back_msg=$(gettext 'Back to entering settings') ;;
|
domcox@2
|
612 *)
|
domcox@2
|
613 back_msg=$(gettext 'Back to Installer Start Page') ;;
|
domcox@2
|
614 esac
|
domcox@13
|
615 case "$next_page" in
|
domcox@2
|
616 execute|run)
|
domcox@2
|
617 next_msg=$(gettext 'Proceed to SliTaz installation') ;;
|
domcox@2
|
618 reboot)
|
domcox@2
|
619 next_msg=$(gettext 'Installation complete. You can now restart') ;;
|
domcox@2
|
620 failed)
|
domcox@2
|
621 next_msg=$(gettext 'Installation failed. See log') ;;
|
domcox@2
|
622 input)
|
domcox@2
|
623 next_msg=$(gettext 'Continue installation.') ;;
|
domcox@2
|
624 *)
|
domcox@2
|
625 next_msg=$(gettext 'Back to Installer Start Page') ;;
|
domcox@2
|
626 esac
|
domcox@2
|
627 hr
|
domcox@13
|
628 input_hidden "page" "$next_page"
|
domcox@13
|
629 a "$back_page" "$back_msg"
|
al@6
|
630 input "submit" \
|
al@6
|
631 "" \
|
al@6
|
632 "$next_msg"
|
domcox@0
|
633 }
|
domcox@0
|
634
|
domcox@2
|
635 moveto_home()
|
domcox@0
|
636 {
|
domcox@13
|
637 a "home" "$(gettext 'Back to Installer Start Page')"
|
domcox@0
|
638 }
|
domcox@0
|
639
|
domcox@0
|
640 page_redirection()
|
domcox@0
|
641 {
|
domcox@2
|
642 local page="$1"
|
domcox@2
|
643 cat <<EOT
|
domcox@0
|
644 <!DOCTYPE html>
|
domcox@0
|
645 <html>
|
domcox@0
|
646 <head>
|
domcox@0
|
647 <meta charset="utf-8">
|
domcox@0
|
648 <title>$(gettext "A web page that points a browser to a different page after \
|
domcox@0
|
649 2 seconds")</title>
|
domcox@0
|
650 <meta http-equiv="refresh" content="0; URL=$SCRIPT_NAME?page=$1">
|
domcox@0
|
651 <meta name="keywords" content="automatic redirection">
|
domcox@0
|
652 </head>
|
domcox@0
|
653 <body>
|
domcox@0
|
654 <p>$(gettext "If your browser doesn't automatically redirect within a few \
|
domcox@2
|
655 seconds, you may want to go there manually")
|
domcox@2
|
656 <a href="$SCRIPT_NAME?page=$page">$(gettext "here")</a></p>
|
domcox@0
|
657 </body>
|
domcox@0
|
658 </html>
|
domcox@0
|
659 EOT
|
domcox@0
|
660 }
|
domcox@0
|
661
|
domcox@2
|
662 #----------
|
domcox@2
|
663 # checking
|
domcox@2
|
664 #----------
|
domcox@2
|
665
|
domcox@0
|
666 check_ressources()
|
domcox@0
|
667 {
|
domcox@2
|
668 local errorcode=0
|
domcox@2
|
669 comment "check_ressources"
|
domcox@0
|
670 if ! [ -x /usr/sbin/tazinst ] ; then
|
al@6
|
671 h4 $(gettext "Tazinst Error")
|
al@6
|
672 p $(gettext "<strong>tazinst</strong>, the backend to slitaz-installer \
|
al@6
|
673 is missing. Any installation can not be done without tazinst.")
|
al@6
|
674 p $(gettext "Check tazinst permissions, or reinstall the \
|
al@6
|
675 slitaz-installer package.")
|
domcox@2
|
676 errorcode=1
|
domcox@0
|
677 else
|
domcox@2
|
678 # check tazinst minimum version
|
domcox@2
|
679 v=$(/usr/sbin/tazinst version | tr -d '[:alpha:]')
|
domcox@2
|
680 r=$TAZINST_MINIMUM_VERSION
|
domcox@13
|
681 if ! (printf '%s' "$v" | /bin/busybox awk -v r=$r \
|
domcox@2
|
682 '{v=$v+0}{ if (v < r) exit 1}') ; then
|
al@6
|
683 h4 $(gettext "Tazinst Error")
|
al@6
|
684 p $(gettext "<strong>tazinst</strong>, the slitaz-installer \
|
al@6
|
685 backend, is not at the minimum required version. Any installation \
|
al@6
|
686 cannot be done without tazinst.")
|
al@6
|
687 p $(gettext "Reinstall the slitaz-installer package, or use \
|
al@6
|
688 tazinst in CLI mode.")
|
domcox@2
|
689 errorcode=1
|
domcox@2
|
690 fi
|
domcox@2
|
691 # check tazinst maximum version
|
domcox@2
|
692 v=$(/usr/sbin/tazinst version | tr -d '[:alpha:]')
|
domcox@2
|
693 r=$TAZINST_MAXIMUM_VERSION
|
domcox@13
|
694 if ! (printf '%s' "$v" | /bin/busybox awk -v r=$r \
|
domcox@2
|
695 '{v=$v+0}{ if (v > r) exit 1}') ; then
|
al@6
|
696 h4 $(gettext "Tazinst Error")
|
al@6
|
697 p $(gettext "<strong>tazinst</strong>, the slitaz-installer \
|
al@6
|
698 backend, is at a higher version than the maximum authorized \
|
al@6
|
699 by the slitaz-installer. Any installation cannot be done.")
|
al@6
|
700 p $(gettext "Reinstall the slitaz-installer package, or use \
|
al@6
|
701 tazinst in CLI mode.")
|
domcox@2
|
702 errorcode=1
|
domcox@0
|
703 fi
|
domcox@0
|
704 fi
|
domcox@2
|
705 return $errorcode
|
domcox@0
|
706 }
|
domcox@0
|
707
|
domcox@2
|
708
|
domcox@2
|
709 #---------------
|
domcox@2
|
710 # html snippets
|
domcox@2
|
711 #---------------
|
domcox@2
|
712
|
domcox@2
|
713 br()
|
domcox@0
|
714 {
|
domcox@13
|
715 echo '<br />'
|
domcox@0
|
716 }
|
domcox@0
|
717
|
domcox@2
|
718 hr()
|
domcox@0
|
719 {
|
domcox@13
|
720 echo '<hr />'
|
domcox@0
|
721 }
|
domcox@0
|
722
|
domcox@2
|
723 comment()
|
domcox@0
|
724 {
|
domcox@13
|
725 printf '<!-- %s -->\n' "$@"
|
domcox@2
|
726 }
|
domcox@2
|
727
|
domcox@2
|
728 a()
|
domcox@2
|
729 {
|
domcox@13
|
730 local page="$1" text="$2"
|
domcox@13
|
731 printf '<a class="button" value="%s" href="%s?page=%s">%s</a>\n' \
|
domcox@13
|
732 "$page" "$SCRIPT_NAME" "$page" "$text"
|
domcox@13
|
733 }
|
domcox@13
|
734
|
domcox@13
|
735 button()
|
domcox@13
|
736 {
|
domcox@13
|
737 local action="$1" msg="$2" title="$3"
|
domcox@13
|
738 printf '<a class="button" href="%s?page=%s" title="%s">%s</a>\n' \
|
domcox@13
|
739 "$SCRIPT_NAME" "$action" "$title" "$msg"
|
domcox@2
|
740 }
|
domcox@2
|
741
|
domcox@2
|
742 open_div()
|
domcox@2
|
743 {
|
domcox@13
|
744 [ "$1" ] && printf '<div %s>\n' "$1" || echo '<div>'
|
domcox@2
|
745 }
|
domcox@2
|
746
|
domcox@2
|
747 close_div()
|
domcox@2
|
748 {
|
domcox@13
|
749 echo '</div>'
|
domcox@2
|
750 }
|
domcox@2
|
751
|
domcox@2
|
752 p()
|
domcox@2
|
753 {
|
domcox@13
|
754 printf '<p>%s</p>\n' "$@"
|
domcox@2
|
755 }
|
domcox@2
|
756
|
domcox@2
|
757 h4()
|
domcox@2
|
758 {
|
domcox@13
|
759 printf '<h4>%s</h4>\n' "$@"
|
domcox@2
|
760 }
|
domcox@2
|
761
|
domcox@2
|
762 h5()
|
domcox@2
|
763 {
|
domcox@13
|
764 printf '<h5>%s</h5>\n' "$@"
|
domcox@2
|
765 }
|
domcox@2
|
766
|
domcox@2
|
767 label()
|
domcox@2
|
768 {
|
domcox@2
|
769 local setting="$1" label="$2" title="$3" name="$4" error=0
|
domcox@2
|
770 [ -z "$name" ] && name="$setting"
|
domcox@13
|
771 printf '<label for="%s"' "$name"
|
domcox@13
|
772 [ "$title" ] && printf ' title="%s">' "$title" || printf '%s' '>'
|
domcox@2
|
773 # display label in red in case of error
|
domcox@2
|
774 if [ "$CHECK" ]; then
|
domcox@2
|
775 /usr/sbin/tazinst check "$setting" "$INSTFILE"
|
domcox@2
|
776 error="$?"
|
domcox@2
|
777 [ "$error" -gt "0" ] && [ "$error" -lt "127" ] && \
|
domcox@13
|
778 printf '%s' '<span class="alert">'
|
domcox@13
|
779 printf '%s' "$label"
|
domcox@2
|
780 [ "$error" -gt "0" ] && [ "$error" -lt "127" ] && \
|
domcox@13
|
781 printf '%s' "<sup>*</sup></span>"
|
domcox@2
|
782 else
|
domcox@13
|
783 printf '%s' "$label"
|
domcox@2
|
784 fi
|
domcox@13
|
785 echo '</label>'
|
domcox@2
|
786 return "$error"
|
domcox@2
|
787 }
|
domcox@2
|
788
|
domcox@2
|
789 label_media()
|
domcox@2
|
790 {
|
domcox@2
|
791 local id="$1" label="$2" media="$3" title="$4" retcode=0
|
domcox@2
|
792 if [ "$media" == "$id" ]; then
|
al@6
|
793 label "source" \
|
al@6
|
794 "$label" \
|
al@6
|
795 "$title" \
|
al@6
|
796 "$media"
|
domcox@2
|
797 retcode="$?"
|
domcox@2
|
798 else
|
domcox@13
|
799 printf '<label for="%s"' "$id"
|
domcox@13
|
800 [ "$title" ] && printf ' title="%s">' "$title" || echo '>'
|
domcox@2
|
801 echo "$label</label>"
|
domcox@2
|
802 fi
|
domcox@2
|
803 return "$retcode"
|
domcox@2
|
804 }
|
domcox@2
|
805
|
domcox@2
|
806 error_msg()
|
domcox@2
|
807 {
|
domcox@2
|
808 local error="$1" setting="$2" line="$3"
|
domcox@2
|
809 if [ "$CHECK" ]; then
|
domcox@2
|
810 if [ "$error" -gt "0" ]; then
|
domcox@13
|
811 [ "$error" -lt "128" ] && printf '%s' '<span class="alert">' \
|
domcox@13
|
812 || printf '%s' '<span class="warning">'
|
domcox@2
|
813 if [ "$line" ]; then
|
domcox@2
|
814 /usr/sbin/tazinst check "$setting" "$INSTFILE" 2>&1 | \
|
domcox@2
|
815 /bin/busybox awk -v LINE="$line" '{if (NR==LINE){print}}'
|
domcox@2
|
816 else
|
domcox@2
|
817 /usr/sbin/tazinst check "$setting" "$INSTFILE" 2>&1
|
domcox@2
|
818 fi
|
domcox@13
|
819 echo '</span>'
|
domcox@2
|
820 fi
|
domcox@2
|
821 fi
|
domcox@2
|
822 }
|
domcox@2
|
823
|
domcox@2
|
824 select()
|
domcox@2
|
825 {
|
domcox@13
|
826 local list="$1" selected="$2" name="$3" type="$4"
|
domcox@13
|
827 printf '%s' "$list" | \
|
domcox@13
|
828 /bin/busybox awk -v SELECTED="$selected" -v NONE="$(gettext "None")" \
|
domcox@13
|
829 -v NAME="$name" -v TYPE="$type" 'BEGIN{
|
domcox@2
|
830 TYPE=TYPE+0
|
domcox@2
|
831 print "<select name=\"" NAME "\">"
|
domcox@2
|
832 print "<option value=>< " NONE " ></option>"
|
domcox@2
|
833 }
|
domcox@2
|
834 {
|
domcox@2
|
835 printf "<option value=\"" $1 "\""
|
domcox@2
|
836 if ($1 == SELECTED) printf " selected"
|
domcox@2
|
837 if (TYPE == 0)
|
domcox@2
|
838 print ">" $0 "</option>"
|
domcox@2
|
839 if (TYPE == 1)
|
domcox@2
|
840 print ">" substr($0,12) "</option>"
|
domcox@2
|
841 if (TYPE == 2)
|
domcox@2
|
842 print ">" $2 "</option>"
|
domcox@2
|
843 }
|
domcox@2
|
844 END{
|
domcox@2
|
845 print "</select>"
|
domcox@2
|
846 }'
|
domcox@2
|
847 }
|
domcox@2
|
848
|
domcox@2
|
849 input()
|
domcox@2
|
850 {
|
domcox@2
|
851 local type="$1" name="$2" value="$3" selected="$4" help="$5" action="$6"
|
domcox@13
|
852 printf '<input type="%s" id="%s" list="list_%s" ' "$type" "$name" "$name"
|
domcox@13
|
853 printf 'name="%s" class="%s" ' "$(printf $name | tr [a-z] [A-Z])" "$type"
|
domcox@13
|
854 [ "$value" ] && printf 'value="%s" ' "$value"
|
domcox@13
|
855 [ "$value" == "$selected" ] && printf '%s' "checked "
|
domcox@2
|
856 [ "$action" ] && printf \
|
domcox@13
|
857 'onInput="document.getElementById(%s).checked = true;" ' "'$action'"
|
domcox@13
|
858 [ "$help" ] && printf 'placeholder="%s" />\n' "$help" || echo "/>"
|
domcox@2
|
859 }
|
domcox@2
|
860
|
domcox@2
|
861 input_media()
|
domcox@2
|
862 {
|
domcox@2
|
863 local id="$1" media="$2"
|
domcox@13
|
864 printf '<input type="radio" name="MEDIA" value="%s" id="%s" ' "$id" "$id"
|
domcox@13
|
865 [ "$media" == "$id" ] && echo 'checked />' || echo '/>'
|
domcox@2
|
866 }
|
domcox@2
|
867
|
domcox@2
|
868 input_hidden()
|
domcox@2
|
869 {
|
domcox@13
|
870 local name="$1" value="$2"
|
domcox@13
|
871 printf '<input type="hidden" name="%s" value="%s" />\n' "$name" "$value"
|
domcox@2
|
872 }
|
domcox@2
|
873
|
domcox@2
|
874 datalist()
|
domcox@2
|
875 {
|
domcox@13
|
876 local list="$1" name="$2"
|
domcox@13
|
877 printf '<datalist id="list_%s">\n' "$name"
|
domcox@2
|
878 # workaround for browsers that don’t support the datalist element..
|
domcox@13
|
879 local script="displaySelValue(\"select_$name\",\"$name\")"
|
domcox@13
|
880 printf '<select class="workaround" id="select_%s" ' "$name"
|
domcox@13
|
881 printf "onChange='%s' onBlur='%s'>\n" "$script" "$script"
|
domcox@13
|
882
|
domcox@2
|
883 # workaround ..end
|
domcox@13
|
884 printf '%s' "$list" | \
|
domcox@13
|
885 /bin/busybox awk -v NONE="$(gettext "None")" 'BEGIN{
|
domcox@2
|
886 line=0
|
domcox@2
|
887 }
|
domcox@2
|
888 {
|
domcox@2
|
889 TEXT=$1
|
domcox@2
|
890 sub(".*/","",TEXT)
|
domcox@13
|
891 printf "<option value=\"%s\">%s</option>\n", $1, TEXT
|
domcox@2
|
892 line++
|
domcox@2
|
893 }
|
domcox@2
|
894 END{
|
domcox@2
|
895 if (line < 1)
|
domcox@13
|
896 printf "<option value=>< %s ></option>\n", NONE
|
domcox@2
|
897 }'
|
domcox@2
|
898 echo "</select>"
|
domcox@2
|
899 echo "</datalist>"
|
domcox@2
|
900 }
|
domcox@2
|
901
|
domcox@2
|
902 format()
|
domcox@2
|
903 {
|
al@6
|
904 list_fs="$1" selected="$2" name="$3" none="$(gettext 'Do not format')"
|
domcox@13
|
905 printf '<label for="%s" ' "$name"
|
domcox@13
|
906 printf 'title="%s">' "$(gettext "To format this partition, select a \
|
domcox@13
|
907 filesystem, usually it's safe to use ext4")"
|
domcox@13
|
908 printf '%s</label>\n' "$(gettext "Formatting option:")"
|
domcox@13
|
909 printf '%s' "$list_fs" | \
|
domcox@13
|
910 /bin/busybox awk -v SELECTED=$selected -v NONE="$none" -v NAME="$name" '
|
domcox@13
|
911 BEGIN{
|
domcox@2
|
912 RS=" "
|
domcox@2
|
913 print "<select name=\"" NAME "\">"
|
domcox@2
|
914 print "<option value=\"\">" NONE "</option>"
|
domcox@2
|
915 line=0
|
domcox@2
|
916 }
|
domcox@2
|
917 {
|
domcox@2
|
918 printf "<option value=\"" $1 "\""
|
domcox@2
|
919 if ($1 == SELECTED) printf " selected"
|
domcox@2
|
920 print ">" $0 "</option>"
|
domcox@2
|
921 line++
|
domcox@2
|
922 }
|
domcox@2
|
923 END{
|
domcox@2
|
924 if (line < 1)
|
domcox@2
|
925 print "<option value=>< " NONE " ></option>"
|
domcox@2
|
926 print "</select>"
|
domcox@2
|
927 }'
|
domcox@2
|
928 }
|
domcox@2
|
929
|
domcox@0
|
930 form_start()
|
domcox@0
|
931 {
|
domcox@13
|
932 printf '<form name="%s" method="get" ' "Form"
|
domcox@13
|
933 printf 'onsubmit="return true" action="%s">\n' "$SCRIPT_NAME"
|
domcox@0
|
934 }
|
domcox@0
|
935
|
domcox@0
|
936 form_end()
|
domcox@0
|
937 {
|
domcox@13
|
938 echo '</form>'
|
domcox@0
|
939 }
|
domcox@0
|
940
|
domcox@13
|
941 add_style()
|
domcox@2
|
942 {
|
domcox@13
|
943 printf '<!-- add specific styles -->
|
domcox@13
|
944 <style type="text/css">
|
domcox@13
|
945 .box label {
|
domcox@13
|
946 display:inline-block;
|
domcox@13
|
947 vertical-align:middle;
|
domcox@13
|
948 width: 130px;
|
domcox@13
|
949 }
|
domcox@13
|
950 .media label {
|
domcox@13
|
951 display:inline-block;
|
domcox@13
|
952 vertical-align:middle;
|
domcox@13
|
953 width: 110px;
|
domcox@13
|
954 }
|
domcox@13
|
955 .options label {
|
domcox@13
|
956 display:inline-block;
|
domcox@13
|
957 vertical-align:middle;
|
domcox@13
|
958 width: 140px;
|
domcox@13
|
959 }
|
domcox@13
|
960 .box .text {
|
domcox@13
|
961 width: 350px;
|
domcox@13
|
962 }
|
domcox@13
|
963 input {margin-bottom:3px;}
|
domcox@13
|
964 span.alert {color: red}
|
domcox@13
|
965 span.warning { color: darkgray}
|
domcox@13
|
966 #progress {
|
domcox@13
|
967 background-color: #f8f8f8;
|
domcox@13
|
968 border: 1px solid #ddd;
|
domcox@13
|
969 color: #666;
|
domcox@13
|
970 cursor: progress;
|
domcox@13
|
971 position: absolute;
|
domcox@13
|
972 width: 348px;
|
domcox@13
|
973 padding: 4px 4px 2px;
|
domcox@13
|
974 }
|
domcox@13
|
975 </style>
|
domcox@13
|
976 <!-- workaround for browsers that do not support the datalist element -->
|
domcox@13
|
977 <style type="text/css">
|
domcox@13
|
978 .workaround {width: 110px;}
|
domcox@13
|
979 </style>
|
domcox@13
|
980 <script>
|
domcox@13
|
981 function displaySelValue(selectId,inputId)
|
domcox@13
|
982 {
|
domcox@13
|
983 var slct = document.getElementById(selectId);
|
domcox@13
|
984 var input = document.getElementById(inputId);
|
domcox@13
|
985 document.getElementById("src_iso").value="";
|
domcox@13
|
986 document.getElementById("src_web").value="";
|
domcox@13
|
987 if (inputId =="src_iso"){
|
domcox@13
|
988 document.getElementById("iso").checked = true;
|
domcox@2
|
989 }
|
domcox@13
|
990 if (inputId =="src_web"){
|
domcox@13
|
991 document.getElementById("web").checked = true;
|
domcox@2
|
992 }
|
domcox@13
|
993 input.value = slct.options[slct.selectedIndex].value;
|
domcox@13
|
994 }
|
domcox@13
|
995 </script>
|
domcox@13
|
996 <!-- datalist workaround end -->
|
domcox@13
|
997 \n'
|
domcox@2
|
998 }
|
domcox@2
|
999
|
domcox@2
|
1000
|
domcox@0
|
1001 #
|
domcox@2
|
1002 # main
|
domcox@0
|
1003 #
|
domcox@0
|
1004
|
domcox@2
|
1005 header
|
domcox@2
|
1006
|
domcox@0
|
1007 case "$(GET page)" in
|
domcox@0
|
1008 home)
|
domcox@0
|
1009 xhtml_header
|
domcox@0
|
1010 select_action
|
domcox@0
|
1011 select_install
|
domcox@0
|
1012 select_upgrade
|
domcox@0
|
1013 ;;
|
domcox@2
|
1014 install)
|
domcox@2
|
1015 xhtml_header
|
domcox@2
|
1016 /usr/sbin/tazinst set mode install "$INSTFILE"
|
domcox@2
|
1017 page_redirection partitioning
|
domcox@2
|
1018 ;;
|
domcox@0
|
1019 partitioning)
|
domcox@0
|
1020 xhtml_header
|
domcox@2
|
1021 form_start
|
domcox@2
|
1022 display_mode
|
domcox@0
|
1023 select_gparted
|
domcox@2
|
1024 moveto_page home input
|
domcox@2
|
1025 form_end
|
domcox@0
|
1026 ;;
|
domcox@0
|
1027 gparted)
|
domcox@2
|
1028 exec_gparted
|
domcox@2
|
1029 xhtml_header
|
domcox@0
|
1030 page_redirection partitioning
|
domcox@0
|
1031 ;;
|
domcox@0
|
1032 upgrade)
|
domcox@0
|
1033 xhtml_header
|
domcox@2
|
1034 /usr/sbin/tazinst set mode upgrade "$INSTFILE"
|
domcox@2
|
1035 page_redirection input
|
domcox@2
|
1036 ;;
|
domcox@2
|
1037 input)
|
domcox@2
|
1038 xhtml_header
|
domcox@13
|
1039 add_style
|
domcox@2
|
1040 form_start
|
domcox@2
|
1041 display_mode
|
domcox@2
|
1042 select_settings
|
domcox@13
|
1043 moveto_page home execute
|
domcox@0
|
1044 form_end
|
domcox@0
|
1045 ;;
|
domcox@2
|
1046 execute)
|
domcox@0
|
1047 xhtml_header
|
domcox@2
|
1048 form_start
|
domcox@2
|
1049 display_mode
|
domcox@2
|
1050 save_settings
|
domcox@2
|
1051 if ! (/usr/sbin/tazinst check all $INSTFILE > /dev/null); then
|
domcox@2
|
1052 page_redirection "input&CHECK=yes"
|
domcox@0
|
1053 else
|
domcox@2
|
1054 tazinst_run && moveto_page home reboot \
|
domcox@2
|
1055 || moveto_page input failed
|
domcox@0
|
1056 fi
|
domcox@2
|
1057 form_end
|
domcox@0
|
1058 ;;
|
domcox@0
|
1059 reboot)
|
domcox@2
|
1060 /usr/sbin/tazinst clean "$INSTFILE"
|
domcox@0
|
1061 reboot ;;
|
domcox@0
|
1062 failed)
|
domcox@0
|
1063 xhtml_header
|
domcox@2
|
1064 form_start
|
domcox@2
|
1065 tazinst_log
|
domcox@2
|
1066 moveto_home
|
domcox@2
|
1067 form_end
|
domcox@0
|
1068 ;;
|
domcox@0
|
1069 *)
|
domcox@0
|
1070 xhtml_header
|
domcox@0
|
1071 if check_ressources; then
|
domcox@2
|
1072 /usr/sbin/tazinst new "$INSTFILE"
|
domcox@0
|
1073 page_redirection home
|
domcox@0
|
1074 fi
|
domcox@0
|
1075 ;;
|
domcox@0
|
1076 esac
|
domcox@0
|
1077
|
domcox@0
|
1078 xhtml_footer
|
domcox@0
|
1079
|
domcox@0
|
1080 exit 0
|