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