Magellan Linux

Annotation of /alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in

Parent Directory Parent Directory | Revision Log Revision Log


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