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