Magellan Linux

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

Parent Directory Parent Directory | Revision Log Revision Log


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