Annotation of /trunk/installer-simple/bin/installer.sh.in
Parent Directory | Revision Log
Revision 2890 -
(hide annotations)
(download)
Fri Jul 31 11:11:58 2015 UTC (8 years, 9 months ago) by niro
File size: 14892 byte(s)
Fri Jul 31 11:11:58 2015 UTC (8 years, 9 months ago) by niro
File size: 14892 byte(s)
-detect flashdisk on auto installation and setup them propably on zotac devices
1 | niro | 2323 | #!/bin/bash |
2 | niro | 2322 | # $Id$ |
3 | niro | 2320 | # |
4 | niro | 2322 | # Simple Installation Script |
5 | # merged from alxinstall-ng and mcore-installer | ||
6 | niro | 2320 | # |
7 | # Niels Rogalla <niro@magellan-linux.de> | ||
8 | # | ||
9 | |||
10 | niro | 2472 | # setup locales |
11 | TEXTDOMAIN=installer | ||
12 | |||
13 | niro | 2340 | # include dir |
14 | niro | 2333 | INSTALLER_LIBDIR="%LIBDIR%" |
15 | |||
16 | niro | 2340 | # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 ! |
17 | # -> now in images.conf | ||
18 | CURRENTLINE=0 | ||
19 | |||
20 | niro | 2397 | die() |
21 | { | ||
22 | echo "Error: $@" | ||
23 | exit 1 | ||
24 | } | ||
25 | |||
26 | niro | 2401 | # load common includes |
27 | niro | 2402 | for inc in %SYSCONFDIR%/installer.conf \ |
28 | ${INSTALLER_LIBDIR}/functions/common.sh \ | ||
29 | ${INSTALLER_LIBDIR}/functions/common-dialogs.sh \ | ||
30 | ${INSTALLER_LIBDIR}/functions/hwdetection.sh \ | ||
31 | niro | 2428 | ${INSTALLER_LIBDIR}/functions/bootloader.sh \ |
32 | ${INSTALLER_LIBDIR}/functions/initrd-tools.sh \ | ||
33 | niro | 2402 | ${INSTALLER_LIBDIR}/functions/installer-dialogs.sh |
34 | niro | 2401 | do |
35 | if [ -e ${inc} ] | ||
36 | then | ||
37 | source "${inc}" | ||
38 | else | ||
39 | die "'${inc}' not found" | ||
40 | fi | ||
41 | done | ||
42 | niro | 2332 | |
43 | niro | 2320 | ### System/Config Version |
44 | VERSION="%VERSIONTAG%" | ||
45 | niro | 2332 | TITLE="${DEFAULT_TITLE} - ${VERSION}" |
46 | niro | 2320 | |
47 | niro | 2890 | # initialize global variables so they are exportable |
48 | niro | 2404 | # some sane defaults |
49 | niro | 2653 | LIVEROOT="${DEFAULT_LIVEROOT}" |
50 | niro | 2642 | IMAGEROOT="${DEFAULT_IMAGEROOT}" |
51 | niro | 2342 | INSTALLROOT="${DEFAULT_INSTALLROOT}" |
52 | niro | 2404 | KERNELPKG="${DEFAULT_KERNELPKG}" |
53 | KERNELOPTS="${DEFAULT_KERNELOPTS}" | ||
54 | niro | 2320 | GRUBLEGACYOPTS="" |
55 | GRUB2OPTS="" | ||
56 | FDISKPARTIONBELOW256MB=0 | ||
57 | SPECIALDEVICE="" | ||
58 | niro | 2404 | FORMFACTOR="${DEFAULT_FORMFACTOR}" |
59 | niro | 2332 | FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}" |
60 | niro | 2890 | FLASHDISK=0 |
61 | niro | 2320 | |
62 | niro | 2642 | # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 ! |
63 | # -> now in images.conf | ||
64 | CDIMAGENAME="" | ||
65 | TOTALLINES="" | ||
66 | CURRENTLINE=0 | ||
67 | if [ -e ${IMAGEROOT}/images.conf ] | ||
68 | then | ||
69 | source ${IMAGEROOT}/images.conf | ||
70 | # check if all required variables are set | ||
71 | [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in ${IMAGEROOT}/images.conf" | ||
72 | [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in ${IMAGEROOT}/images.conf" | ||
73 | else | ||
74 | die "${IMAGEROOT}/images.conf not found" | ||
75 | fi | ||
76 | niro | 2320 | |
77 | niro | 2482 | ### helper scripts ### |
78 | |||
79 | niro | 2409 | trap_exit() |
80 | { | ||
81 | is_mounted --location "${INSTALLROOT}/dev" && umount ${INSTALLROOT}/dev | ||
82 | is_mounted --location "${INSTALLROOT}/proc" && umount ${INSTALLROOT}/proc | ||
83 | is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys | ||
84 | is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot | ||
85 | is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT} | ||
86 | niro | 2889 | [[ -n ${SWAPHDD} ]] && swapoff ${SWAPHDD} |
87 | niro | 2409 | |
88 | echo $"Installation aborted." | ||
89 | exit 1 | ||
90 | } | ||
91 | |||
92 | niro | 2423 | install_meter() |
93 | niro | 2320 | { |
94 | while [[ ${CURRENTLINE} != ${TOTALLINES} ]] | ||
95 | do | ||
96 | CURRENTLINE=$(grep -c . /tmp/install.log) | ||
97 | PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES})) | ||
98 | echo ${PERCENT} | ||
99 | sleep 1 | ||
100 | done | ||
101 | rm -f /tmp/install.log | ||
102 | return 0 | ||
103 | } | ||
104 | |||
105 | niro | 2485 | mount_rootfs() |
106 | niro | 2484 | { |
107 | niro | 2489 | local retval |
108 | |||
109 | niro | 2882 | if [[ -n ${SWAPHDD} ]] |
110 | niro | 2489 | then |
111 | niro | 2882 | swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'" |
112 | niro | 2489 | fi |
113 | niro | 2882 | |
114 | if [[ -n ${ROOTHDD} ]] | ||
115 | then | ||
116 | if is_mounted --location "${INSTALLROOT}" | ||
117 | then | ||
118 | echo $"${INSTALLROOT} already mounted" >&2 | ||
119 | else | ||
120 | niro | 2888 | mount -t "${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" |
121 | niro | 2882 | fi |
122 | fi | ||
123 | |||
124 | niro | 2486 | [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot |
125 | niro | 2882 | |
126 | if [[ -n ${BOOTHDD} ]] | ||
127 | then | ||
128 | if is_mounted --location "${INSTALLROOT}"/boot | ||
129 | then | ||
130 | echo $"${INSTALLROOT}/boot already mounted" >&2 | ||
131 | else | ||
132 | niro | 2888 | mount -t "${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'" |
133 | niro | 2882 | fi |
134 | fi | ||
135 | niro | 2484 | } |
136 | |||
137 | niro | 2485 | umount_rootfs() |
138 | niro | 2484 | { |
139 | is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot | ||
140 | is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} | ||
141 | niro | 2882 | |
142 | if [[ -n ${SWAPHDD} ]] | ||
143 | then | ||
144 | swapoff ${SWAPHDD} || die | ||
145 | fi | ||
146 | niro | 2484 | } |
147 | |||
148 | install_do_reboot() | ||
149 | { | ||
150 | reboot | ||
151 | } | ||
152 | |||
153 | niro | 2320 | run_hardware_detection() |
154 | { | ||
155 | local hwinfo | ||
156 | |||
157 | hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" | ||
158 | |||
159 | niro | 2654 | # check for special devices/clients: |
160 | # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd | ||
161 | local removable=0 | ||
162 | if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] | ||
163 | then | ||
164 | niro | 2890 | for i in /sys/block/[hs]d*/removable |
165 | do | ||
166 | if [[ $(< ${i}) = 1 ]] | ||
167 | then | ||
168 | removable=1 | ||
169 | # we assume that all removable disks are flash disks on a zotac | ||
170 | export FLASHDISK=1 | ||
171 | fi | ||
172 | done | ||
173 | niro | 2654 | # smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card' |
174 | niro | 2320 | |
175 | niro | 2654 | # only add this for grub legacy, grub2 detect these settings on its own |
176 | export GRUBLEGACYOPTS="rootdelay=8" | ||
177 | # there are to zotac types in the wild, nvidia based gfx and intel | ||
178 | if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] | ||
179 | then | ||
180 | export SPECIALDEVICE="zotac_nvidia" | ||
181 | else | ||
182 | export SPECIALDEVICE="zotac_intel" | ||
183 | fi | ||
184 | fi | ||
185 | niro | 2320 | |
186 | # check for special devices/clients: | ||
187 | # if a rangee and disk ist smaller then 256mb move partion one block further ahead | ||
188 | if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] | ||
189 | then | ||
190 | # for a rangee always define partion startblock +1 | ||
191 | export FDISKPARTIONBELOW256MB="1" | ||
192 | export SPECIALDEVICE="rangee" | ||
193 | export GRUBLEGACYOPTS="" | ||
194 | fi | ||
195 | |||
196 | # check for special devices/clients: | ||
197 | # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer | ||
198 | if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]] | ||
199 | then | ||
200 | export SPECIALDEVICE="maxdata" | ||
201 | export GRUBLEGACYOPTS="" | ||
202 | fi | ||
203 | |||
204 | # check for special devices/clients: | ||
205 | # check for laptops and activate cpufreq scaling | ||
206 | if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]] | ||
207 | then | ||
208 | export FORMFACTOR="laptop" | ||
209 | export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand" | ||
210 | fi | ||
211 | } | ||
212 | |||
213 | niro | 2429 | run_hardware_detection_disks() |
214 | { | ||
215 | local bootdev | ||
216 | |||
217 | # all disks but exclude ramdisks | ||
218 | export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') | ||
219 | # remove the boot device from ALL_DISKS if it was an usbstick | ||
220 | niro | 2653 | if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] |
221 | niro | 2429 | then |
222 | niro | 2653 | bootdev=$(grep "[[:space:]]${LIVEROOT}[[:space:]]" /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g') |
223 | niro | 2429 | export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") |
224 | fi | ||
225 | export ALL_CDROMS="$(get_hwinfo cdrom)" | ||
226 | } | ||
227 | |||
228 | niro | 2882 | setup_hdd_partitions() |
229 | niro | 2320 | { |
230 | niro | 2435 | # sanity check - should not happen |
231 | if is_mounted --device "${ROOTHDD}" | ||
232 | then | ||
233 | echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2 | ||
234 | umount "${ROOTHDD}" | ||
235 | fi | ||
236 | niro | 2882 | if [[ -n ${BOOTHDD} ]] |
237 | niro | 2320 | then |
238 | niro | 2882 | if is_mounted --device "${BOOTHDD}" |
239 | niro | 2320 | then |
240 | niro | 2882 | echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2 |
241 | umount "${BOOTHDD}" | ||
242 | niro | 2320 | fi |
243 | fi | ||
244 | |||
245 | niro | 2882 | if [[ ${INSTALL_METHOD} = auto ]] |
246 | then | ||
247 | # run this only if FDISKPARTITIONBELOW256MB is not already 1 | ||
248 | if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] | ||
249 | then | ||
250 | if device_minimum_size "${HDD}" 256 | ||
251 | then | ||
252 | FDISKPARTIONBELOW256MB=1 | ||
253 | else | ||
254 | FDISKPARTIONBELOW256MB=0 | ||
255 | fi | ||
256 | fi | ||
257 | niro | 2320 | |
258 | niro | 2882 | ## delete disk |
259 | dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die | ||
260 | |||
261 | niro | 2890 | if [[ ${FLASHDISK} = 1 ]] |
262 | niro | 2882 | then |
263 | niro | 2890 | if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
264 | then | ||
265 | ## setup one bootable partition | ||
266 | # 1. n= new disk | ||
267 | # 2. p= primary disk | ||
268 | # 3. 1= first partition | ||
269 | # 4. 2= default sector start // small disk needs more space for grub2 mbr sector | ||
270 | # 5. ''= defaul sector end | ||
271 | # 6. a= bootable flag | ||
272 | # 7. 1= boot flag for partition 1 | ||
273 | # 8. n= new disk | ||
274 | #10. p= primary disk | ||
275 | #11. 2= second partition | ||
276 | #12. ''= default sector start | ||
277 | #13. ''= defaul sector end | ||
278 | #14. w= write/quit | ||
279 | fdisk ${HDD} &> /dev/null << EOF | ||
280 | niro | 2320 | n |
281 | p | ||
282 | 1 | ||
283 | 2 | ||
284 | niro | 2890 | +50M |
285 | a | ||
286 | 1 | ||
287 | n | ||
288 | p | ||
289 | 2 | ||
290 | niro | 2320 | |
291 | niro | 2890 | |
292 | w | ||
293 | EOF | ||
294 | else | ||
295 | ## setup one bootable partition | ||
296 | # 1. n= new disk | ||
297 | # 2. p= primary disk | ||
298 | # 3. 1= first partition | ||
299 | # 4. ''= default sector start | ||
300 | # 5. ''= defaul sector end | ||
301 | # 6. a= bootable flag | ||
302 | # 7. 1= boot flag for partition 1 | ||
303 | # 8. n= new disk | ||
304 | #10. p= primary disk | ||
305 | #11. 2= second partition | ||
306 | #12. ''= default sector start | ||
307 | #13. ''= defaul sector end | ||
308 | #14. w= write/quit | ||
309 | fdisk ${HDD} &> /dev/null << EOF | ||
310 | n | ||
311 | p | ||
312 | 1 | ||
313 | |||
314 | +50M | ||
315 | niro | 2320 | a |
316 | 1 | ||
317 | niro | 2890 | n |
318 | p | ||
319 | 2 | ||
320 | |||
321 | |||
322 | niro | 2320 | w |
323 | EOF | ||
324 | niro | 2890 | fi |
325 | niro | 2882 | else |
326 | niro | 2890 | if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
327 | then | ||
328 | ## setup one bootable partition | ||
329 | #1. n= new disk | ||
330 | #2. p= primary disk | ||
331 | #3. 1= first partition | ||
332 | #4. 2= default sector start // small disk needs more space for grub2 mbr sector | ||
333 | #5. ''= defaul sector end | ||
334 | #6. a= bootable flag | ||
335 | #7. 1= boot flag for partition 1 | ||
336 | #8. w= write/quit | ||
337 | fdisk ${HDD} &> /dev/null << EOF | ||
338 | niro | 2320 | n |
339 | p | ||
340 | 1 | ||
341 | niro | 2890 | 2 |
342 | niro | 2320 | |
343 | niro | 2890 | a |
344 | 1 | ||
345 | w | ||
346 | EOF | ||
347 | else | ||
348 | ## setup one bootable partition | ||
349 | #1. n= new disk | ||
350 | #2. p= primary disk | ||
351 | #3. 1= first partition | ||
352 | #4. ''= default sector start | ||
353 | #5. ''= defaul sector end | ||
354 | #6. a= bootable flag | ||
355 | #7. 1= boot flag for partition 1 | ||
356 | #8. w= write/quit | ||
357 | fdisk ${HDD} &> /dev/null << EOF | ||
358 | n | ||
359 | p | ||
360 | 1 | ||
361 | niro | 2320 | |
362 | niro | 2890 | |
363 | niro | 2320 | a |
364 | 1 | ||
365 | w | ||
366 | EOF | ||
367 | niro | 2890 | fi |
368 | niro | 2882 | fi |
369 | else | ||
370 | cfdisk ${HDD} || dialog_die | ||
371 | niro | 2320 | fi |
372 | } | ||
373 | |||
374 | setup_hdd_format() | ||
375 | { | ||
376 | niro | 2883 | install -d /tmp |
377 | :> /tmp/format.log | ||
378 | |||
379 | niro | 2882 | if [[ -n ${SWAPHDD} ]] |
380 | niro | 2435 | then |
381 | niro | 2882 | # sanity check - should not happen |
382 | if is_mounted --device "${SWAPHDD}" | ||
383 | then | ||
384 | echo "format: device ${SWAPHDD} is already mounted, umount it" >&2 | ||
385 | umount "${SWAPHDD}" | ||
386 | fi | ||
387 | mkswap ${SWAPHDD} || die | ||
388 | niro | 2435 | fi |
389 | |||
390 | niro | 2882 | if [[ -n ${BOOTHDD} ]] |
391 | then | ||
392 | # sanity check - should not happen | ||
393 | if is_mounted --device "${BOOTHDD}" | ||
394 | then | ||
395 | echo "format: device ${BOOTHDD} is already mounted, umount it" >&2 | ||
396 | umount "${BOOTHDD}" | ||
397 | fi | ||
398 | |||
399 | niro | 2885 | mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die |
400 | niro | 2882 | fi |
401 | |||
402 | if [[ -n ${ROOTHDD} ]] | ||
403 | then | ||
404 | # sanity check - should not happen | ||
405 | if is_mounted --device "${ROOTHDD}" | ||
406 | then | ||
407 | echo "format: device ${ROOTHDD} is already mounted, umount it" >&2 | ||
408 | umount "${ROOTHDD}" | ||
409 | fi | ||
410 | |||
411 | niro | 2885 | mkfs."${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die |
412 | niro | 2882 | fi |
413 | niro | 2320 | } |
414 | |||
415 | install_system_image() | ||
416 | { | ||
417 | niro | 2433 | pushd ${INSTALLROOT} > /dev/null |
418 | niro | 2655 | tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT} |
419 | niro | 2433 | popd > /dev/null |
420 | niro | 2320 | } |
421 | |||
422 | install_system_settings() | ||
423 | { | ||
424 | niro | 2443 | local CONFIG |
425 | niro | 2320 | |
426 | niro | 2443 | # write fstab |
427 | CONFIG="${INSTALLROOT}/etc/fstab" | ||
428 | clearconfig | ||
429 | niro | 2882 | if [[ -n ${BOOTHDD} ]] |
430 | then | ||
431 | niro | 2885 | addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime\t1 1" |
432 | niro | 2882 | fi |
433 | if [[ -n ${ROOTHDD} ]] | ||
434 | then | ||
435 | niro | 2885 | addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0" |
436 | niro | 2882 | fi |
437 | if [[ -n ${SWAPHDD} ]] | ||
438 | then | ||
439 | addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" | ||
440 | fi | ||
441 | niro | 2443 | addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" |
442 | addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" | ||
443 | |||
444 | niro | 2320 | # install network config skeleton |
445 | niro | 2443 | CONFIG="${INSTALLROOT}/etc/conf.d/net.eth0" |
446 | clearconfig | ||
447 | addconfig 'ONBOOT="yes"' | ||
448 | addconfig 'NETWORKING="dhcp"' | ||
449 | niro | 2320 | |
450 | niro | 2442 | # intel framebuffer quirk |
451 | niro | 2500 | CONFIG="${INSTALLROOT}/etc/splash/splash.conf" |
452 | if [ -e ${CONFIG} ] && [ -e /proc/fb ] | ||
453 | niro | 2320 | then |
454 | niro | 2500 | if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] |
455 | niro | 2320 | then |
456 | niro | 2500 | fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') |
457 | [[ ${fbdev} != 0 ]] && sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${CONFIG} || dialog_die | ||
458 | niro | 2320 | fi |
459 | fi | ||
460 | } | ||
461 | |||
462 | |||
463 | niro | 2482 | ### installer dialogs ### |
464 | |||
465 | dialog_die() | ||
466 | { | ||
467 | ERROR="$1" | ||
468 | RETVAL="$?" | ||
469 | dialog_install_failure | ||
470 | exit 1 | ||
471 | } | ||
472 | |||
473 | dialog_warning() | ||
474 | { | ||
475 | local retval | ||
476 | |||
477 | yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?" | ||
478 | retval=$? | ||
479 | if [[ ${retval} -eq 1 ]] | ||
480 | then | ||
481 | clear | ||
482 | echo $"The process was aborted." | ||
483 | exit 1 | ||
484 | fi | ||
485 | } | ||
486 | |||
487 | |||
488 | ### installer tasks ### | ||
489 | |||
490 | task_setup_system_menu() | ||
491 | { | ||
492 | local mode | ||
493 | local retval | ||
494 | |||
495 | mode="$(dialog_setup_system_menu)" | ||
496 | retval=$? | ||
497 | [[ ${retval} -eq 1 ]] && return 1 | ||
498 | if [[ ${retval} -eq 0 ]] | ||
499 | then | ||
500 | case "${mode}" in | ||
501 | niro | 2882 | "1") run_install auto ;; |
502 | "2") run_install normal ;; | ||
503 | niro | 2482 | "") task_setup_system_menu;; |
504 | esac | ||
505 | fi | ||
506 | } | ||
507 | |||
508 | task_hardware_detection() | ||
509 | { | ||
510 | local message | ||
511 | |||
512 | run_hardware_detection_disks | ||
513 | |||
514 | message+=$"Harddrives:\n" | ||
515 | |||
516 | if [[ ! -z ${ALL_DISKS} ]] | ||
517 | then | ||
518 | for i in ${ALL_DISKS} | ||
519 | do | ||
520 | message+="\Z3${i}\Zn " | ||
521 | done | ||
522 | message+="\n" | ||
523 | fi | ||
524 | |||
525 | if [[ ! -z ${ALL_CDROMS} ]] | ||
526 | then | ||
527 | message+="\n" | ||
528 | message+=$"Optical disk drives:\n" | ||
529 | for i in ${ALL_CDROMS} | ||
530 | do | ||
531 | message+="\Z3${i}\Zn" | ||
532 | done | ||
533 | message+="\n" | ||
534 | fi | ||
535 | |||
536 | # other devices | ||
537 | run_hardware_detection | ||
538 | case "${SPECIALDEVICE}" in | ||
539 | zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;; | ||
540 | rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;; | ||
541 | maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;; | ||
542 | *) message+=$"\n\ZnCommon device detected.\Zn" ;; | ||
543 | esac | ||
544 | if [[ ${FORMFACTOR} = laptop ]] | ||
545 | then | ||
546 | message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn" | ||
547 | fi | ||
548 | niro | 2890 | if [[ ${FLASHDISK} = 1 ]] |
549 | then | ||
550 | message+=$"\n\ZnFlash memory detected.\Zn" | ||
551 | message+=$"\n\ZnF2FS will be used as default filesystem withn the auto installation mode.\Zn" | ||
552 | fi | ||
553 | niro | 2482 | |
554 | messagebox -y 12 -h $"Detected hardware:" "${message}" | ||
555 | } | ||
556 | |||
557 | niro | 2882 | task_setup_hdd_partitions() |
558 | niro | 2482 | { |
559 | local i | ||
560 | local retval | ||
561 | |||
562 | if [[ -z ${ALL_DISKS} ]] | ||
563 | then | ||
564 | dialog_no_harddrive_found | ||
565 | exit 1 | ||
566 | else | ||
567 | HDD=$(dialog_select_target_harddrive) | ||
568 | retval=$? | ||
569 | [[ ${retval} -eq 1 ]] && return 1 | ||
570 | if [[ ${retval} -eq 0 ]] | ||
571 | then | ||
572 | dialog_setup_hdd_info | ||
573 | niro | 2882 | setup_hdd_partitions |
574 | niro | 2482 | fi |
575 | fi | ||
576 | } | ||
577 | |||
578 | task_main() | ||
579 | { | ||
580 | local method=0 | ||
581 | local retval | ||
582 | |||
583 | while [[ ${method} -le 2 ]] | ||
584 | do | ||
585 | method=$(dialog_main) | ||
586 | retval=$? | ||
587 | [[ ${retval} -eq 1 ]] && exit 1 | ||
588 | if [[ ${retval} -eq 0 ]] | ||
589 | then | ||
590 | case ${method} in | ||
591 | "1") task_setup_system_menu ;; | ||
592 | "2") task_hardware_detection ;; | ||
593 | "3") install_do_reboot ;; | ||
594 | "4") /bin/bash --login -i ;; | ||
595 | esac | ||
596 | fi | ||
597 | done | ||
598 | } | ||
599 | |||
600 | niro | 2882 | run_install() |
601 | niro | 2320 | { |
602 | niro | 2882 | local method="$1" |
603 | |||
604 | niro | 2481 | task_hardware_detection |
605 | niro | 2320 | |
606 | niro | 2882 | case "${method}" in |
607 | auto) | ||
608 | niro | 2890 | if [[ ${FLASHDISK} = 1 ]] |
609 | then | ||
610 | export BOOTHDD="${HDD}1" | ||
611 | export SWAPHDD="" | ||
612 | export ROOTHDD="${HDD}2" | ||
613 | export FORMAT_FILESYSTEM_BOOTHDD="f2fs" | ||
614 | export FORMAT_FILESYSTEM_ROOTHDD="ext2" | ||
615 | else | ||
616 | export BOOTHDD="" | ||
617 | export SWAPHDD="" | ||
618 | export ROOTHDD="${HDD}1" | ||
619 | export FORMAT_FILESYSTEM_BOOTHDD="" | ||
620 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" | ||
621 | fi | ||
622 | niro | 2882 | export INSTALL_METHOD="${method}" |
623 | ;; | ||
624 | normal) | ||
625 | niro | 2886 | export BOOTHDD="${HDD}1" |
626 | export SWAPHDD="${HDD}2" | ||
627 | export ROOTHDD="${HDD}3" | ||
628 | niro | 2885 | export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" |
629 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" | ||
630 | niro | 2882 | export INSTALL_METHOD="${method}" |
631 | ;; | ||
632 | niro | 2885 | single) |
633 | niro | 2886 | export BOOTHDD="" |
634 | export SWAPHDD="" | ||
635 | export ROOTHDD="${HDD}1" | ||
636 | niro | 2885 | export FORMAT_FILESYSTEM_BOOTHDD="" |
637 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" | ||
638 | export INSTALL_METHOD="${method}" | ||
639 | ;; | ||
640 | niro | 2887 | flash) |
641 | export BOOTHDD="${HDD}1" | ||
642 | export SWAPHDD="" | ||
643 | export ROOTHDD="${HDD}2" | ||
644 | export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" | ||
645 | export FORMAT_FILESYSTEM_ROOTHDD="f2fs" | ||
646 | export INSTALL_METHOD="${method}" | ||
647 | ;; | ||
648 | niro | 2882 | *) |
649 | die "Unknown install method '${method}', aborting." | ||
650 | ;; | ||
651 | esac | ||
652 | niro | 2320 | |
653 | niro | 2882 | task_setup_hdd_partitions |
654 | niro | 2320 | dialog_setup_hdd_format |
655 | niro | 2399 | setup_hdd_format > /dev/null |
656 | niro | 2485 | mount_rootfs |
657 | niro | 2423 | (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image |
658 | niro | 2320 | |
659 | dialog_install_settings | ||
660 | sleep 1 | ||
661 | niro | 2399 | install_system_settings |
662 | niro | 2440 | if is_initrd_supported |
663 | then | ||
664 | dialog_install_initrd | ||
665 | initrd_config | ||
666 | initrd_install | ||
667 | fi | ||
668 | niro | 2320 | |
669 | dialog_install_bootsector | ||
670 | niro | 2440 | bootloader_config |
671 | bootloader_install | ||
672 | niro | 2320 | |
673 | niro | 2485 | umount_rootfs |
674 | niro | 2320 | dialog_install_successful |
675 | } | ||
676 | |||
677 | niro | 2409 | # set some proper traps |
678 | trap "trap_exit" SIGINT SIGQUIT | ||
679 | |||
680 | niro | 2477 | task_main |
681 | niro | 2320 | |
682 | exit 0 |