Contents of /trunk/installer-simple/bin/installer.sh.in
Parent Directory | Revision Log
Revision 2423 -
(show annotations)
(download)
Tue Jan 7 13:55:26 2014 UTC (10 years, 8 months ago) by niro
File size: 19772 byte(s)
Tue Jan 7 13:55:26 2014 UTC (10 years, 8 months ago) by niro
File size: 19772 byte(s)
-renamed dialog_install_meter() to install_meter()
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 | METHOD=0 |
319 | |
320 | while [[ ${METHOD} -le 2 ]] |
321 | do |
322 | METHOD=$(dialog \ |
323 | --backtitle "${TITLE}" \ |
324 | --no-cancel \ |
325 | --ok-label "Weiter" \ |
326 | --stdout \ |
327 | --menu "Konfiguration" 14 70 5 \ |
328 | "1" "AutoSta_LX installieren" \ |
329 | "2" "Uebersicht gefundener Laufwerke" \ |
330 | "3" "Beenden und neustarten" \ |
331 | "4" "Beenden und eine Shell starten") |
332 | RES=$? |
333 | [[ ${RES} -eq 1 ]] && exit 1 |
334 | if [[ ${RES} -eq 0 ]] |
335 | then |
336 | case ${METHOD} in |
337 | "1") dialog_setup_system_menu ;; |
338 | "2") dialog_hardware_detection ;; |
339 | "3") install_do_reboot ;; |
340 | "4") /bin/bash --login -i ;; |
341 | esac |
342 | fi |
343 | done |
344 | } |
345 | |
346 | ################################################# |
347 | # Install Komandos # |
348 | ################################################# |
349 | run_hardware_detection() |
350 | { |
351 | local hwinfo |
352 | |
353 | hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" |
354 | |
355 | # check for special devices/clients: |
356 | # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd |
357 | local removable=0 |
358 | if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
359 | then |
360 | for i in /sys/block/[hs]d*/removable |
361 | do |
362 | if [[ $(< ${i}) = 1 ]] |
363 | then |
364 | removable=1 |
365 | fi |
366 | done |
367 | |
368 | # only add this for grub legacy, grub2 detect these settings on its own |
369 | export GRUBLEGACYOPTS="rootdelay=8" |
370 | # there are to zotac types in the wild, nvidia based gfx and intel |
371 | if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] |
372 | then |
373 | export SPECIALDEVICE="zotac_nvidia" |
374 | else |
375 | export SPECIALDEVICE="zotac_intel" |
376 | fi |
377 | fi |
378 | |
379 | # check for special devices/clients: |
380 | # if a rangee and disk ist smaller then 256mb move partion one block further ahead |
381 | if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] |
382 | then |
383 | # for a rangee always define partion startblock +1 |
384 | export FDISKPARTIONBELOW256MB="1" |
385 | export SPECIALDEVICE="rangee" |
386 | export GRUBLEGACYOPTS="" |
387 | fi |
388 | |
389 | # check for special devices/clients: |
390 | # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer |
391 | if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]] |
392 | then |
393 | export SPECIALDEVICE="maxdata" |
394 | export GRUBLEGACYOPTS="" |
395 | fi |
396 | |
397 | # check for special devices/clients: |
398 | # check for laptops and activate cpufreq scaling |
399 | if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]] |
400 | then |
401 | export FORMFACTOR="laptop" |
402 | export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand" |
403 | fi |
404 | } |
405 | |
406 | hdd_size_below_256mb() |
407 | { |
408 | local hdd="$1" |
409 | local size |
410 | local retval |
411 | [[ -z ${hdd} ]] && dialog_die "Error: get_hdd_size() no \$hdd given!" |
412 | |
413 | size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') |
414 | if [[ ${size} -le 257000000 ]] |
415 | then |
416 | retval="0" |
417 | else |
418 | retval="1" |
419 | fi |
420 | |
421 | return "${retval}" |
422 | } |
423 | |
424 | setup_hdd_partitions_auto() |
425 | { |
426 | ROOTHDD="${HDD}1" |
427 | |
428 | # run this only if FDISKPARTITIONBELOW256MB is not already 1 |
429 | if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
430 | then |
431 | if hdd_size_below_256mb ${HDD} |
432 | then |
433 | FDISKPARTIONBELOW256MB=1 |
434 | else |
435 | FDISKPARTIONBELOW256MB=0 |
436 | fi |
437 | fi |
438 | |
439 | ## delete disk |
440 | dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die |
441 | |
442 | if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
443 | then |
444 | ## setup one bootable partition |
445 | #1. n= new disk |
446 | #2. p= primary disk |
447 | #3. 1= first partition |
448 | #4. 2= default sector start // small disk needs more space for grub2 mbr sector |
449 | #5. ''= defaul sector end |
450 | #6. a= bootable flag |
451 | #7. 1= boot flag for partition 1 |
452 | #8. w= write/quit |
453 | fdisk ${HDD} &> /dev/null << EOF |
454 | n |
455 | p |
456 | 1 |
457 | 2 |
458 | |
459 | a |
460 | 1 |
461 | w |
462 | EOF |
463 | else |
464 | ## setup one bootable partition |
465 | #1. n= new disk |
466 | #2. p= primary disk |
467 | #3. 1= first partition |
468 | #4. ''= default sector start |
469 | #5. ''= defaul sector end |
470 | #6. a= bootable flag |
471 | #7. 1= boot flag for partition 1 |
472 | #8. w= write/quit |
473 | fdisk ${HDD} &> /dev/null << EOF |
474 | n |
475 | p |
476 | 1 |
477 | |
478 | |
479 | a |
480 | 1 |
481 | w |
482 | EOF |
483 | fi |
484 | } |
485 | |
486 | setup_hdd_partitions_manual() |
487 | { |
488 | ROOTHDD="${HDD}1" |
489 | |
490 | ## hdds partitionieren manual |
491 | cfdisk ${HDD} || dialog_die |
492 | } |
493 | |
494 | setup_hdd_format() |
495 | { |
496 | mke2fs -j -q ${ROOTHDD} || dialog_die |
497 | } |
498 | |
499 | install_mount_rootfs() |
500 | { |
501 | mount ${ROOTHDD} ${INSTALLROOT} || dialog_die |
502 | install -d ${INSTALLROOT}/boot || dialog_die |
503 | cd ${INSTALLROOT} || dialog_die |
504 | } |
505 | |
506 | install_system_image() |
507 | { |
508 | tar xvjpf ${CDROOT}/system/${CDIMAGENAME} -C ${INSTALLROOT} |
509 | } |
510 | |
511 | install_bootsector_chroot() |
512 | { |
513 | local my_roothdd |
514 | local grubconf=${INSTALLROOT}/boot/grub/grub.conf |
515 | local grub2conf=/boot/grub/grub.cfg |
516 | |
517 | # check for grub2 |
518 | if [[ -f ${INSTALLROOT}/sbin/grub-mkconfig ]] |
519 | then |
520 | # needed by grub-mkconfig on the first run |
521 | if [[ ! -f ${INSTALLROOT}/boot/grub/video.lst ]] |
522 | then |
523 | install -m0644 ${INSTALLROOT}/lib/grub/*/video.lst ${INSTALLROOT}/boot/grub/video.lst || dialog_die |
524 | fi |
525 | |
526 | # set kernelopts |
527 | if [[ -f ${INSTALLROOT}/etc/conf.d/grub ]] |
528 | then |
529 | sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLROOT}/etc/conf.d/grub || dialog_die |
530 | else |
531 | echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALLROOT}/etc/conf.d/grub || dialog_die |
532 | fi |
533 | echo 'grub-mkdevicemap' > ${INSTALLROOT}/root/.installrc || dialog_die |
534 | echo "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" >> ${INSTALLROOT}/root/.installrc || dialog_die |
535 | echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLROOT}/root/.installrc || dialog_die |
536 | echo "exit 0" >> ${INSTALLROOT}/root/.installrc || dialog_die |
537 | |
538 | # grub-legacy |
539 | else |
540 | ### grubconf schreiben |
541 | source ${INSTALLROOT}/boot/kernelversion |
542 | |
543 | #for alx only |
544 | if [ -e ${INSTALLROOT}/etc/alx_version ] |
545 | then |
546 | OLD_ALXVER="${ALXVER}" |
547 | source ${INSTALLROOT}/etc/alx_version |
548 | KRNVER="ALX-${ALXVER}" |
549 | ALXVER="${OLD_ALXVER}" |
550 | fi |
551 | |
552 | [[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX" |
553 | [[ -z ${KRNINITRD} ]] && KRNINITRD="initrd" |
554 | [[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz" |
555 | |
556 | # uuid support |
557 | if is_uuid_supported |
558 | then |
559 | my_roothdd="UUID=$(get_uuid ${ROOTHDD})" |
560 | else |
561 | my_roothdd="${ROOTHDD}" |
562 | fi |
563 | |
564 | : > ${grubconf} || dialog_die |
565 | echo "default 0" >> ${grubconf} || dialog_die |
566 | echo "timeout 3" >> ${grubconf} || dialog_die |
567 | # using current root password |
568 | echo "password --md5 $(cat ${INSTALLROOT}/etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} || dialog_die |
569 | |
570 | echo >> ${grubconf} || dialog_die |
571 | echo "# normal boot" >> ${grubconf} || dialog_die |
572 | echo "title ${KRNVER}" >> ${grubconf} || dialog_die |
573 | echo "root (hd0,0)" >> ${grubconf} || dialog_die |
574 | echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || dialog_die |
575 | if is_initrd_supported |
576 | then |
577 | echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die |
578 | fi |
579 | |
580 | echo >> ${grubconf} || dialog_die |
581 | echo "# admin boot" >> ${grubconf} || dialog_die |
582 | echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || dialog_die |
583 | echo "lock" >> ${grubconf} || dialog_die |
584 | echo "root (hd0,0)" >> ${grubconf} || dialog_die |
585 | echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || dialog_die |
586 | if is_initrd_supported |
587 | then |
588 | echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die |
589 | fi |
590 | |
591 | echo >> ${grubconf} || dialog_die |
592 | echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || dialog_die |
593 | echo "lock" >> ${grubconf} || dialog_die |
594 | echo "root (hd0,0)" >> ${grubconf} || dialog_die |
595 | echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || dialog_die |
596 | if is_initrd_supported |
597 | then |
598 | echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || dialog_die |
599 | fi |
600 | |
601 | # bootsector schreiben chrooted schreiben (lfs/magellan) |
602 | cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF |
603 | /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null |
604 | root (hd0,0) |
605 | setup (hd0) |
606 | quit |
607 | EOF |
608 | exit 0 |
609 | CHROOTEOF |
610 | fi |
611 | |
612 | ## enter chroot |
613 | mount -t proc proc ${INSTALLROOT}/proc |
614 | mount -t sysfs sysfs ${INSTALLROOT}/sys |
615 | mount -o bind /dev ${INSTALLROOT}/dev |
616 | chroot ${INSTALLROOT} /bin/bash --rcfile /root/.installrc -i |
617 | umount ${INSTALLROOT}/proc |
618 | umount ${INSTALLROOT}/sys |
619 | umount ${INSTALLROOT}/dev |
620 | rm ${INSTALLROOT}/root/.installrc |
621 | } |
622 | |
623 | is_initrd_supported() |
624 | { |
625 | # only generate initrds if the cmd exists |
626 | [[ -x ${INSTALLROOT}/sbin/mkinitrd ]] && return 0 |
627 | return 1 |
628 | } |
629 | |
630 | install_initrd_chroot() |
631 | { |
632 | # only generate initrds if the cmd exists |
633 | is_initrd_supported || return 0 |
634 | |
635 | DISKMODS="sd_mod" |
636 | OLDPATAMODS="amd74xx piix sis5513 via82cxxx" |
637 | PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" |
638 | SATAMODS="sata_via sata_sis sata_nv" |
639 | DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" |
640 | OTHERMODS="" |
641 | case ${SPECIALDEVICE} in |
642 | zotac_intel) FBMODS=""; DRMMODS="i915" ;; |
643 | zotac_nvidia) FBMODS=""; DRMMODS="nouveau" ;; |
644 | rangee) FBMODS="" ;; ## fallback to vesafb, viafb does not run on all CLE266 boards |
645 | # not working with kms enabled drivers -> segfaults |
646 | #maxdata) FBMODS="i810fb" ;; ## check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer |
647 | maxdata) FBMODS="" ;; |
648 | *) FBMODS="uvesafb" ;; |
649 | esac |
650 | |
651 | if [[ ${FORMFACTOR} = laptop ]] |
652 | then |
653 | OTHERMODS="acpi-cpufreq cpufreq_ondemand cpufreq_conservative cpufreq_powersave" |
654 | fi |
655 | |
656 | # install an appropriate uvesafb.conf |
657 | install -d ${INSTALLROOT}/etc/modprobe.d || dialog_die |
658 | echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLROOT}/etc/modprobe.d/uvesafb.conf || dialog_die |
659 | |
660 | # install an appropriate viafb.conf |
661 | echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLROOT}/etc/modprobe.d/viafb.conf || dialog_die |
662 | |
663 | # install an appropriate i810fb.conf |
664 | 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 |
665 | |
666 | cat > ${INSTALLROOT}/root/.installrc << CHROOTEOF |
667 | echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd |
668 | mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null |
669 | exit 0 |
670 | CHROOTEOF |
671 | |
672 | ## enters chroot |
673 | mount -t proc proc ${INSTALLROOT}/proc |
674 | mount -t sysfs sysfs ${INSTALLROOT}/sys |
675 | mount -o bind /dev ${INSTALLROOT}/dev |
676 | chroot ${INSTALLROOT} /bin/bash --rcfile /root/.installrc -i |
677 | umount ${INSTALLROOT}/proc |
678 | umount ${INSTALLROOT}/sys |
679 | umount ${INSTALLROOT}/dev |
680 | rm ${INSTALLROOT}/root/.installrc |
681 | } |
682 | |
683 | is_uuid_supported() |
684 | { |
685 | if [[ -x $(type -P busybox.mkinitrd) ]] |
686 | then |
687 | # only detect uuids if supported |
688 | if [[ ! -z $(busybox.mkinitrd | grep blkid) ]] |
689 | then |
690 | return 0 |
691 | fi |
692 | fi |
693 | |
694 | return 1 |
695 | } |
696 | |
697 | get_uuid() |
698 | { |
699 | local UUID |
700 | local SEC_TYPE |
701 | local TYPE |
702 | |
703 | local dev="$1" |
704 | [[ -z ${dev} ]] && dialog_die "no dev given" |
705 | |
706 | # check if given device is already an UUID |
707 | if [[ ${dev/UUID=/}x != ${dev}x ]] |
708 | then |
709 | eval "${dev}" |
710 | else |
711 | eval $(busybox.mkinitrd blkid ${dev} | grep "${dev}:" | sed 's/.*:\ //') |
712 | fi |
713 | echo "${UUID}" |
714 | } |
715 | |
716 | install_system_settings() |
717 | { |
718 | # schreibe fstab |
719 | if is_uuid_supported |
720 | then |
721 | echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die |
722 | else |
723 | echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die |
724 | fi |
725 | # not needed busybox loads all with swapon -a, even if not mentioned in fstab |
726 | #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die |
727 | echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die |
728 | echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLROOT}/etc/fstab || dialog_die |
729 | |
730 | # install network config skeleton |
731 | install -m0644 ${INSTALLROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLROOT}/etc/conf.d/ || dialog_die |
732 | |
733 | # intel framebufer quirk |
734 | if [[ -e /proc/fb ]] |
735 | then |
736 | if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] |
737 | then |
738 | fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') |
739 | if [[ ${fbdev} != 0 ]] |
740 | then |
741 | sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLROOT}/etc/splash/splash.conf || dialog_die |
742 | fi |
743 | fi |
744 | fi |
745 | } |
746 | |
747 | install_umount_rootfs() |
748 | { |
749 | cd / |
750 | umount ${INSTALLROOT}/boot || dialog_die |
751 | umount ${INSTALLROOT} || dialog_die |
752 | } |
753 | |
754 | install_do_reboot() |
755 | { |
756 | reboot |
757 | } |
758 | |
759 | ################################################# |
760 | # Install Ablauf Scripte # |
761 | ################################################# |
762 | |
763 | run_install_normal() |
764 | { |
765 | dialog_hardware_detection |
766 | |
767 | dialog_setup_hdd_partitions_manual |
768 | dialog_setup_hdd_format |
769 | setup_hdd_format > /dev/null |
770 | install_mount_rootfs |
771 | (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image |
772 | |
773 | dialog_install_settings |
774 | sleep 1 |
775 | install_system_settings |
776 | install_initrd_chroot |
777 | |
778 | dialog_install_bootsector |
779 | install_bootsector_chroot |
780 | |
781 | install_umount_rootfs |
782 | dialog_install_successful |
783 | } |
784 | |
785 | run_install_auto() |
786 | { |
787 | dialog_hardware_detection |
788 | |
789 | dialog_setup_hdd_partitions_auto |
790 | dialog_setup_hdd_format |
791 | setup_hdd_format > /dev/null |
792 | install_mount_rootfs |
793 | (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image |
794 | |
795 | dialog_install_settings |
796 | sleep 1 |
797 | install_system_settings |
798 | install_initrd_chroot |
799 | |
800 | dialog_install_bootsector |
801 | install_bootsector_chroot |
802 | |
803 | install_umount_rootfs |
804 | dialog_install_successful |
805 | } |
806 | |
807 | # set some proper traps |
808 | trap "trap_exit" SIGINT SIGQUIT |
809 | |
810 | dialog_main |
811 | |
812 | exit 0 |