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