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