Annotation of /trunk/installer-simple/bin/installer.sh.in
Parent Directory | Revision Log
Revision 2950 -
(hide annotations)
(download)
Thu Jun 16 08:43:55 2016 UTC (7 years, 11 months ago) by niro
File size: 19009 byte(s)
Thu Jun 16 08:43:55 2016 UTC (7 years, 11 months ago) by niro
File size: 19009 byte(s)
-fixed broken fstab
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 | 2472 | # setup locales |
11 | TEXTDOMAIN=installer | ||
12 | |||
13 | niro | 2340 | # include dir |
14 | niro | 2333 | INSTALLER_LIBDIR="%LIBDIR%" |
15 | |||
16 | niro | 2340 | # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 ! |
17 | # -> now in images.conf | ||
18 | CURRENTLINE=0 | ||
19 | |||
20 | niro | 2397 | die() |
21 | { | ||
22 | echo "Error: $@" | ||
23 | exit 1 | ||
24 | } | ||
25 | |||
26 | niro | 2401 | # load common includes |
27 | niro | 2402 | for inc in %SYSCONFDIR%/installer.conf \ |
28 | ${INSTALLER_LIBDIR}/functions/common.sh \ | ||
29 | ${INSTALLER_LIBDIR}/functions/common-dialogs.sh \ | ||
30 | ${INSTALLER_LIBDIR}/functions/hwdetection.sh \ | ||
31 | niro | 2428 | ${INSTALLER_LIBDIR}/functions/bootloader.sh \ |
32 | ${INSTALLER_LIBDIR}/functions/initrd-tools.sh \ | ||
33 | niro | 2402 | ${INSTALLER_LIBDIR}/functions/installer-dialogs.sh |
34 | niro | 2401 | do |
35 | if [ -e ${inc} ] | ||
36 | then | ||
37 | source "${inc}" | ||
38 | else | ||
39 | die "'${inc}' not found" | ||
40 | fi | ||
41 | done | ||
42 | niro | 2332 | |
43 | niro | 2930 | # fetch cmdline |
44 | for argv in $* | ||
45 | do | ||
46 | case $1 in | ||
47 | --liveroot) shift; cmdliveroot="$1" ;; | ||
48 | --imageroot) shift; cmdimageroot="$1" ;; | ||
49 | --installroot) shift; cmdinstallroot="$1" ;; | ||
50 | --filesystem) shift; cmdformatfilesystem="$1" ;; | ||
51 | --help) | ||
52 | echo "$0 options:" | ||
53 | echo " --liveroot [path] - override default liveroot" | ||
54 | echo " --imageroot [path] - override default imageroot" | ||
55 | echo " --installroot [path] - override default installroot" | ||
56 | echo " --filesystem [fstype] - override default filesystem used to format the disk" | ||
57 | exit 0 ;; | ||
58 | esac | ||
59 | shift | ||
60 | done | ||
61 | |||
62 | niro | 2320 | ### System/Config Version |
63 | VERSION="%VERSIONTAG%" | ||
64 | niro | 2332 | TITLE="${DEFAULT_TITLE} - ${VERSION}" |
65 | niro | 2320 | |
66 | niro | 2890 | # initialize global variables so they are exportable |
67 | niro | 2404 | # some sane defaults |
68 | niro | 2891 | INSTALL_METHOD="" |
69 | niro | 2930 | if [[ -n ${cmdliveroot} ]] |
70 | then | ||
71 | LIVEROOT="${cmdliveroot}" | ||
72 | else | ||
73 | LIVEROOT="${DEFAULT_LIVEROOT}" | ||
74 | fi | ||
75 | if [[ -n ${cmdimageroot} ]] | ||
76 | then | ||
77 | IMAGEROOT="${cmdimageroot}" | ||
78 | else | ||
79 | IMAGEROOT="${DEFAULT_IMAGEROOT}" | ||
80 | fi | ||
81 | if [[ -n ${cmdinstallroot} ]] | ||
82 | then | ||
83 | INSTALLROOT="${cmdinstallroot}" | ||
84 | else | ||
85 | INSTALLROOT="${DEFAULT_INSTALLROOT}" | ||
86 | fi | ||
87 | niro | 2404 | KERNELPKG="${DEFAULT_KERNELPKG}" |
88 | KERNELOPTS="${DEFAULT_KERNELOPTS}" | ||
89 | niro | 2320 | GRUBLEGACYOPTS="" |
90 | GRUB2OPTS="" | ||
91 | FDISKPARTIONBELOW256MB=0 | ||
92 | SPECIALDEVICE="" | ||
93 | niro | 2404 | FORMFACTOR="${DEFAULT_FORMFACTOR}" |
94 | niro | 2930 | if [[ -n ${cmdformatfilesystem} ]] |
95 | then | ||
96 | FORMAT_FILESYSTEM="${cmdformatfilesystem}" | ||
97 | else | ||
98 | FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}" | ||
99 | fi | ||
100 | niro | 2890 | FLASHDISK=0 |
101 | niro | 2320 | |
102 | niro | 2642 | # TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 ! |
103 | # -> now in images.conf | ||
104 | CDIMAGENAME="" | ||
105 | TOTALLINES="" | ||
106 | CURRENTLINE=0 | ||
107 | if [ -e ${IMAGEROOT}/images.conf ] | ||
108 | then | ||
109 | source ${IMAGEROOT}/images.conf | ||
110 | # check if all required variables are set | ||
111 | [[ -z ${CDIMAGENAME} ]] && die "CDIMAGENAME is empty in ${IMAGEROOT}/images.conf" | ||
112 | [[ -z ${TOTALLINES} ]] && die "TOTALLINES is empty in ${IMAGEROOT}/images.conf" | ||
113 | else | ||
114 | die "${IMAGEROOT}/images.conf not found" | ||
115 | fi | ||
116 | niro | 2320 | |
117 | niro | 2482 | ### helper scripts ### |
118 | |||
119 | niro | 2409 | trap_exit() |
120 | { | ||
121 | is_mounted --location "${INSTALLROOT}/dev" && umount ${INSTALLROOT}/dev | ||
122 | is_mounted --location "${INSTALLROOT}/proc" && umount ${INSTALLROOT}/proc | ||
123 | is_mounted --location "${INSTALLROOT}/sys" && umount ${INSTALLROOT}/sys | ||
124 | is_mounted --location "${INSTALLROOT}/boot" && umount ${INSTALLROOT}/boot | ||
125 | is_mounted --location "${INSTALLROOT}" && umount ${INSTALLROOT} | ||
126 | niro | 2889 | [[ -n ${SWAPHDD} ]] && swapoff ${SWAPHDD} |
127 | niro | 2409 | |
128 | echo $"Installation aborted." | ||
129 | exit 1 | ||
130 | } | ||
131 | |||
132 | niro | 2423 | install_meter() |
133 | niro | 2320 | { |
134 | while [[ ${CURRENTLINE} != ${TOTALLINES} ]] | ||
135 | do | ||
136 | CURRENTLINE=$(grep -c . /tmp/install.log) | ||
137 | PERCENT=$(( ${CURRENTLINE} * 100 / ${TOTALLINES})) | ||
138 | echo ${PERCENT} | ||
139 | sleep 1 | ||
140 | done | ||
141 | rm -f /tmp/install.log | ||
142 | return 0 | ||
143 | } | ||
144 | |||
145 | niro | 2485 | mount_rootfs() |
146 | niro | 2484 | { |
147 | niro | 2489 | local retval |
148 | |||
149 | niro | 2882 | if [[ -n ${SWAPHDD} ]] |
150 | niro | 2489 | then |
151 | niro | 2882 | swapon ${SWAPHDD} || dialog_die $"Could not enable swap space '${SWAPHDD}'" |
152 | niro | 2489 | fi |
153 | niro | 2882 | |
154 | if [[ -n ${ROOTHDD} ]] | ||
155 | then | ||
156 | if is_mounted --location "${INSTALLROOT}" | ||
157 | then | ||
158 | echo $"${INSTALLROOT} already mounted" >&2 | ||
159 | else | ||
160 | niro | 2888 | mount -t "${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" "${INSTALLROOT}" || dialog_die $"Could not mount rootfs - drive '${ROOTHDD}' -> '${INSTALLROOT}'" |
161 | niro | 2882 | fi |
162 | fi | ||
163 | |||
164 | niro | 2486 | [[ -d ${INSTALLROOT}/boot ]] || install -d ${INSTALLROOT}/boot |
165 | niro | 2882 | |
166 | if [[ -n ${BOOTHDD} ]] | ||
167 | then | ||
168 | if is_mounted --location "${INSTALLROOT}"/boot | ||
169 | then | ||
170 | echo $"${INSTALLROOT}/boot already mounted" >&2 | ||
171 | else | ||
172 | niro | 2888 | mount -t "${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" "${INSTALLROOT}"/boot || dialog_die $"Could not mount bootfs - drive '${BOOTHDD}' -> '${INSTALLROOT}/boot'" |
173 | niro | 2882 | fi |
174 | fi | ||
175 | niro | 2484 | } |
176 | |||
177 | niro | 2485 | umount_rootfs() |
178 | niro | 2484 | { |
179 | is_mounted --location ${INSTALLROOT}/boot && umount ${INSTALLROOT}/boot | ||
180 | is_mounted --location ${INSTALLROOT} && umount ${INSTALLROOT} | ||
181 | niro | 2882 | |
182 | if [[ -n ${SWAPHDD} ]] | ||
183 | then | ||
184 | swapoff ${SWAPHDD} || die | ||
185 | fi | ||
186 | niro | 2484 | } |
187 | |||
188 | install_do_reboot() | ||
189 | { | ||
190 | reboot | ||
191 | } | ||
192 | |||
193 | niro | 2320 | run_hardware_detection() |
194 | { | ||
195 | local hwinfo | ||
196 | hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" | ||
197 | |||
198 | niro | 2654 | # check for special devices/clients: |
199 | # if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd | ||
200 | local removable=0 | ||
201 | if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] | ||
202 | then | ||
203 | niro | 2890 | for i in /sys/block/[hs]d*/removable |
204 | do | ||
205 | if [[ $(< ${i}) = 1 ]] | ||
206 | then | ||
207 | removable=1 | ||
208 | # we assume that all removable disks are flash disks on a zotac | ||
209 | export FLASHDISK=1 | ||
210 | fi | ||
211 | done | ||
212 | niro | 2654 | # smartcard = udevadm info -n /dev/sda -a | grep -i 'configuration.*card' |
213 | niro | 2320 | |
214 | niro | 2654 | # only add this for grub legacy, grub2 detect these settings on its own |
215 | export GRUBLEGACYOPTS="rootdelay=8" | ||
216 | # there are to zotac types in the wild, nvidia based gfx and intel | ||
217 | if [[ ! -z $(echo "${hwinfo}" | grep -i nouveau) ]] | ||
218 | then | ||
219 | export SPECIALDEVICE="zotac_nvidia" | ||
220 | else | ||
221 | export SPECIALDEVICE="zotac_intel" | ||
222 | fi | ||
223 | fi | ||
224 | niro | 2320 | |
225 | # check for special devices/clients: | ||
226 | # if a rangee and disk ist smaller then 256mb move partion one block further ahead | ||
227 | if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] | ||
228 | then | ||
229 | # for a rangee always define partion startblock +1 | ||
230 | export FDISKPARTIONBELOW256MB="1" | ||
231 | export SPECIALDEVICE="rangee" | ||
232 | export GRUBLEGACYOPTS="" | ||
233 | fi | ||
234 | |||
235 | # check for special devices/clients: | ||
236 | # check for maxdata / i810/ i815 Chipsets and disable KMS and use i810fb frambuffer | ||
237 | if [[ ! -z $(echo "${hwinfo}" | grep -i i810) ]] || [[ ! -z $(echo "${hwinfo}" | grep -i i815) ]] | ||
238 | then | ||
239 | export SPECIALDEVICE="maxdata" | ||
240 | export GRUBLEGACYOPTS="" | ||
241 | fi | ||
242 | |||
243 | niro | 2892 | # check for i845 Chipsets and enable KMS and use 915 drm driver later in initrd |
244 | if [[ ! -z $(echo "${hwinfo}" | grep -i i845) ]] | ||
245 | then | ||
246 | export SPECIALDEVICE="i845" | ||
247 | # unset default video=1024x768 opt or the drm driver breaks | ||
248 | export KERNELOPTS="quiet" | ||
249 | export GRUBLEGACYOPTS="" | ||
250 | # enable full kms support | ||
251 | export GRUB2GFXPAYLOAD="keep" | ||
252 | fi | ||
253 | |||
254 | # check for radeon gfxcards | ||
255 | if [[ ! -z $(echo "${hwinfo}" | grep -i radeon) ]] | ||
256 | then | ||
257 | # enable full kms support | ||
258 | export GRUB2GFXPAYLOAD="keep" | ||
259 | fi | ||
260 | |||
261 | # requires nomsi to prevent massive IRQ error spam | ||
262 | # see: http://ubuntuforums.org/showthread.php?t=1234983 | ||
263 | if [[ ! -z $(echo "${hwinfo}" | grep -i 'P5VD2-X') ]] || [[ ! -z $(echo "${hwinfo}" | grep -i 'VT8237') ]] || [[ ! -z $(echo "${hwinfo}" | grep -i 'VX700') ]] | ||
264 | then | ||
265 | export SPECIALDEVICE="nomsi" | ||
266 | export KERNELOPTS="${KERNELOPTS} pci=nomsi,noaer" | ||
267 | fi | ||
268 | |||
269 | niro | 2320 | # check for special devices/clients: |
270 | # check for laptops and activate cpufreq scaling | ||
271 | if [[ $(echo "${hwinfo}" | grep 'Formfactor:' | sed 's:.*Formfactor\:\ \"\(.*\)\":\1:') = laptop ]] | ||
272 | then | ||
273 | export FORMFACTOR="laptop" | ||
274 | export KERNELOPTS="${KERNELOPTS} cpufreq.governor=ondemand" | ||
275 | fi | ||
276 | } | ||
277 | |||
278 | niro | 2429 | run_hardware_detection_disks() |
279 | { | ||
280 | local bootdev | ||
281 | |||
282 | # all disks but exclude ramdisks | ||
283 | export ALL_DISKS=$(get_hwinfo disk | sed '/\/dev\/ram[0-9].*/d') | ||
284 | # remove the boot device from ALL_DISKS if it was an usbstick | ||
285 | niro | 2653 | if [[ $(grep '[[:space:]]${LIVEROOT}[[:space:]]' /proc/mounts | cut -d' ' -f3) != iso9660 ]] |
286 | niro | 2429 | then |
287 | niro | 2653 | bootdev=$(grep "[[:space:]]${LIVEROOT}[[:space:]]" /proc/mounts | cut -d' ' -f1 | sed 's:[0-9]::g') |
288 | niro | 2429 | export ALL_DISKS=$(echo "${ALL_DISKS}" | grep -v "${bootdev}") |
289 | fi | ||
290 | export ALL_CDROMS="$(get_hwinfo cdrom)" | ||
291 | } | ||
292 | |||
293 | niro | 2948 | auto_partition_clear_disk() |
294 | { | ||
295 | if [ -e ${HDD} ] | ||
296 | then | ||
297 | dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die | ||
298 | else | ||
299 | echo "clear disk: device ${HDD} does not exist" >&2 | ||
300 | fi | ||
301 | } | ||
302 | |||
303 | auto_partition_command() | ||
304 | { | ||
305 | if [ -e ${HDD} ] | ||
306 | then | ||
307 | fdisk ${HDD} &> /dev/null << EOF | ||
308 | $(echo "${PARTITION_OPTS}") | ||
309 | EOF | ||
310 | else | ||
311 | echo "partition command: device ${HDD} does not exist" >&2 | ||
312 | fi | ||
313 | } | ||
314 | |||
315 | niro | 2882 | setup_hdd_partitions() |
316 | niro | 2320 | { |
317 | niro | 2948 | local partition_number |
318 | local partition_type | ||
319 | local partition_start_sector | ||
320 | local partition_size | ||
321 | |||
322 | niro | 2435 | # sanity check - should not happen |
323 | if is_mounted --device "${ROOTHDD}" | ||
324 | then | ||
325 | echo "partition: device ${ROOTHDD} is already mounted, umount it" >&2 | ||
326 | umount "${ROOTHDD}" | ||
327 | fi | ||
328 | niro | 2882 | if [[ -n ${BOOTHDD} ]] |
329 | niro | 2320 | then |
330 | niro | 2882 | if is_mounted --device "${BOOTHDD}" |
331 | niro | 2320 | then |
332 | niro | 2882 | echo "partition: device ${BOOTHDD} is already mounted, umount it" >&2 |
333 | umount "${BOOTHDD}" | ||
334 | niro | 2320 | fi |
335 | fi | ||
336 | |||
337 | niro | 2882 | if [[ ${INSTALL_METHOD} = auto ]] |
338 | then | ||
339 | # run this only if FDISKPARTITIONBELOW256MB is not already 1 | ||
340 | if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] | ||
341 | then | ||
342 | if device_minimum_size "${HDD}" 256 | ||
343 | then | ||
344 | FDISKPARTIONBELOW256MB=1 | ||
345 | else | ||
346 | FDISKPARTIONBELOW256MB=0 | ||
347 | fi | ||
348 | fi | ||
349 | niro | 2320 | |
350 | niro | 2882 | ## delete disk |
351 | niro | 2948 | auto_partition_clear_disk |
352 | niro | 2882 | |
353 | niro | 2948 | # setup partition options |
354 | export PARTITION_OPTS | ||
355 | |||
356 | if [[ -n ${BOOTHDD} ]] | ||
357 | niro | 2882 | then |
358 | niro | 2948 | # create a boot disk with 50meg size - bootable |
359 | partition_type="p" | ||
360 | partition_number="1" | ||
361 | niro | 2890 | if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
362 | then | ||
363 | niro | 2948 | # 2= default sector start // small disk needs more space for grub2 mbr sector |
364 | partition_start_sector="2" | ||
365 | else | ||
366 | # '' use default sector start | ||
367 | partition_start_sector="" | ||
368 | fi | ||
369 | # 50meg size | ||
370 | partition_size="+50M" | ||
371 | niro | 2320 | |
372 | niro | 2948 | # create a boot disk with 50meg size - bootable |
373 | # n= new disk | ||
374 | # p= primary disk | ||
375 | # w= write/quit | ||
376 | PARTITION_OPTS="n | ||
377 | ${partition_type} | ||
378 | ${partition_number} | ||
379 | ${partition_start_sector} | ||
380 | ${partition_size} | ||
381 | w" | ||
382 | # create the disk | ||
383 | auto_partition_command | ||
384 | niro | 2890 | |
385 | niro | 2948 | # mark the disk bootable |
386 | PARTITION_OPTS="a | ||
387 | ${partition_number} | ||
388 | w" | ||
389 | auto_partition_command | ||
390 | |||
391 | fi | ||
392 | |||
393 | if [[ -n ${SWAPHDD} ]] | ||
394 | then | ||
395 | # p= primary disk | ||
396 | partition_type="p" | ||
397 | if [[ -n ${BOOTHDD} ]] | ||
398 | then | ||
399 | # boot disk exist, partition 2 | ||
400 | partition_number="2" | ||
401 | niro | 2890 | else |
402 | niro | 2948 | # boot disk does not exist, partition 1 |
403 | partition_number="1" | ||
404 | fi | ||
405 | if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] | ||
406 | then | ||
407 | # fake sector 2 and fdisk finds the next free sector which must be selected with enter | ||
408 | partition_start_sector="2 | ||
409 | " | ||
410 | else | ||
411 | # '' use default sector start | ||
412 | partition_start_sector="" | ||
413 | fi | ||
414 | partition_start_sector="" | ||
415 | # +2G disk size | ||
416 | partition_size="+2G" | ||
417 | niro | 2890 | |
418 | niro | 2948 | # create a swap disk with 2GB size |
419 | PARTITION_OPTS="n | ||
420 | ${partition_type} | ||
421 | ${partition_number} | ||
422 | ${partition_start_sector} | ||
423 | ${partition_size} | ||
424 | w" | ||
425 | # create the disk | ||
426 | auto_partition_command | ||
427 | niro | 2890 | |
428 | niro | 2948 | # mark disk as swap space |
429 | PARTITION_OPTS=" | ||
430 | t" | ||
431 | if [[ ${partition_number} != 1 ]] | ||
432 | then | ||
433 | PARTITION_OPTS+=" | ||
434 | ${partition_number}" | ||
435 | fi | ||
436 | PARTITION_OPTS+=" | ||
437 | 82 | ||
438 | w" | ||
439 | auto_partition_command | ||
440 | fi | ||
441 | niro | 2890 | |
442 | niro | 2948 | if [[ -n ${ROOTHDD} ]] |
443 | then | ||
444 | # p= primary disk | ||
445 | partition_type="p" | ||
446 | if [[ -z ${BOOTHDD} ]] && [[ -z ${SWAPHDD} ]] | ||
447 | then | ||
448 | # boot and swap disk does not exist, partition 1 | ||
449 | partition_number="1" | ||
450 | niro | 2890 | fi |
451 | niro | 2948 | if [[ -n ${BOOTHDD} ]] || [[ -n ${SWAPHDD} ]] |
452 | then | ||
453 | # boot or swap disk exist, partition 2 | ||
454 | partition_number="2" | ||
455 | fi | ||
456 | if [[ -n ${BOOTHDD} ]] && [[ -n ${SWAPHDD} ]] | ||
457 | then | ||
458 | # boot and swap disk does exist, partition 3 | ||
459 | partition_number="3" | ||
460 | fi | ||
461 | niro | 2890 | if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
462 | then | ||
463 | niro | 2948 | if [[ -z ${BOOTHDD} ]] |
464 | then | ||
465 | # 2= default sector start // small disk needs more space for grub2 mbr sector | ||
466 | partition_start_sector="2" | ||
467 | else | ||
468 | # fake sector 2 and fdisk finds the next free sector which must be selected with enter | ||
469 | partition_start_sector="2 | ||
470 | " | ||
471 | fi | ||
472 | niro | 2890 | else |
473 | niro | 2948 | # '' use default sector start |
474 | partition_start_sector="" | ||
475 | fi | ||
476 | # '' default sector end | ||
477 | partition_size="" | ||
478 | niro | 2320 | |
479 | niro | 2948 | # create system disk with remaining space |
480 | # w= write/quit | ||
481 | PARTITION_OPTS="n | ||
482 | ${partition_type} | ||
483 | ${partition_number} | ||
484 | ${partition_start_sector} | ||
485 | ${partition_size} | ||
486 | w" | ||
487 | # create the disk | ||
488 | auto_partition_command | ||
489 | niro | 2890 | |
490 | niro | 2948 | # no boot disk? then this is the boot disk |
491 | if [[ -z ${BOOTHDD} ]] | ||
492 | then | ||
493 | # mark the disk bootable | ||
494 | PARTITION_OPTS="a | ||
495 | ${partition_number} | ||
496 | w" | ||
497 | auto_partition_command | ||
498 | niro | 2890 | fi |
499 | niro | 2882 | fi |
500 | else | ||
501 | cfdisk ${HDD} || dialog_die | ||
502 | niro | 2320 | fi |
503 | } | ||
504 | |||
505 | setup_hdd_format() | ||
506 | { | ||
507 | niro | 2883 | install -d /tmp |
508 | :> /tmp/format.log | ||
509 | |||
510 | niro | 2882 | if [[ -n ${SWAPHDD} ]] |
511 | niro | 2435 | then |
512 | niro | 2882 | # sanity check - should not happen |
513 | if is_mounted --device "${SWAPHDD}" | ||
514 | then | ||
515 | echo "format: device ${SWAPHDD} is already mounted, umount it" >&2 | ||
516 | umount "${SWAPHDD}" | ||
517 | fi | ||
518 | mkswap ${SWAPHDD} || die | ||
519 | niro | 2435 | fi |
520 | |||
521 | niro | 2882 | if [[ -n ${BOOTHDD} ]] |
522 | then | ||
523 | # sanity check - should not happen | ||
524 | if is_mounted --device "${BOOTHDD}" | ||
525 | then | ||
526 | echo "format: device ${BOOTHDD} is already mounted, umount it" >&2 | ||
527 | umount "${BOOTHDD}" | ||
528 | fi | ||
529 | |||
530 | niro | 2885 | mkfs."${FORMAT_FILESYSTEM_BOOTHDD}" "${BOOTHDD}" &>> /tmp/format.log || dialog_die |
531 | niro | 2882 | fi |
532 | |||
533 | if [[ -n ${ROOTHDD} ]] | ||
534 | then | ||
535 | # sanity check - should not happen | ||
536 | if is_mounted --device "${ROOTHDD}" | ||
537 | then | ||
538 | echo "format: device ${ROOTHDD} is already mounted, umount it" >&2 | ||
539 | umount "${ROOTHDD}" | ||
540 | fi | ||
541 | |||
542 | niro | 2885 | mkfs."${FORMAT_FILESYSTEM_ROOTHDD}" "${ROOTHDD}" &>> /tmp/format.log || dialog_die |
543 | niro | 2882 | fi |
544 | niro | 2320 | } |
545 | |||
546 | install_system_image() | ||
547 | { | ||
548 | niro | 2433 | pushd ${INSTALLROOT} > /dev/null |
549 | niro | 2655 | tar xvjpf ${IMAGEROOT}/${CDIMAGENAME} -C ${INSTALLROOT} |
550 | niro | 2433 | popd > /dev/null |
551 | niro | 2320 | } |
552 | |||
553 | install_system_settings() | ||
554 | { | ||
555 | niro | 2443 | local CONFIG |
556 | niro | 2320 | |
557 | niro | 2443 | # write fstab |
558 | CONFIG="${INSTALLROOT}/etc/fstab" | ||
559 | clearconfig | ||
560 | niro | 2882 | if [[ -n ${BOOTHDD} ]] |
561 | then | ||
562 | niro | 2950 | addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM_BOOTHDD}\tdefaults,noatime\t1 1" |
563 | niro | 2882 | fi |
564 | if [[ -n ${ROOTHDD} ]] | ||
565 | then | ||
566 | niro | 2950 | addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tdefaults,noatime\t0 0" |
567 | niro | 2882 | fi |
568 | if [[ -n ${SWAPHDD} ]] | ||
569 | then | ||
570 | addconfig -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" | ||
571 | fi | ||
572 | niro | 2443 | addconfig -e "proc\t/proc\tproc\tdefaults\t0 0" |
573 | addconfig -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" | ||
574 | |||
575 | niro | 2320 | # install network config skeleton |
576 | niro | 2443 | CONFIG="${INSTALLROOT}/etc/conf.d/net.eth0" |
577 | clearconfig | ||
578 | addconfig 'ONBOOT="yes"' | ||
579 | addconfig 'NETWORKING="dhcp"' | ||
580 | niro | 2320 | |
581 | niro | 2442 | # intel framebuffer quirk |
582 | niro | 2500 | CONFIG="${INSTALLROOT}/etc/splash/splash.conf" |
583 | if [ -e ${CONFIG} ] && [ -e /proc/fb ] | ||
584 | niro | 2320 | then |
585 | niro | 2500 | if [[ ! -z $(grep 'inteldrmfb' /proc/fb) ]] |
586 | niro | 2320 | then |
587 | niro | 2500 | fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') |
588 | [[ ${fbdev} != 0 ]] && sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${CONFIG} || dialog_die | ||
589 | niro | 2320 | fi |
590 | fi | ||
591 | } | ||
592 | |||
593 | |||
594 | niro | 2482 | ### installer dialogs ### |
595 | |||
596 | dialog_die() | ||
597 | { | ||
598 | ERROR="$1" | ||
599 | RETVAL="$?" | ||
600 | dialog_install_failure | ||
601 | exit 1 | ||
602 | } | ||
603 | |||
604 | dialog_warning() | ||
605 | { | ||
606 | local retval | ||
607 | |||
608 | yesnobox $"\Z1 !!! Warning !!! \Zn\n\n\This harddrive will be irreversibly erased.\n\n\Do you want to continue ?" | ||
609 | retval=$? | ||
610 | if [[ ${retval} -eq 1 ]] | ||
611 | then | ||
612 | clear | ||
613 | echo $"The process was aborted." | ||
614 | exit 1 | ||
615 | fi | ||
616 | } | ||
617 | |||
618 | |||
619 | ### installer tasks ### | ||
620 | |||
621 | task_setup_system_menu() | ||
622 | { | ||
623 | local mode | ||
624 | local retval | ||
625 | |||
626 | mode="$(dialog_setup_system_menu)" | ||
627 | retval=$? | ||
628 | [[ ${retval} -eq 1 ]] && return 1 | ||
629 | if [[ ${retval} -eq 0 ]] | ||
630 | then | ||
631 | case "${mode}" in | ||
632 | niro | 2882 | "1") run_install auto ;; |
633 | "2") run_install normal ;; | ||
634 | niro | 2482 | "") task_setup_system_menu;; |
635 | esac | ||
636 | fi | ||
637 | } | ||
638 | |||
639 | task_hardware_detection() | ||
640 | { | ||
641 | local message | ||
642 | |||
643 | run_hardware_detection_disks | ||
644 | |||
645 | message+=$"Harddrives:\n" | ||
646 | |||
647 | if [[ ! -z ${ALL_DISKS} ]] | ||
648 | then | ||
649 | for i in ${ALL_DISKS} | ||
650 | do | ||
651 | message+="\Z3${i}\Zn " | ||
652 | done | ||
653 | message+="\n" | ||
654 | fi | ||
655 | |||
656 | if [[ ! -z ${ALL_CDROMS} ]] | ||
657 | then | ||
658 | message+="\n" | ||
659 | message+=$"Optical disk drives:\n" | ||
660 | for i in ${ALL_CDROMS} | ||
661 | do | ||
662 | message+="\Z3${i}\Zn" | ||
663 | done | ||
664 | message+="\n" | ||
665 | fi | ||
666 | |||
667 | # other devices | ||
668 | run_hardware_detection | ||
669 | case "${SPECIALDEVICE}" in | ||
670 | zotac*) message+=$"\n\Z2Zotac device detected.\Zn" ;; | ||
671 | rangee) message+=$"\n\Z2Rangee device detected.\Zn" ;; | ||
672 | maxdata) message+=$"\n\Z2Maxdata device detected.\Zn" ;; | ||
673 | niro | 2892 | i845) message+=$"\n\Z2Intel i845 VGA device detected.\Zn" ;; |
674 | nomsi) message+=$"\n\Z2Mainboard with P5VD2-X/VT8237/VX700 chipset detected.\Zn" | ||
675 | message+=$"\n\Z2Disabling Message Signaled Interrupts (MSI) capability of the kernel.\Zn" ;; | ||
676 | niro | 2482 | *) message+=$"\n\ZnCommon device detected.\Zn" ;; |
677 | esac | ||
678 | if [[ ${FORMFACTOR} = laptop ]] | ||
679 | then | ||
680 | message+=$"\n\ZnFormfactor Laptop, activating 'ondemand' powersaving mode.\Zn" | ||
681 | fi | ||
682 | niro | 2890 | if [[ ${FLASHDISK} = 1 ]] |
683 | then | ||
684 | message+=$"\n\ZnFlash memory detected.\Zn" | ||
685 | niro | 2942 | message+=$"\n\ZnF2FS will be used as default filesystem within the auto installation mode.\Zn" |
686 | niro | 2890 | fi |
687 | niro | 2482 | |
688 | messagebox -y 12 -h $"Detected hardware:" "${message}" | ||
689 | } | ||
690 | |||
691 | niro | 2937 | task_select_target_hdd() |
692 | { | ||
693 | if [[ -z ${ALL_DISKS} ]] | ||
694 | then | ||
695 | dialog_no_harddrive_found | ||
696 | exit 1 | ||
697 | else | ||
698 | export HDD=$(dialog_select_target_harddrive) | ||
699 | fi | ||
700 | } | ||
701 | |||
702 | niro | 2882 | task_setup_hdd_partitions() |
703 | niro | 2482 | { |
704 | local retval | ||
705 | |||
706 | niro | 2937 | if [[ -z ${HDD} ]] |
707 | niro | 2482 | then |
708 | dialog_no_harddrive_found | ||
709 | exit 1 | ||
710 | else | ||
711 | niro | 2937 | dialog_setup_hdd_info |
712 | setup_hdd_partitions | ||
713 | niro | 2482 | fi |
714 | } | ||
715 | |||
716 | task_main() | ||
717 | { | ||
718 | local method=0 | ||
719 | local retval | ||
720 | |||
721 | while [[ ${method} -le 2 ]] | ||
722 | do | ||
723 | method=$(dialog_main) | ||
724 | retval=$? | ||
725 | [[ ${retval} -eq 1 ]] && exit 1 | ||
726 | if [[ ${retval} -eq 0 ]] | ||
727 | then | ||
728 | case ${method} in | ||
729 | "1") task_setup_system_menu ;; | ||
730 | "2") task_hardware_detection ;; | ||
731 | "3") install_do_reboot ;; | ||
732 | "4") /bin/bash --login -i ;; | ||
733 | esac | ||
734 | fi | ||
735 | done | ||
736 | } | ||
737 | |||
738 | niro | 2882 | run_install() |
739 | niro | 2320 | { |
740 | niro | 2882 | local method="$1" |
741 | |||
742 | niro | 2481 | task_hardware_detection |
743 | niro | 2937 | task_select_target_hdd |
744 | niro | 2320 | |
745 | niro | 2882 | case "${method}" in |
746 | auto) | ||
747 | niro | 2890 | if [[ ${FLASHDISK} = 1 ]] |
748 | then | ||
749 | export BOOTHDD="${HDD}1" | ||
750 | export SWAPHDD="" | ||
751 | export ROOTHDD="${HDD}2" | ||
752 | niro | 2940 | export FORMAT_FILESYSTEM_BOOTHDD="ext2" |
753 | export FORMAT_FILESYSTEM_ROOTHDD="f2fs" | ||
754 | niro | 2890 | else |
755 | niro | 2941 | # ext4 seems not to be compatible again |
756 | if [[ ${FORMAT_FILESYSTEM} = ext4 ]] | ||
757 | then | ||
758 | export BOOTHDD="${HDD}1" | ||
759 | export SWAPHDD="" | ||
760 | export ROOTHDD="${HDD}2" | ||
761 | export FORMAT_FILESYSTEM_BOOTHDD="ext2" | ||
762 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" | ||
763 | else | ||
764 | export BOOTHDD="" | ||
765 | export SWAPHDD="" | ||
766 | export ROOTHDD="${HDD}1" | ||
767 | export FORMAT_FILESYSTEM_BOOTHDD="" | ||
768 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" | ||
769 | fi | ||
770 | niro | 2890 | fi |
771 | niro | 2882 | export INSTALL_METHOD="${method}" |
772 | ;; | ||
773 | normal) | ||
774 | niro | 2886 | export BOOTHDD="${HDD}1" |
775 | export SWAPHDD="${HDD}2" | ||
776 | export ROOTHDD="${HDD}3" | ||
777 | niro | 2885 | export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" |
778 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" | ||
779 | niro | 2882 | export INSTALL_METHOD="${method}" |
780 | ;; | ||
781 | niro | 2885 | single) |
782 | niro | 2886 | export BOOTHDD="" |
783 | export SWAPHDD="" | ||
784 | export ROOTHDD="${HDD}1" | ||
785 | niro | 2885 | export FORMAT_FILESYSTEM_BOOTHDD="" |
786 | export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" | ||
787 | export INSTALL_METHOD="${method}" | ||
788 | ;; | ||
789 | niro | 2887 | flash) |
790 | export BOOTHDD="${HDD}1" | ||
791 | export SWAPHDD="" | ||
792 | export ROOTHDD="${HDD}2" | ||
793 | niro | 2940 | export FORMAT_FILESYSTEM_BOOTHDD="ext2" |
794 | niro | 2887 | export FORMAT_FILESYSTEM_ROOTHDD="f2fs" |
795 | export INSTALL_METHOD="${method}" | ||
796 | ;; | ||
797 | niro | 2882 | *) |
798 | die "Unknown install method '${method}', aborting." | ||
799 | ;; | ||
800 | esac | ||
801 | niro | 2320 | |
802 | niro | 2882 | task_setup_hdd_partitions |
803 | niro | 2320 | dialog_setup_hdd_format |
804 | niro | 2399 | setup_hdd_format > /dev/null |
805 | niro | 2485 | mount_rootfs |
806 | niro | 2423 | (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | install_meter | dialog_install_system_image |
807 | niro | 2320 | |
808 | dialog_install_settings | ||
809 | sleep 1 | ||
810 | niro | 2399 | install_system_settings |
811 | niro | 2440 | if is_initrd_supported |
812 | then | ||
813 | dialog_install_initrd | ||
814 | initrd_config | ||
815 | initrd_install | ||
816 | fi | ||
817 | niro | 2320 | |
818 | dialog_install_bootsector | ||
819 | niro | 2440 | bootloader_config |
820 | bootloader_install | ||
821 | niro | 2320 | |
822 | niro | 2485 | umount_rootfs |
823 | niro | 2320 | dialog_install_successful |
824 | } | ||
825 | |||
826 | niro | 2409 | # set some proper traps |
827 | trap "trap_exit" SIGINT SIGQUIT | ||
828 | |||
829 | niro | 2477 | task_main |
830 | niro | 2320 | |
831 | exit 0 |