Contents of /alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in
Parent Directory | Revision Log
Revision 6844 -
(show annotations)
(download)
Thu Jul 23 13:32:03 2015 UTC (9 years, 2 months ago) by niro
File size: 23394 byte(s)
Thu Jul 23 13:32:03 2015 UTC (9 years, 2 months ago) by niro
File size: 23394 byte(s)
-not every mkfs.FS prog like the -q option, pipe the output into a log file instead
1 | #!/bin/sh |
2 | # $Id$ |
3 | |
4 | # ignore environment! |
5 | LC_ALL=C |
6 | |
7 | MLIBDIR="/usr/lib/alxinstall-ng" |
8 | |
9 | # images: (get ${CDIMAGENAME}) |
10 | source /mnt/cdrom/system/images.conf |
11 | |
12 | # includes |
13 | source ${MLIBDIR}/functions/generic.sh |
14 | source ${MLIBDIR}/functions/hwdetection.sh |
15 | |
16 | ### System/Config Version |
17 | VERSION="@@VERSION@@" |
18 | TITLE="alxinstall-ng - ${VERSION}" |
19 | |
20 | # locations |
21 | CDPATH="/mnt/cdrom" |
22 | INSTALL_ROOT="/mnt/magellan" |
23 | |
24 | # default system settings |
25 | # standard kernel opts |
26 | DEFAULT_KERNELOPTS="quiet video=1024x768" |
27 | |
28 | # grub options |
29 | DEFAULT_GRUBLEGACYOPTS="" |
30 | DEFAULT_GRUB2OPTS="" |
31 | DEFAULT_GRUB2GFXPAYLOAD="1024x768x16,1024x768" |
32 | |
33 | # default specialdevices |
34 | DEFAULT_FORMFACTOR="desktop" |
35 | |
36 | # target filesystem |
37 | DEFAULT_FORMAT_FILESYSTEM="ext4" |
38 | |
39 | # initialize global variables so they are exportable |
40 | INSTALL_METHOD="" |
41 | KERNELOPTS="" |
42 | GRUBLEGACYOPTS="" |
43 | GRUB2OPTS="" |
44 | GRUB2GFXPAYLOAD="" |
45 | FORMFACTOR="" |
46 | FORMAT_FILESYSTEM="" |
47 | FORMAT_FILESYSTEM_BOOTHDD="" |
48 | FORMAT_FILESYSTEM_ROOTHDD="" |
49 | FDISKPARTIONBELOW256MB=0 |
50 | SPECIALDEVICE="" |
51 | FLASHDISK=0 |
52 | ### linecount of system.tar.gz -1 ! |
53 | CURRENTLINE=0 |
54 | #TOTALLINES=11072 # -> now in images.conf |
55 | |
56 | ################################################# |
57 | # DIALOG BOXES # |
58 | ################################################# |
59 | |
60 | die() |
61 | { |
62 | ERROR=$1 |
63 | RETVAL=$? |
64 | dialog_install_failure |
65 | trap_exit |
66 | exit 1 |
67 | } |
68 | |
69 | dialog_warning() |
70 | { |
71 | dialog \ |
72 | --backtitle "${TITLE}" \ |
73 | --colors \ |
74 | --defaultno \ |
75 | --yesno "\Z1 !!! Achtung !!! \Zn\n\n\ |
76 | Diese Festplatte wird unwiederruflich geloescht werden.\n\n\ |
77 | Soll ich wirklich fortfahren ?" 10 70 |
78 | RES=$? |
79 | if [[ ${RES} -eq 1 ]] |
80 | then |
81 | clear |
82 | echo "Der Vorgang wurde abgebrochen." |
83 | exit 1 |
84 | fi |
85 | } |
86 | |
87 | dialog_setup_hdd_info() |
88 | { |
89 | case "${INSTALL_METHOD}" in |
90 | auto) |
91 | dialog_setup_hdd_info_auto |
92 | dialog_setup_hdd_create_partitions |
93 | ;; |
94 | normal) dialog_setup_hdd_info_normal ;; |
95 | single) dialog_setup_hdd_info_single ;; |
96 | flash) dialog_setup_hdd_info_flash ;; |
97 | esac |
98 | } |
99 | |
100 | dialog_setup_hdd_info_normal() |
101 | { |
102 | local SHDD="$(echo ${HDD} | sed 's/\/dev\///')" |
103 | |
104 | dialog \ |
105 | --colors \ |
106 | --title "[ Festplatten Partitionierung ]" \ |
107 | --backtitle "${TITLE}" \ |
108 | --ok-label "Weiter" \ |
109 | --msgbox "\nBitte legen Sie 3 Partitionen an.\n\n\ |
110 | [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit ca. 50MB\n\ |
111 | [ \Z3${SHDD}2\Zn ] Typ: \Z3Linux Swap\Zn mit ca. 256MB\n\ |
112 | [ \Z3${SHDD}3\Zn ] Typ: \Z3Linux \Zn mit dem Rest (min. 256MB)\n\n\ |
113 | Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 |
114 | } |
115 | |
116 | dialog_setup_hdd_info_single() |
117 | { |
118 | local SHDD="$(echo $HDD | sed 's/\/dev\///')" |
119 | |
120 | dialog \ |
121 | --colors \ |
122 | --title "[ Festplatten Partitionierung ]" \ |
123 | --backtitle "${TITLE}" \ |
124 | --ok-label "Weiter" \ |
125 | --msgbox "\nBitte legen Sie 1 Partition an.\n\n\ |
126 | [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit dem gesamten Speicher\n\ |
127 | Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 |
128 | } |
129 | |
130 | dialog_setup_hdd_info_flash() |
131 | { |
132 | local SHDD="$(echo ${HDD} | sed 's/\/dev\///')" |
133 | |
134 | dialog \ |
135 | --colors \ |
136 | --title "[ Festplatten Partitionierung ]" \ |
137 | --backtitle "${TITLE}" \ |
138 | --ok-label "Weiter" \ |
139 | --msgbox "\nBitte legen Sie 2 Partitionen an.\n\n\ |
140 | [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit ca. 50MB\n\ |
141 | [ \Z3${SHDD}2\Zn ] Typ: \Z3Linux \Zn mit dem Rest (min. 256MB)\n\n\ |
142 | Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 |
143 | } |
144 | |
145 | dialog_setup_hdd_info_auto() |
146 | { |
147 | local SHDD="$(echo $HDD | sed 's/\/dev\///')" |
148 | |
149 | dialog \ |
150 | --colors \ |
151 | --title "[ Festplatten Partitionierung ]" \ |
152 | --backtitle "${TITLE}" \ |
153 | --ok-label "Weiter" \ |
154 | --msgbox "\nAchtung!\n\ |
155 | Alle Daten werden von der Disk [ \Z3${HDD}\Zn ] gelöscht!" 12 81 |
156 | } |
157 | |
158 | dialog_setup_system_menu() |
159 | { |
160 | local i |
161 | |
162 | i=$(dialog \ |
163 | --backtitle "${TITLE}" \ |
164 | --title "[ Festplatten Partitionierung ]" \ |
165 | --cancel-label "Abbrechen" \ |
166 | --ok-label "Weiter" \ |
167 | --stdout \ |
168 | --colors \ |
169 | --menu "\nWaehlen Sie die Installations-Methode" 14 70 6 \ |
170 | "1" "Automatisches Setup (Empfohlen)" \ |
171 | "" "" \ |
172 | "" "\Z1Experten Modi:\Zn" \ |
173 | "2" "Normale IDE-Disk (Manuell)" \ |
174 | "3" "Normale IDE Disk (Single)" \ |
175 | "4" "Flash SDHC/NAND oder USBStick (Manuell)") |
176 | RES=$? |
177 | [[ ${RES} -eq 1 ]] && return 1 |
178 | if [[ ${RES} -eq 0 ]] |
179 | then |
180 | case "${i}" in |
181 | "1") run_install auto ;; |
182 | "2") run_install normal ;; |
183 | "3") run_install single ;; |
184 | "4") run_install flash ;; |
185 | "") dialog_setup_system_menu;; |
186 | esac |
187 | fi |
188 | } |
189 | |
190 | dialog_hardware_detection() |
191 | { |
192 | local i |
193 | local hwtmp |
194 | |
195 | if [ -x $(type -P mktemp) ] |
196 | then |
197 | hwtmp="$(mktemp)" |
198 | else |
199 | hwtmp="/tmp/hwtmp.sh" |
200 | fi |
201 | |
202 | run_hardware_detection_disks |
203 | |
204 | echo "dialog \\" > ${hwtmp} |
205 | echo "--backtitle \"${TITLE}\" \\" >> ${hwtmp} |
206 | echo "--ok-label \"Weiter\" \\" >> ${hwtmp} |
207 | echo "--stdout \\" >> ${hwtmp} |
208 | echo "--colors \\" >> ${hwtmp} |
209 | echo "--msgbox \"Gefundene Hardware:\n\n \\" >> ${hwtmp} |
210 | echo " Festplatten:\n \\" >> ${hwtmp} |
211 | |
212 | if [[ ! -z ${ALL_DISKS} ]] |
213 | then |
214 | for i in ${ALL_DISKS} |
215 | do |
216 | echo " \\Z3${i}\\Zn\n \\" >> ${hwtmp} |
217 | done |
218 | fi |
219 | |
220 | if [[ ! -z ${ALL_CDROMS} ]] |
221 | then |
222 | echo " \n \\" >> ${hwtmp} |
223 | echo " CDROM Laufwerke:\n \\" >> ${hwtmp} |
224 | for i in ${ALL_CDROMS} |
225 | do |
226 | echo " \\Z3${i}\\Zn\n \\" >> ${hwtmp} |
227 | done |
228 | fi |
229 | |
230 | # other devices |
231 | run_hardware_detection |
232 | case "${SPECIALDEVICE}" in |
233 | zotac*) echo " \n \\Z2Zotac Device erkannt.\\Zn \\" >> ${hwtmp} ;; |
234 | rangee) echo " \n \\Z2Rangee Device erkannt.\\Zn \\" >> ${hwtmp} ;; |
235 | maxdata) echo " \n \\Z2Maxdata Device erkannt.\\Zn \\" >> ${hwtmp} ;; |
236 | i845) echo " \n \\Z2Intel i845 Device erkannt.\\Zn \\" >> ${hwtmp} ;; |
237 | *) echo " \n \\ZnStandard Device erkannt.\\Zn \\" >> ${hwtmp} ;; |
238 | esac |
239 | if [[ ${FORMFACTOR} = laptop ]] |
240 | then |
241 | echo " \n \\ZnFormfactor Laptop, Powersave Modus 'ondemand' wird aktiviert.\\Zn \\" >> ${hwtmp} |
242 | fi |
243 | if [[ ${FLASHDISK} = 1 ]] |
244 | then |
245 | echo " \n \\ZnFlash Speicher erkannt, F2FS wird als Dateisystem benutzt.\\Zn \\" >> ${hwtmp} |
246 | fi |
247 | |
248 | echo " \" 14 70" >> ${hwtmp} |
249 | chmod a+x ${hwtmp} |
250 | ${hwtmp} |
251 | |
252 | # remove tmp file |
253 | if [[ -f ${hwtmp} ]] |
254 | then |
255 | rm ${hwtmp} |
256 | fi |
257 | } |
258 | |
259 | dialog_setup_hdd_partitions() |
260 | { |
261 | local i |
262 | |
263 | if [[ -z ${ALL_DISKS} ]] |
264 | then |
265 | dialog \ |
266 | --backtitle "${TITLE}" \ |
267 | --ok-label "Beenden" \ |
268 | --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70 |
269 | exit 1 |
270 | else |
271 | |
272 | echo "dialog \\" > /tmp/hddtmp.sh |
273 | echo "--backtitle \"${TITLE}\" \\" >> /tmp/hddtmp.sh |
274 | echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh |
275 | echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh |
276 | echo "--stdout \\" >> /tmp/hddtmp.sh |
277 | echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh |
278 | |
279 | for i in ${ALL_DISKS} |
280 | do |
281 | echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh |
282 | done |
283 | echo -e "\n" >> /tmp/hddtmp.sh |
284 | |
285 | chmod a+x /tmp/hddtmp.sh |
286 | HDD="$(/tmp/hddtmp.sh)" |
287 | RES=$? |
288 | [[ ${RES} -eq 1 ]] && return 1 |
289 | if [[ ${RES} -eq 0 ]] |
290 | then |
291 | dialog_setup_hdd_info |
292 | setup_hdd_partitions |
293 | fi |
294 | fi |
295 | } |
296 | |
297 | dialog_setup_hdd_create_partitions() |
298 | { |
299 | dialog \ |
300 | --backtitle "${TITLE}" \ |
301 | --infobox "Erstelle Disk Partitionen ..." 3 70 |
302 | } |
303 | |
304 | dialog_setup_hdd_format() |
305 | { |
306 | dialog \ |
307 | --backtitle "${TITLE}" \ |
308 | --infobox "Erstelle Datei-Systeme ..." 3 70 |
309 | } |
310 | |
311 | dialog_install_settings() |
312 | { |
313 | dialog \ |
314 | --backtitle "${TITLE}" \ |
315 | --infobox "Speichere System-Einstellungen ..." 3 70 |
316 | } |
317 | |
318 | dialog_install_system_image() |
319 | { |
320 | dialog \ |
321 | --backtitle "${TITLE}" \ |
322 | --gauge "Kopiere System-Image ..." 6 80 |
323 | } |
324 | |
325 | dialog_install_meter() |
326 | { |
327 | while [[ ${CURRENTLINE} != ${TOTALLINES} ]] |
328 | do |
329 | CURRENTLINE=$(grep -c . /tmp/install.log) |
330 | PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES})) |
331 | echo ${PERCENT} |
332 | sleep 1 |
333 | done |
334 | rm -f /tmp/install.log |
335 | return 0 |
336 | } |
337 | |
338 | dialog_install_bootsector() |
339 | { |
340 | dialog \ |
341 | --backtitle "${TITLE}" \ |
342 | --infobox "Schreibe den Bootsektor ..." 3 70 |
343 | } |
344 | |
345 | dialog_install_successful() |
346 | { |
347 | dialog \ |
348 | --backtitle "${TITLE}" \ |
349 | --colors \ |
350 | --msgbox "Die Installation war \Z2erfolgreich\Zn." 5 81 |
351 | } |
352 | |
353 | dialog_install_failure() |
354 | { |
355 | dialog \ |
356 | --backtitle "${TITLE}" \ |
357 | --colors \ |
358 | --msgbox "Die Installation ist \Z1Fehlgeschlagen\Zn.\n\n\ |
359 | Fehler bei ${ERROR}, RetVal: ${RETVAL} \ |
360 | " 10 81 |
361 | } |
362 | |
363 | dialog_main() |
364 | { |
365 | METHOD=0 |
366 | |
367 | while [[ ${METHOD} -le 2 ]] |
368 | do |
369 | METHOD=$(dialog \ |
370 | --backtitle "${TITLE}" \ |
371 | --no-cancel \ |
372 | --ok-label "Weiter" \ |
373 | --stdout \ |
374 | --menu "Konfiguration" 14 70 6 \ |
375 | "1" "AutoSta_LX installieren" \ |
376 | "2" "Uebersicht gefundener Laufwerke" \ |
377 | "3" "Beenden und neustarten" \ |
378 | "4" "Beenden und eine Shell starten") |
379 | RES=$? |
380 | [[ ${RES} -eq 1 ]] && exit 1 |
381 | if [[ ${RES} -eq 0 ]] |
382 | then |
383 | case ${METHOD} in |
384 | "1") dialog_setup_system_menu ;; |
385 | "2") dialog_hardware_detection ;; |
386 | "3") install_do_reboot ;; |
387 | "4") /bin/bash --login -i ;; |
388 | esac |
389 | fi |
390 | done |
391 | } |
392 | |
393 | ################################################# |
394 | # Install Commands # |
395 | ################################################# |
396 | run_hardware_detection() |
397 | { |
398 | local hwinfo |
399 | hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" |
400 | |
401 | # check for special devices/clients: |
402 | # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd |
403 | local removable=0 |
404 | if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
405 | then |
406 | for i in /sys/block/[hs]d*/removable |
407 | do |
408 | if [[ $(< ${i}) = 1 ]] |
409 | then |
410 | removable=1 |
411 | # we assume that all removable disks are flash disks |
412 | export FLASHDISK=1 |
413 | fi |
414 | done |
415 | |
416 | # only add this for grub legacy, grub2 detect these settings on its own |
417 | export GRUBLEGACYOPTS="rootdelay=8" |
418 | # there are two zotac types in the wild, nvidia based gfx and intel |
419 | if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] |
420 | then |
421 | export SPECIALDEVICE="zotac_nvidia" |
422 | else |
423 | export SPECIALDEVICE="zotac_intel" |
424 | fi |
425 | fi |
426 | |
427 | # check for special devices/clients: |
428 | # if a rangee and disk ist smaller then 256mb move partion one block further ahead |
429 | if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] |
430 | then |
431 | # for a rangee always define partion startblock +1 |
432 | export FDISKPARTIONBELOW256MB="1" |
433 | export SPECIALDEVICE="rangee" |
434 | export GRUBLEGACYOPTS="" |
435 | fi |
436 | |
437 | # check for special devices/clients: |
438 | # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer |
439 | if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]] |
440 | then |
441 | export SPECIALDEVICE="maxdata" |
442 | export GRUBLEGACYOPTS="" |
443 | fi |
444 | |
445 | # check for i845 Chipsets and disable KMS and use 915 drm driver |
446 | if [[ ! -z $(echo "${hwinfo}" | grep -i i845) ]] |
447 | then |
448 | export SPECIALDEVICE="i845" |
449 | # unset default video=1024x768 opt or the drm driver breaks |
450 | export KERNELOPTS="quiet" |
451 | export GRUBLEGACYOPTS="" |
452 | # enable full kms support |
453 | export GRUB2GFXPAYLOAD="keep" |
454 | fi |
455 | |
456 | # check for radeon gfxcards |
457 | if [[ ! -z $(echo "${hwinfo}" | grep -i radeon) ]] |
458 | then |
459 | # enable full kms support |
460 | export GRUB2GFXPAYLOAD="keep" |
461 | fi |
462 | |
463 | # check for special devices/clients: |
464 | # check for laptops and activate cpufreq scaling |
465 | if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]] |
466 | then |
467 | export FORMFACTOR="laptop" |
468 | export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand" |
469 | fi |
470 | } |
471 | |
472 | run_hardware_detection_disks() |
473 | { |
474 | local bootdev |
475 | |
476 | # all disks but exclude ramdisks |
477 | export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') |
478 | # remove the boot device from ALL_DISKS if it was an usbstick |
479 | if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] |
480 | then |
481 | bootdev="$(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')" |
482 | export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") |
483 | fi |
484 | export ALL_CDROMS="$(get_hwinfo cdrom)" |
485 | } |
486 | |
487 | hdd_size_below_256mb() |
488 | { |
489 | local hdd="$1" |
490 | local size |
491 | local retval |
492 | [[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!" |
493 | |
494 | size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') |
495 | if [[ ${size} -le 257000000 ]] |
496 | then |
497 | retval="0" |
498 | else |
499 | retval="1" |
500 | fi |
501 | |
502 | return "${retval}" |
503 | } |
504 | |
505 | setup_hdd_partitions() |
506 | { |
507 | case "${INSTALL_METHOD}" in |
508 | normal) |
509 | BOOTHDD="${HDD}1" |
510 | SWAPHDD="${HDD}2" |
511 | ROOTHDD="${HDD}3" |
512 | ;; |
513 | |
514 | single|auto) |
515 | BOOTHDD="" |
516 | SWAPHDD="" |
517 | ROOTHDD="${HDD}1" |
518 | ;; |
519 | |
520 | flash) |
521 | BOOTHDD="${HDD}1" |
522 | SWAPHDD="" |
523 | ROOTHDD="${HDD}2" |
524 | ;; |
525 | esac |
526 | |
527 | if [[ ${INSTALL_METHOD} = auto ]] |
528 | then |
529 | # run this only if FDISKPARTITIONBELOW256MB is not already 1 |
530 | if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
531 | then |
532 | if hdd_size_below_256mb ${HDD} |
533 | then |
534 | FDISKPARTIONBELOW256MB=1 |
535 | else |
536 | FDISKPARTIONBELOW256MB=0 |
537 | fi |
538 | fi |
539 | |
540 | ## delete disk |
541 | dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die |
542 | |
543 | if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
544 | then |
545 | ## setup one bootable partition |
546 | #1. n= new disk |
547 | #2. p= primary disk |
548 | #3. 1= first partition |
549 | #4. 2= default sector start // small disk needs more space for grub2 mbr sector |
550 | #5. ''= defaul sector end |
551 | #6. a= bootable flag |
552 | #7. 1= boot flag for partition 1 |
553 | #8. w= write/quit |
554 | fdisk ${HDD} &> /dev/null << EOF |
555 | n |
556 | p |
557 | 1 |
558 | 2 |
559 | |
560 | a |
561 | 1 |
562 | w |
563 | EOF |
564 | else |
565 | ## setup one bootable partition |
566 | #1. n= new disk |
567 | #2. p= primary disk |
568 | #3. 1= first partition |
569 | #4. ''= default sector start |
570 | #5. ''= defaul sector end |
571 | #6. a= bootable flag |
572 | #7. 1= boot flag for partition 1 |
573 | #8. w= write/quit |
574 | fdisk ${HDD} &> /dev/null << EOF |
575 | n |
576 | p |
577 | 1 |
578 | |
579 | |
580 | a |
581 | 1 |
582 | w |
583 | EOF |
584 | fi |
585 | else |
586 | ## hdds partitionieren manuell |
587 | cfdisk ${HDD} || die |
588 | fi |
589 | } |
590 | |
591 | setup_hdd_format() |
592 | { |
593 | install -d /tmp |
594 | :> /tmp/format.log |
595 | |
596 | if [[ -n ${SWAPHDD} ]] |
597 | then |
598 | mkswap ${SWAPHDD} || die |
599 | fi |
600 | if [[ -n ${BOOTHDD} ]] |
601 | then |
602 | mkfs.${FORMAT_FILESYSTEM_BOOTHDD} ${BOOTHDD} &> /tmp/format.log || die |
603 | fi |
604 | if [[ -n ${ROOTHDD} ]] |
605 | then |
606 | mkfs.${FORMAT_FILESYSTEM_ROOTHDD} ${ROOTHDD} &> /tmp/format.log || die |
607 | fi |
608 | } |
609 | |
610 | install_mount_rootfs() |
611 | { |
612 | local opts |
613 | |
614 | if [[ -n ${SWAPHDD} ]] |
615 | then |
616 | swapon ${SWAPHDD} || die |
617 | fi |
618 | if [[ -n ${ROOTHDD} ]] |
619 | then |
620 | mount -t ${FORMAT_FILESYSTEM_ROOTHDD} ${ROOTHDD} ${INSTALL_ROOT} || die |
621 | fi |
622 | if [[ -n ${BOOTHDD} ]] |
623 | then |
624 | install -d ${INSTALL_ROOT}/boot || die |
625 | mount -t ${FORMAT_FILESYSTEM_BOOTHDD} ${BOOTHDD} ${INSTALL_ROOT}/boot || die |
626 | fi |
627 | |
628 | cd ${INSTALL_ROOT} || die |
629 | } |
630 | |
631 | install_system_image() |
632 | { |
633 | tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALL_ROOT} |
634 | } |
635 | |
636 | install_bootsector_chroot() |
637 | { |
638 | local my_roothdd |
639 | local grubconf=${INSTALL_ROOT}/boot/grub/grub.conf |
640 | local grub2conf=/boot/grub/grub.cfg |
641 | local CONFIG |
642 | |
643 | # check for grub2 |
644 | if [[ -f ${INSTALL_ROOT}/sbin/grub-mkconfig ]] |
645 | then |
646 | # needed by grub-mkconfig on the first run |
647 | if [[ ! -f ${INSTALL_ROOT}/boot/grub/video.lst ]] |
648 | then |
649 | install -m0644 ${INSTALL_ROOT}/lib/grub/*/video.lst ${INSTALL_ROOT}/boot/grub/video.lst || die |
650 | fi |
651 | |
652 | # set kernelopts |
653 | if [[ -f ${INSTALL_ROOT}/etc/conf.d/grub ]] |
654 | then |
655 | sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die |
656 | sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die |
657 | else |
658 | CONFIG=${INSTALL_ROOT}/etc/conf.d/grub |
659 | clearconfig |
660 | addconfig "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" |
661 | addconfig "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" |
662 | fi |
663 | CONFIG=${INSTALL_ROOT}/.installrc |
664 | clearconfig |
665 | addconfig 'grub-mkdevicemap' |
666 | addconfig "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" |
667 | addconfig "grub-install --no-floppy ${HDD} &> /dev/null" |
668 | addconfig "exit 0" |
669 | |
670 | # grub-legacy |
671 | else |
672 | ### grubconf schreiben |
673 | source ${INSTALL_ROOT}/boot/kernelversion |
674 | |
675 | #for alx only |
676 | if [ -e ${INSTALL_ROOT}/etc/alx_version ] |
677 | then |
678 | OLD_ALXVER="${ALXVER}" |
679 | source ${INSTALL_ROOT}/etc/alx_version |
680 | KRNVER="ALX-${ALXVER}" |
681 | ALXVER="${OLD_ALXVER}" |
682 | fi |
683 | |
684 | [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX" |
685 | [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd" |
686 | [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz" |
687 | |
688 | # uuid support |
689 | if is_uuid_supported |
690 | then |
691 | my_roothdd="UUID=$(get_uuid ${ROOTHDD})" |
692 | else |
693 | my_roothdd="${ROOTHDD}" |
694 | fi |
695 | |
696 | CONFIG="${grubconf}" |
697 | clearconfig |
698 | addconfig "default 0" |
699 | addconfig "timeout 3" |
700 | # using current root password |
701 | addconfig "password --md5 $(cat ${INSTALL_ROOT}/etc/shadow | grep root | cut -d: -f2)" |
702 | addconfig |
703 | addconfig "# normal boot" |
704 | addconfig "title ${KRNVER}" |
705 | addconfig "root (hd0,0)" |
706 | addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" |
707 | if is_initrd_supported |
708 | then |
709 | addconfig "initrd /boot/${KRNINITRD}" |
710 | fi |
711 | addconfig |
712 | addconfig "# admin boot" |
713 | addconfig "title ${KRNVER} - Re-run hardware-detection" |
714 | addconfig "lock" |
715 | addconfig "root (hd0,0)" |
716 | addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" |
717 | if is_initrd_supported |
718 | then |
719 | addconfig "initrd /boot/${KRNINITRD}" |
720 | fi |
721 | addconfig |
722 | addconfig "title ${KRNVER} - Reset *all* local settings" |
723 | addconfig "lock" |
724 | addconfig "root (hd0,0)" |
725 | addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" |
726 | if is_initrd_supported |
727 | then |
728 | addconfig "initrd /boot/${KRNINITRD}" |
729 | fi |
730 | |
731 | # write bootsector chrooted (lfs/magellan) |
732 | CONFIG=${INSTALL_ROOT}/.installrc |
733 | clearconfig |
734 | addconfig '/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null' |
735 | addconfig 'root (hd0,0)' |
736 | addconfig 'setup (hd0)' |
737 | addconfig 'quit' |
738 | addconfig 'EOF' |
739 | addconfig 'exit 0' |
740 | fi |
741 | |
742 | ## enter chroot |
743 | enter_chroot_installrc |
744 | } |
745 | |
746 | is_initrd_supported() |
747 | { |
748 | # only generate initrds if the cmd exists |
749 | [[ -x ${INSTALL_ROOT}/sbin/mkinitrd ]] && return 0 |
750 | return 1 |
751 | } |
752 | |
753 | install_initrd_chroot() |
754 | { |
755 | local CONFIG |
756 | |
757 | # only generate initrds if the cmd exists |
758 | is_initrd_supported || return 0 |
759 | |
760 | FSMODS="${FORMAT_FILESYSTEM_BOOTHDD} ${FORMAT_FILESYSTEM_ROOTHDD}" |
761 | DISKMODS="sd_mod" |
762 | OLDPATAMODS="amd74xx piix sis5513 via82cxxx" |
763 | PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" |
764 | SATAMODS="sata_via sata_sis sata_nv" |
765 | DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" |
766 | OTHERMODS="" |
767 | case ${SPECIALDEVICE} in |
768 | zotac_intel|i845) FBMODS=""; DRMMODS="i915" ;; |
769 | zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;; |
770 | rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards |
771 | # not working with kms enabled drivers -> segfaults |
772 | #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer |
773 | maxdata) FBMODS="" ;; |
774 | *) FBMODS="uvesafb" ;; |
775 | esac |
776 | |
777 | if [[ ${FORMFACTOR} = laptop ]] |
778 | then |
779 | OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave" |
780 | fi |
781 | |
782 | # install an appropriate uvesafb.conf |
783 | CONFIG=${INSTALL_ROOT}/etc/modprobe.d/uvesafb.conf |
784 | clearconfig |
785 | addconfig "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" |
786 | |
787 | # install an appropriate viafb.conf |
788 | CONFIG=${INSTALL_ROOT}/etc/modprobe.d/viafb.conf |
789 | clearconfig |
790 | addconfig "options viafb viafb_mode=1024x768 viafb_refresh=60" |
791 | |
792 | # install an appropriate i810fb.conf |
793 | CONFIG=${INSTALL_ROOT}/etc/modprobe.d/i810fb.conf |
794 | clearconfig |
795 | addconfig "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60" |
796 | |
797 | CONFIG=${INSTALL_ROOT}/.installrc |
798 | clearconfig |
799 | addconfig 'echo "MODULES=\"${FSMODS} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd' |
800 | addconfig 'mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null' |
801 | addconfig 'exit 0' |
802 | ## enter chroot |
803 | enter_chroot_installrc |
804 | } |
805 | |
806 | is_uuid_supported() |
807 | { |
808 | # f2fs needs special treatments as the old busybox does not support this fs |
809 | # use the blkid from util-linux instead of busybox |
810 | if [[ ${FORMAT_FILESYSTEM} = f2fs ]] |
811 | then |
812 | if [[ -x $(type -P blkid) ]] |
813 | then |
814 | return 0 |
815 | fi |
816 | else |
817 | if [[ -x $(type -P busybox.mkinitrd) ]] |
818 | then |
819 | # only detect uuids if supported |
820 | if [[ ! -z $(busybox.mkinitrd | grep blkid) ]] |
821 | then |
822 | return 0 |
823 | fi |
824 | fi |
825 | fi |
826 | |
827 | return 1 |
828 | } |
829 | |
830 | get_uuid() |
831 | { |
832 | local UUID |
833 | local SEC_TYPE |
834 | local TYPE |
835 | local blkidcmd |
836 | |
837 | local dev="$1" |
838 | [[ -z ${dev} ]] && die "no dev given" |
839 | |
840 | # check if given device is already an UUID |
841 | if [[ ${dev/UUID=/}x != ${dev}x ]] |
842 | then |
843 | eval "${dev}" |
844 | else |
845 | # f2fs needs special treatments as the old busybox does not support this fs |
846 | # use the blkid from util-linux instead of busybox |
847 | if [[ ${FORMAT_FILESYSTEM} = f2fs ]] |
848 | then |
849 | blkidcmd="blkid" |
850 | else |
851 | blkidcmd="busybox.mkinitrd blkid" |
852 | fi |
853 | eval $(${blkidcmd} ${dev} | grep "${dev}:" | sed 's/.*:\ //') |
854 | fi |
855 | echo "${UUID}" |
856 | } |
857 | |
858 | install_system_settings() |
859 | { |
860 | local CONFIG |
861 | local fstype |
862 | |
863 | # write fstab |
864 | CONFIG=${INSTALL_ROOT}/etc/fstab |
865 | clearconfig |
866 | |
867 | if [[ -n ${BOOTHDD} ]] |
868 | then |
869 | if is_uuid_supported |
870 | then |
871 | addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime,noauto\t1 1" |
872 | else |
873 | addconfig -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime,noauto\t1 1" |
874 | fi |
875 | fi |
876 | |
877 | if [[ -n ${ROOTHDD} ]] |
878 | then |
879 | if is_uuid_supported |
880 | then |
881 | addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0" |
882 | else |
883 | addconfig -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0" |
884 | fi |
885 | fi |
886 | |
887 | # not needed busybox loads all with swapon -a, even if not mentioned in fstab |
888 | #addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" |
889 | addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" |
890 | addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" |
891 | |
892 | # install network config skeleton |
893 | install -m0644 ${INSTALL_ROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALL_ROOT}/etc/conf.d/ || die |
894 | |
895 | # intel framebufer quirk |
896 | if [[ -e /proc/fb ]] |
897 | then |
898 | if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] |
899 | then |
900 | fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') |
901 | if [[ ${fbdev} != 0 ]] |
902 | then |
903 | sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALL_ROOT}/etc/splash/splash.conf || die |
904 | fi |
905 | fi |
906 | fi |
907 | } |
908 | |
909 | install_umount_rootfs() |
910 | { |
911 | cd / |
912 | if [[ -n ${BOOTHDD} ]] |
913 | then |
914 | umount ${INSTALL_ROOT}/boot || die |
915 | fi |
916 | if [[ -n ${ROOTHDD} ]] |
917 | then |
918 | umount ${INSTALL_ROOT} || die |
919 | fi |
920 | if [[ -n ${SWAPHDD} ]] |
921 | then |
922 | swapoff ${SWAPHDD} || die |
923 | fi |
924 | } |
925 | |
926 | install_do_reboot() |
927 | { |
928 | reboot |
929 | } |
930 | |
931 | ################################################# |
932 | # Install Main Scripts # |
933 | ################################################# |
934 | |
935 | run_install() |
936 | { |
937 | local method="$1" |
938 | |
939 | # setup install environment |
940 | export KERNELOPTS="${DEFAULT_KERNELOPTS}" |
941 | export GRUBLEGACYOPTS="${GRUBLEGACYOPTS}" |
942 | export GRUB2OPTS="${GRUB2OPTS}" |
943 | export GRUB2GFXPAYLOAD="${DEFAULT_GRUB2GFXPAYLOAD}" |
944 | export FORMFACTOR="${DEFAULT_FORMFACTOR}" |
945 | export FORMAT_FILESYSTEM="${DEFAULT_FORMAT_FILESYSTEM}" |
946 | |
947 | case "${method}" in |
948 | auto) |
949 | export FORMAT_FILESYSTEM_BOOTHDD="" |
950 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
951 | export INSTALL_METHOD="${method}" |
952 | ;; |
953 | normal) |
954 | export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" |
955 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
956 | export INSTALL_METHOD="${method}" |
957 | ;; |
958 | single) |
959 | export FORMAT_FILESYSTEM_BOOTHDD="" |
960 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
961 | export INSTALL_METHOD="${method}" |
962 | ;; |
963 | flash) |
964 | export FORMAT_FILESYSTEM="f2fs" |
965 | export FORMAT_FILESYSTEM_BOOTHDD="ext2" |
966 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
967 | export INSTALL_METHOD="${method}" |
968 | ;; |
969 | *) |
970 | die "Unknown install method '${method}', aborting." |
971 | ;; |
972 | esac |
973 | |
974 | dialog_hardware_detection |
975 | |
976 | dialog_setup_hdd_partitions |
977 | dialog_setup_hdd_format |
978 | setup_hdd_format > /dev/null |
979 | install_mount_rootfs |
980 | (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image |
981 | |
982 | dialog_install_settings |
983 | sleep 1 |
984 | install_system_settings |
985 | install_initrd_chroot |
986 | |
987 | dialog_install_bootsector |
988 | install_bootsector_chroot |
989 | |
990 | install_umount_rootfs |
991 | dialog_install_successful |
992 | } |
993 | |
994 | # set some proper traps |
995 | trap "trap_exit" SIGINT SIGQUIT |
996 | |
997 | dialog_main |
998 | |
999 | exit 0 |