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