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