Magellan Linux

Annotation of /trunk/installer-simple/bin/installer.sh.in

Parent Directory Parent Directory | Revision Log Revision Log


Revision 2417 - (hide annotations) (download)
Tue Jan 7 13:42:08 2014 UTC (10 years, 10 months ago) by niro
File size: 20913 byte(s)
dialog_hardware_detection(): use messagebox()
1 niro 2323 #!/bin/bash
2 niro 2322 # $Id$
3 niro 2320 #
4 niro 2322 # Simple Installation Script
5     # merged from alxinstall-ng and mcore-installer
6 niro 2320 #
7     # Niels Rogalla <niro@magellan-linux.de>
8     #
9    
10 niro 2339 # ignore the environment
11     LC_ALL=C
12 niro 2340 # include dir
13 niro 2333 INSTALLER_LIBDIR="%LIBDIR%"
14    
15 niro 2340 # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 !
16     # -> now in images.conf
17     CURRENTLINE=0
18    
19 niro 2397 die()
20     {
21     echo "Error: $@"
22     exit 1
23     }
24    
25 niro 2401 # load common includes
26 niro 2402 for inc in %SYSCONFDIR%/installer.conf \
27     ${INSTALLER_LIBDIR}/functions/common.sh \
28     ${INSTALLER_LIBDIR}/functions/common-dialogs.sh \
29     ${INSTALLER_LIBDIR}/functions/hwdetection.sh \
30     ${INSTALLER_LIBDIR}/functions/installer-dialogs.sh
31 niro 2401 do
32     if [ -e ${inc} ]
33     then
34     source "${inc}"
35     else
36     die "'${inc}' not found"
37     fi
38     done
39 niro 2332
40 niro 2340 # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 !
41     # -> now in images.conf
42     CDIMAGENAME=""
43     TOTALLINES=""
44     CURRENTLINE=0
45 niro 2334 if [ -e /mnt/cdrom/system/images.conf ]
46     then
47     source /mnt/cdrom/system/images.conf
48 niro 2340 # check if all required variables are set
49     [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in /mnt/cdrom/system/images.conf"
50     [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in /mnt/cdrom/system/images.conf"
51 niro 2334 else
52     die "/mnt/cdrom/system/images.conf not found"
53     fi
54 niro 2320
55     ### System/Config Version
56     VERSION="%VERSIONTAG%"
57 niro 2332 TITLE="${DEFAULT_TITLE} - ${VERSION}"
58 niro 2320
59 niro 2404 # some sane defaults
60 niro 2343 CDROOT="${DEFAULT_CDROOT}"
61 niro 2342 INSTALLROOT="${DEFAULT_INSTALLROOT}"
62 niro 2404 KERNELPKG="${DEFAULT_KERNELPKG}"
63     KERNELOPTS="${DEFAULT_KERNELOPTS}"
64 niro 2320 GRUBLEGACYOPTS=""
65     GRUB2OPTS=""
66     FDISKPARTIONBELOW256MB=0
67     SPECIALDEVICE=""
68 niro 2404 FORMFACTOR="${DEFAULT_FORMFACTOR}"
69 niro 2332 FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}"
70 niro 2320
71     #################################################
72     # DIALOG BOXEN #
73     #################################################
74    
75 niro 2409 trap_exit()
76     {
77     is_mounted --location "${INSTALLROOT}/dev" && umount ${INSTALLROOT}/dev
78     is_mounted --location "${INSTALLROOT}/proc" && umount ${INSTALLROOT}/proc
79     is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys
80     is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot
81     is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT}
82    
83     echo $"Installation aborted."
84     exit 1
85     }
86    
87 niro 2336 dialog_die()
88     {
89 niro 2341 ERROR="$1"
90     RETVAL="$?"
91 niro 2320 dialog_install_failure
92     exit 1
93     }
94    
95     dialog_warning()
96     {
97 niro 2398 local retval
98    
99     yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?"
100     retval=$?
101     if [[ ${retval} -eq 1 ]]
102 niro 2320 then
103     clear
104 niro 2398 echo $"The process was aborted."
105 niro 2320 exit 1
106     fi
107     }
108    
109     dialog_setup_hdd_info()
110     {
111 niro 2410 local SHDD="${HDD//\/dev\/}"
112 niro 2320
113 niro 2411 messagebox -h $"[ Harddrive partitioning ]" \
114     $"\nPlease create 1 partition.\n\n\[ \Z3${SHDD}1\Zn ] type: \Z3linux\Zn with the whole diskspace\n\Please mark ${SHDD}1 \Z3bootable\Zn."
115 niro 2320 }
116    
117     dialog_setup_hdd_info_auto()
118     {
119 niro 2410 local SHDD="${HDD//\/dev\/}"
120 niro 2320
121 niro 2411 messagebox -h $"[ Harddrive partitioning ]" \
122     $"\Z1Warning!\Zn\n\nAll data on disk [ \Z3${HDD}\Zn ] will be erased!"
123 niro 2320 }
124    
125     dialog_setup_system_menu()
126     {
127 niro 2412 local mode
128     local retval
129 niro 2320
130 niro 2416 mode=$(menubox -h $"[ Harddrive partitioning ]" $"\nSelect an installation mode" \
131     $"1:Automatic setup (recommended)" \
132     ":" \
133     $":\Z1Expert modes:\Zn" \
134     $"2:Common IDE-disk (manual setup)")
135 niro 2412 retval=$?
136     [[ ${retval} -eq 1 ]] && return 1
137     if [[ ${retval} -eq 0 ]]
138 niro 2320 then
139 niro 2415 case "${mode}" in
140 niro 2320 "1") run_install_auto ;;
141 niro 2341 "2") run_install_normal ;;
142 niro 2320 "") dialog_setup_system_menu;;
143     esac
144     fi
145     }
146    
147     dialog_hardware_detection()
148     {
149 niro 2417 local message
150 niro 2320
151 niro 2344 run_hardware_detection_disks
152 niro 2320
153 niro 2417 message+=$"Harddrives:\n"
154 niro 2320
155 niro 2344 if [[ ! -z ${ALL_DISKS} ]]
156 niro 2320 then
157 niro 2344 for i in ${ALL_DISKS}
158 niro 2320 do
159 niro 2417 message+="\Z3${i}\Zn "
160 niro 2320 done
161 niro 2417 message+="\n"
162 niro 2320 fi
163    
164 niro 2344 if [[ ! -z ${ALL_CDROMS} ]]
165 niro 2320 then
166 niro 2417 message+="\n"
167     message+=$"Optical disk drives:\n"
168 niro 2344 for i in ${ALL_CDROMS}
169 niro 2320 do
170 niro 2417 message+="\Z3${i}\Zn"
171 niro 2320 done
172 niro 2417 message+="\n"
173 niro 2320 fi
174    
175     # other devices
176     run_hardware_detection
177     case "${SPECIALDEVICE}" in
178 niro 2417 zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;;
179     rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;;
180     maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;;
181     *) message+=$"\n \\ZnCommon device detected.\Zn" ;;
182 niro 2320 esac
183     if [[ ${FORMFACTOR} = laptop ]]
184     then
185 niro 2417 message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn"
186 niro 2320 fi
187    
188 niro 2417 messagebox -y 15 -h $"Detected hardware:" "${message}"
189 niro 2320 }
190    
191 niro 2413 dialog_setup_hdd_partitions_manual()
192 niro 2320 {
193     local i
194    
195     if [[ -z ${installdevs} ]]
196     then
197     dialog \
198     --backtitle "${TITLE}" \
199     --ok-label "Beenden" \
200     --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70
201     exit 1
202     else
203    
204     echo "dialog \\" > /tmp/hddtmp.sh
205     echo "--backtitle \"${TITLE}\" \\" >> /tmp/hddtmp.sh
206     echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh
207     echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh
208     echo "--stdout \\" >> /tmp/hddtmp.sh
209     echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh
210    
211     for i in ${installdevs}
212     do
213     echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh
214     done
215     echo -e "\n" >> /tmp/hddtmp.sh
216    
217     chmod a+x /tmp/hddtmp.sh
218     HDD="$(/tmp/hddtmp.sh)"
219     RES=$?
220     [[ ${RES} -eq 1 ]] && return 1
221     if [[ ${RES} -eq 0 ]]
222     then
223     dialog_setup_hdd_info
224 niro 2413 setup_hdd_partitions_manual
225 niro 2320 fi
226     fi
227     }
228    
229     dialog_setup_hdd_partitions_auto()
230     {
231     local i
232    
233     if [[ -z ${installdevs} ]]
234     then
235     dialog \
236     --backtitle "${TITLE}" \
237     --ok-label "Beenden" \
238     --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70
239     exit 1
240     else
241    
242     echo "dialog \\" > /tmp/hddtmp.sh
243     echo "--backtitle \"${TITLE}\" \\" >> /tmp/hddtmp.sh
244     echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh
245     echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh
246     echo "--stdout \\" >> /tmp/hddtmp.sh
247     echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh
248    
249     for i in ${installdevs}
250     do
251     echo "\"${i}\" \"\" \\" >> /tmp/hddtmp.sh
252     done
253     echo -e "\n" >> /tmp/hddtmp.sh
254    
255     chmod a+x /tmp/hddtmp.sh
256     HDD="$(/tmp/hddtmp.sh)"
257     RES=$?
258     [[ ${RES} -eq 1 ]] && return 1
259     if [[ ${RES} -eq 0 ]]
260     then
261     dialog_setup_hdd_info_auto
262     dialog_setup_hdd_create_partitions
263     setup_hdd_partitions_auto
264     fi
265     fi
266     }
267    
268 niro 2344 run_hardware_detection_disks()
269     {
270     local bootdev
271    
272     # all disks but exclude ramdisks
273     export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d')
274     # remove the boot device from ALL_DISKS if it was an usbstick
275     if [[ $(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]]
276     then
277     bootdev="$(grep '[[:space:]]/mnt/cdrom[[:space:]]' /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g')"
278     export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}")
279     fi
280     export ALL_CDROMS="$(get_hwinfo cdrom)"
281     }
282    
283 niro 2320 dialog_setup_hdd_create_partitions()
284     {
285     dialog \
286     --backtitle "${TITLE}" \
287     --infobox "Erstelle Disk Partitionen ..." 3 70
288     }
289    
290     dialog_setup_hdd_format()
291     {
292     dialog \
293     --backtitle "${TITLE}" \
294     --infobox "Erstelle Datei-Systeme ..." 3 70
295     }
296    
297     dialog_install_settings()
298     {
299     dialog \
300     --backtitle "${TITLE}" \
301     --infobox "Speichere System-Einstellungen ..." 3 70
302     }
303    
304     dialog_install_system_image()
305     {
306     dialog \
307     --backtitle "${TITLE}" \
308     --gauge "Kopiere System-Image ..." 6 80
309     }
310    
311     dialog_install_meter()
312     {
313     while [[ ${CURRENTLINE} != ${TOTALLINES} ]]
314     do
315     CURRENTLINE=$(grep -c . /tmp/install.log)
316     PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES}))
317     echo ${PERCENT}
318     sleep 1
319     done
320     rm -f /tmp/install.log
321     return 0
322     }
323    
324    
325     dialog_install_bootsector()
326     {
327     dialog \
328     --backtitle "${TITLE}" \
329     --infobox "Schreibe den Bootsektor ..." 3 70
330     }
331    
332     dialog_install_successful()
333     {
334     dialog \
335     --backtitle "${TITLE}" \
336     --colors \
337     --msgbox "Die Installation war \Z2erfolgreich\Zn." 5 81
338     }
339    
340     dialog_install_failure()
341     {
342     dialog \
343     --backtitle "${TITLE}" \
344     --colors \
345     --msgbox "Die Installation ist \Z1Fehlgeschlagen\Zn.\n\n\
346     Fehler bei ${ERROR}, RetVal: ${RETVAL} \
347     " 10 81
348     }
349    
350     dialog_main()
351     {
352     METHOD=0
353    
354     while [[ ${METHOD} -le 2 ]]
355     do
356     METHOD=$(dialog \
357     --backtitle "${TITLE}" \
358     --no-cancel \
359     --ok-label "Weiter" \
360     --stdout \
361     --menu "Konfiguration" 14 70 5 \
362     "1" "AutoSta_LX installieren" \
363     "2" "Uebersicht gefundener Laufwerke" \
364     "3" "Beenden und neustarten" \
365     "4" "Beenden und eine Shell starten")
366     RES=$?
367     [[ ${RES} -eq 1 ]] && exit 1
368     if [[ ${RES} -eq 0 ]]
369     then
370     case ${METHOD} in
371 niro 2341 "1") dialog_setup_system_menu ;;
372 niro 2320 "2") dialog_hardware_detection ;;
373     "3") install_do_reboot ;;
374     "4") /bin/bash --login -i ;;
375     esac
376     fi
377     done
378     }
379    
380     #################################################
381     # Install Komandos #
382     #################################################
383     run_hardware_detection()
384     {
385     local hwinfo
386    
387     hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)"
388    
389     # check for special devices/clients:
390     # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd
391     local removable=0
392     if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]]
393     then
394     for i in /sys/block/[hs]d*/removable
395     do
396     if [[ $(< ${i}) = 1 ]]
397     then
398     removable=1
399     fi
400     done
401    
402     # only add this for grub legacy, grub2 detect these settings on its own
403     export GRUBLEGACYOPTS="rootdelay=8"
404     # there are to zotac types in the wild, nvidia based gfx and intel
405     if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]]
406     then
407     export SPECIALDEVICE="zotac_nvidia"
408     else
409     export SPECIALDEVICE="zotac_intel"
410     fi
411     fi
412    
413     # check for special devices/clients:
414     # if a rangee and disk ist smaller then 256mb move partion one block further ahead
415     if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]]
416     then
417     # for a rangee always define partion startblock +1
418     export FDISKPARTIONBELOW256MB="1"
419     export SPECIALDEVICE="rangee"
420     export GRUBLEGACYOPTS=""
421     fi
422    
423     # check for special devices/clients:
424     # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
425     if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]]
426     then
427     export SPECIALDEVICE="maxdata"
428     export GRUBLEGACYOPTS=""
429     fi
430    
431     # check for special devices/clients:
432     # check for laptops and activate cpufreq scaling
433     if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]]
434     then
435     export FORMFACTOR="laptop"
436     export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand"
437     fi
438     }
439    
440     hdd_size_below_256mb()
441     {
442     local hdd="$1"
443     local size
444     local retval
445 niro 2336 [[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!"
446 niro 2320
447     size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:')
448     if [[ ${size} -le 257000000 ]]
449     then
450     retval="0"
451     else
452     retval="1"
453     fi
454    
455     return "${retval}"
456     }
457    
458     setup_hdd_partitions_auto()
459     {
460     ROOTHDD="${HDD}1"
461    
462     # run this only if FDISKPARTITIONBELOW256MB is not already 1
463     if [[ ${FDISKPARTIONBELOW256MB} != 1 ]]
464     then
465     if hdd_size_below_256mb ${HDD}
466     then
467     FDISKPARTIONBELOW256MB=1
468     else
469     FDISKPARTIONBELOW256MB=0
470     fi
471     fi
472    
473     ## delete disk
474 niro 2336 dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die
475 niro 2320
476     if [[ ${FDISKPARTIONBELOW256MB} = 1 ]]
477     then
478     ## setup one bootable partition
479     #1. n= new disk
480     #2. p= primary disk
481     #3. 1= first partition
482     #4. 2= default sector start // small disk needs more space for grub2 mbr sector
483     #5. ''= defaul sector end
484     #6. a= bootable flag
485     #7. 1= boot flag for partition 1
486     #8. w= write/quit
487     fdisk ${HDD} &> /dev/null << EOF
488     n
489     p
490     1
491     2
492    
493     a
494     1
495     w
496     EOF
497     else
498     ## setup one bootable partition
499     #1. n= new disk
500     #2. p= primary disk
501     #3. 1= first partition
502     #4. ''= default sector start
503     #5. ''= defaul sector end
504     #6. a= bootable flag
505     #7. 1= boot flag for partition 1
506     #8. w= write/quit
507     fdisk ${HDD} &> /dev/null << EOF
508     n
509     p
510     1
511    
512    
513     a
514     1
515     w
516     EOF
517     fi
518     }
519    
520 niro 2413 setup_hdd_partitions_manual()
521 niro 2320 {
522     ROOTHDD="${HDD}1"
523    
524 niro 2413 ## hdds partitionieren manual
525 niro 2336 cfdisk ${HDD} || dialog_die
526 niro 2320 }
527    
528     setup_hdd_format()
529     {
530 niro 2336 mke2fs -j -q ${ROOTHDD} || dialog_die
531 niro 2320 }
532    
533     install_mount_rootfs()
534     {
535 niro 2342 mount ${ROOTHDD} ${INSTALLROOT} || dialog_die
536     install -d ${INSTALLROOT}/boot || dialog_die
537     cd ${INSTALLROOT} || dialog_die
538 niro 2320 }
539    
540     install_system_image()
541     {
542 niro 2343 tar xvjpf ${CDROOT}/system/${CDIMAGENAME} -C ${INSTALLROOT}
543 niro 2320 }
544    
545     install_bootsector_chroot()
546     {
547     local my_roothdd
548 niro 2342 local grubconf=${INSTALLROOT}/boot/grub/grub.conf
549 niro 2320 local grub2conf=/boot/grub/grub.cfg
550    
551     # check for grub2
552 niro 2342 if [[ -f ${INSTALLROOT}/sbin/grub-mkconfig ]]
553 niro 2320 then
554     # needed by grub-mkconfig on the first run
555 niro 2342 if [[ ! -f ${INSTALLROOT}/boot/grub/video.lst ]]
556 niro 2320 then
557 niro 2342 install -m0644 ${INSTALLROOT}/lib/grub/*/video.lst ${INSTALLROOT}/boot/grub/video.lst || dialog_die
558 niro 2320 fi
559    
560     # set kernelopts
561 niro 2342 if [[ -f ${INSTALLROOT}/etc/conf.d/grub ]]
562 niro 2320 then
563 niro 2342 sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLROOT}/etc/conf.d/grub || dialog_die
564 niro 2320 else
565 niro 2342 echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALLROOT}/etc/conf.d/grub || dialog_die
566 niro 2320 fi
567 niro 2342 echo 'grub-mkdevicemap' > ${INSTALLROOT}/root/.installrc || dialog_die
568     echo "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" >> ${INSTALLROOT}/root/.installrc || dialog_die
569     echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLROOT}/root/.installrc || dialog_die
570     echo "exit 0" >> ${INSTALLROOT}/root/.installrc || dialog_die
571 niro 2320
572     # grub-legacy
573     else
574     ### grubconf schreiben
575 niro 2342 source ${INSTALLROOT}/boot/kernelversion
576 niro 2320
577     #for alx only
578 niro 2342 if [ -e ${INSTALLROOT}/etc/alx_version ]
579 niro 2320 then
580     OLD_ALXVER="${ALXVER}"
581 niro 2342 source ${INSTALLROOT}/etc/alx_version
582 niro 2320 KRNVER="ALX-${ALXVER}"
583     ALXVER="${OLD_ALXVER}"
584     fi
585    
586     [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX"
587     [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd"
588     [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz"
589    
590     # uuid support
591     if is_uuid_supported
592     then
593     my_roothdd="UUID=$(get_uuid ${ROOTHDD})"
594     else
595     my_roothdd="${ROOTHDD}"
596     fi
597    
598 niro 2336 : > ${grubconf} || dialog_die
599     echo "default 0" >> ${grubconf} || dialog_die
600     echo "timeout 3" >> ${grubconf} || dialog_die
601 niro 2320 # using current root password
602 niro 2342 echo "password --md5 $(cat ${INSTALLROOT}/etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} || dialog_die
603 niro 2320
604 niro 2336 echo >> ${grubconf} || dialog_die
605     echo "# normal boot" >> ${grubconf} || dialog_die
606     echo "title ${KRNVER}" >> ${grubconf} || dialog_die
607     echo "root (hd0,0)" >> ${grubconf} || dialog_die
608     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || dialog_die
609 niro 2320 if is_initrd_supported
610     then
611 niro 2336 echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die
612 niro 2320 fi
613    
614 niro 2336 echo >> ${grubconf} || dialog_die
615     echo "# admin boot" >> ${grubconf} || dialog_die
616     echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || dialog_die
617     echo "lock" >> ${grubconf} || dialog_die
618     echo "root (hd0,0)" >> ${grubconf} || dialog_die
619     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || dialog_die
620 niro 2320 if is_initrd_supported
621     then
622 niro 2336 echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die
623 niro 2320 fi
624    
625 niro 2336 echo >> ${grubconf} || dialog_die
626     echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || dialog_die
627     echo "lock" >> ${grubconf} || dialog_die
628     echo "root (hd0,0)" >> ${grubconf} || dialog_die
629     echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || dialog_die
630 niro 2320 if is_initrd_supported
631     then
632 niro 2336 echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die
633 niro 2320 fi
634    
635     # bootsector schreiben chrooted schreiben (lfs/magellan)
636 niro 2342 cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF
637 niro 2320 /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null
638     root (hd0,0)
639     setup (hd0)
640     quit
641     EOF
642     exit 0
643     CHROOTEOF
644     fi
645    
646 niro 2336 ## enter chroot
647 niro 2342 mount -t proc proc ${INSTALLROOT}/proc
648     mount -t sysfs sysfs ${INSTALLROOT}/sys
649     mount -o bind /dev ${INSTALLROOT}/dev
650     chroot ${INSTALLROOT} /bin/bash --rcfile /root/.installrc -i
651     umount ${INSTALLROOT}/proc
652     umount ${INSTALLROOT}/sys
653     umount ${INSTALLROOT}/dev
654     rm ${INSTALLROOT}/root/.installrc
655 niro 2320 }
656    
657     is_initrd_supported()
658     {
659     # only generate initrds if the cmd exists
660 niro 2342 [[ -x ${INSTALLROOT}/sbin/mkinitrd ]] && return 0
661 niro 2320 return 1
662     }
663    
664     install_initrd_chroot()
665     {
666     # only generate initrds if the cmd exists
667     is_initrd_supported || return 0
668    
669     DISKMODS="sd_mod"
670     OLDPATAMODS="amd74xx piix sis5513 via82cxxx"
671     PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via"
672     SATAMODS="sata_via sata_sis sata_nv"
673     DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via"
674     OTHERMODS=""
675     case ${SPECIALDEVICE} in
676     zotac_intel) FBMODS=""; DRMMODS="i915" ;;
677     zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;;
678     rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards
679     # not working with kms enabled drivers -> segfaults
680     #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer
681     maxdata) FBMODS="" ;;
682     *) FBMODS="uvesafb" ;;
683     esac
684    
685     if [[ ${FORMFACTOR} = laptop ]]
686     then
687     OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave"
688     fi
689    
690     # install an appropriate uvesafb.conf
691 niro 2342 install -d ${INSTALLROOT}/etc/modprobe.d || dialog_die
692     echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLROOT}/etc/modprobe.d/uvesafb.conf || dialog_die
693 niro 2320
694     # install an appropriate viafb.conf
695 niro 2342 echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLROOT}/etc/modprobe.d/viafb.conf || dialog_die
696 niro 2320
697     # install an appropriate i810fb.conf
698 niro 2342 echo "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60" > ${INSTALLROOT}/etc/modprobe.d/i810fb.conf || dialog_die
699 niro 2320
700 niro 2342 cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF
701 niro 2320 echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd
702     mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null
703     exit 0
704     CHROOTEOF
705    
706     ## enters chroot
707 niro 2342 mount -t proc proc ${INSTALLROOT}/proc
708     mount -t sysfs sysfs ${INSTALLROOT}/sys
709     mount -o bind /dev ${INSTALLROOT}/dev
710     chroot ${INSTALLROOT} /bin/bash --rcfile /root/.installrc -i
711     umount ${INSTALLROOT}/proc
712     umount ${INSTALLROOT}/sys
713     umount ${INSTALLROOT}/dev
714     rm ${INSTALLROOT}/root/.installrc
715 niro 2320 }
716    
717     is_uuid_supported()
718     {
719 niro 2345 if [[ -x $(type -P busybox.mkinitrd) ]]
720 niro 2320 then
721     # only detect uuids if supported
722     if [[ ! -z $(busybox.mkinitrd | grep blkid) ]]
723     then
724     return 0
725     fi
726     fi
727    
728     return 1
729     }
730    
731     get_uuid()
732     {
733     local UUID
734     local SEC_TYPE
735     local TYPE
736    
737     local dev="$1"
738 niro 2336 [[ -z ${dev} ]] && dialog_die "no dev given"
739 niro 2320
740     # check if given device is already an UUID
741     if [[ ${dev/UUID=/}x != ${dev}x ]]
742     then
743     eval "${dev}"
744     else
745     eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //')
746     fi
747     echo "${UUID}"
748     }
749    
750     install_system_settings()
751     {
752     # schreibe fstab
753     if is_uuid_supported
754     then
755 niro 2342 echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die
756 niro 2320 else
757 niro 2342 echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die
758 niro 2320 fi
759     # not needed busybox loads all with swapon -a, even if not mentioned in fstab
760 niro 2342 #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die
761     echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die
762     echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die
763 niro 2320
764     # install network config skeleton
765 niro 2342 install -m0644 ${INSTALLROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLROOT}/etc/conf.d/ || dialog_die
766 niro 2320
767     # intel framebufer quirk
768     if [[ -e /proc/fb ]]
769     then
770     if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]]
771     then
772     fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:')
773     if [[ ${fbdev} != 0 ]]
774     then
775 niro 2342 sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die
776 niro 2320 fi
777     fi
778     fi
779     }
780    
781     install_umount_rootfs()
782     {
783     cd /
784 niro 2342 umount ${INSTALLROOT}/boot || dialog_die
785     umount ${INSTALLROOT} || dialog_die
786 niro 2320 }
787    
788     install_do_reboot()
789     {
790     reboot
791     }
792    
793     #################################################
794     # Install Ablauf Scripte #
795     #################################################
796    
797     run_install_normal()
798     {
799     dialog_hardware_detection
800    
801 niro 2413 dialog_setup_hdd_partitions_manual
802 niro 2320 dialog_setup_hdd_format
803     setup_hdd_format > /dev/null
804     install_mount_rootfs
805     (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image
806    
807     dialog_install_settings
808     sleep 1
809     install_system_settings
810     install_initrd_chroot
811    
812     dialog_install_bootsector
813     install_bootsector_chroot
814    
815     install_umount_rootfs
816     dialog_install_successful
817     }
818    
819     run_install_auto()
820     {
821     dialog_hardware_detection
822    
823     dialog_setup_hdd_partitions_auto
824     dialog_setup_hdd_format
825 niro 2399 setup_hdd_format > /dev/null
826     install_mount_rootfs
827 niro 2320 (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image
828    
829     dialog_install_settings
830     sleep 1
831 niro 2399 install_system_settings
832 niro 2320 install_initrd_chroot
833    
834     dialog_install_bootsector
835     install_bootsector_chroot
836    
837 niro 2399 install_umount_rootfs
838 niro 2320 dialog_install_successful
839     }
840    
841 niro 2409 # set some proper traps
842     trap "trap_exit" SIGINT SIGQUIT
843    
844 niro 2320 dialog_main
845    
846     exit 0