40 |
fi |
fi |
41 |
done |
done |
42 |
|
|
43 |
|
# 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 |
### System/Config Version |
### System/Config Version |
63 |
VERSION="%VERSIONTAG%" |
VERSION="%VERSIONTAG%" |
64 |
TITLE="${DEFAULT_TITLE} - ${VERSION}" |
TITLE="${DEFAULT_TITLE} - ${VERSION}" |
66 |
# initialize global variables so they are exportable |
# initialize global variables so they are exportable |
67 |
# some sane defaults |
# some sane defaults |
68 |
INSTALL_METHOD="" |
INSTALL_METHOD="" |
69 |
LIVEROOT="${DEFAULT_LIVEROOT}" |
if [[ -n ${cmdliveroot} ]] |
70 |
IMAGEROOT="${DEFAULT_IMAGEROOT}" |
then |
71 |
INSTALLROOT="${DEFAULT_INSTALLROOT}" |
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 |
KERNELPKG="${DEFAULT_KERNELPKG}" |
KERNELPKG="${DEFAULT_KERNELPKG}" |
88 |
KERNELOPTS="${DEFAULT_KERNELOPTS}" |
KERNELOPTS="${DEFAULT_KERNELOPTS}" |
89 |
GRUBLEGACYOPTS="" |
GRUBLEGACYOPTS="" |
91 |
FDISKPARTIONBELOW256MB=0 |
FDISKPARTIONBELOW256MB=0 |
92 |
SPECIALDEVICE="" |
SPECIALDEVICE="" |
93 |
FORMFACTOR="${DEFAULT_FORMFACTOR}" |
FORMFACTOR="${DEFAULT_FORMFACTOR}" |
94 |
FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}" |
if [[ -n ${cmdformatfilesystem} ]] |
95 |
|
then |
96 |
|
FORMAT_FILESYSTEM="${cmdformatfilesystem}" |
97 |
|
else |
98 |
|
FORMAT_FILESYSTEM="${DEFAULT_FILESYSTEM}" |
99 |
|
fi |
100 |
FLASHDISK=0 |
FLASHDISK=0 |
101 |
|
|
102 |
# TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 ! |
# TOTALLINES=linecount of ${CDIMAGENAME}-tarball -1 ! |
193 |
run_hardware_detection() |
run_hardware_detection() |
194 |
{ |
{ |
195 |
local hwinfo |
local hwinfo |
|
|
|
196 |
hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" |
hwinfo="$(hwinfo --bios --storage --pci --gfxcard --sys)" |
197 |
|
|
198 |
# check for special devices/clients: |
# check for special devices/clients: |
290 |
export ALL_CDROMS="$(get_hwinfo cdrom)" |
export ALL_CDROMS="$(get_hwinfo cdrom)" |
291 |
} |
} |
292 |
|
|
293 |
|
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 |
setup_hdd_partitions() |
setup_hdd_partitions() |
316 |
{ |
{ |
317 |
|
local partition_number |
318 |
|
local partition_type |
319 |
|
local partition_start_sector |
320 |
|
local partition_size |
321 |
|
|
322 |
# sanity check - should not happen |
# sanity check - should not happen |
323 |
if is_mounted --device "${ROOTHDD}" |
if is_mounted --device "${ROOTHDD}" |
324 |
then |
then |
348 |
fi |
fi |
349 |
|
|
350 |
## delete disk |
## delete disk |
351 |
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || dialog_die |
auto_partition_clear_disk |
352 |
|
|
353 |
|
# setup partition options |
354 |
|
export PARTITION_OPTS |
355 |
|
|
356 |
if [[ ${FLASHDISK} = 1 ]] |
if [[ -n ${BOOTHDD} ]] |
357 |
then |
then |
358 |
|
# create a boot disk with 50meg size - bootable |
359 |
|
partition_type="p" |
360 |
|
partition_number="1" |
361 |
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
362 |
then |
then |
363 |
## setup one bootable partition |
# 2= default sector start // small disk needs more space for grub2 mbr sector |
364 |
# 1. n= new disk |
partition_start_sector="2" |
365 |
# 2. p= primary disk |
else |
366 |
# 3. 1= first partition |
# '' use default sector start |
367 |
# 4. 2= default sector start // small disk needs more space for grub2 mbr sector |
partition_start_sector="" |
368 |
# 5. ''= defaul sector end |
fi |
369 |
# 6. a= bootable flag |
# 50meg size |
370 |
# 7. 1= boot flag for partition 1 |
partition_size="+50M" |
|
# 8. n= new disk |
|
|
#10. p= primary disk |
|
|
#11. 2= second partition |
|
|
#12. ''= default sector start |
|
|
#13. ''= defaul sector end |
|
|
#14. w= write/quit |
|
|
fdisk ${HDD} &> /dev/null << EOF |
|
|
n |
|
|
p |
|
|
1 |
|
|
2 |
|
|
+50M |
|
|
a |
|
|
1 |
|
|
n |
|
|
p |
|
|
2 |
|
371 |
|
|
372 |
|
# 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 |
|
|
385 |
|
# mark the disk bootable |
386 |
|
PARTITION_OPTS="a |
387 |
|
${partition_number} |
388 |
|
w" |
389 |
|
auto_partition_command |
390 |
|
|
391 |
w |
fi |
|
EOF |
|
|
else |
|
|
## setup one bootable partition |
|
|
# 1. n= new disk |
|
|
# 2. p= primary disk |
|
|
# 3. 1= first partition |
|
|
# 4. ''= default sector start |
|
|
# 5. ''= defaul sector end |
|
|
# 6. a= bootable flag |
|
|
# 7. 1= boot flag for partition 1 |
|
|
# 8. n= new disk |
|
|
#10. p= primary disk |
|
|
#11. 2= second partition |
|
|
#12. ''= default sector start |
|
|
#13. ''= defaul sector end |
|
|
#14. w= write/quit |
|
|
fdisk ${HDD} &> /dev/null << EOF |
|
|
n |
|
|
p |
|
|
1 |
|
|
|
|
|
+50M |
|
|
a |
|
|
1 |
|
|
n |
|
|
p |
|
|
2 |
|
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 |
|
else |
402 |
|
# 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 |
|
|
418 |
|
# 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 |
|
|
428 |
|
# 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 |
|
|
442 |
w |
if [[ -n ${ROOTHDD} ]] |
443 |
EOF |
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 |
|
fi |
451 |
|
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 |
fi |
|
else |
|
461 |
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
462 |
then |
then |
463 |
## setup one bootable partition |
if [[ -z ${BOOTHDD} ]] |
464 |
#1. n= new disk |
then |
465 |
#2. p= primary disk |
# 2= default sector start // small disk needs more space for grub2 mbr sector |
466 |
#3. 1= first partition |
partition_start_sector="2" |
467 |
#4. 2= default sector start // small disk needs more space for grub2 mbr sector |
else |
468 |
#5. ''= defaul sector end |
# fake sector 2 and fdisk finds the next free sector which must be selected with enter |
469 |
#6. a= bootable flag |
partition_start_sector="2 |
470 |
#7. 1= boot flag for partition 1 |
" |
471 |
#8. w= write/quit |
fi |
|
fdisk ${HDD} &> /dev/null << EOF |
|
|
n |
|
|
p |
|
|
1 |
|
|
2 |
|
|
|
|
|
a |
|
|
1 |
|
|
w |
|
|
EOF |
|
472 |
else |
else |
473 |
## setup one bootable partition |
# '' use default sector start |
474 |
#1. n= new disk |
partition_start_sector="" |
475 |
#2. p= primary disk |
fi |
476 |
#3. 1= first partition |
# '' default sector end |
477 |
#4. ''= default sector start |
partition_size="" |
478 |
#5. ''= defaul sector end |
|
479 |
#6. a= bootable flag |
# create system disk with remaining space |
480 |
#7. 1= boot flag for partition 1 |
# w= write/quit |
481 |
#8. w= write/quit |
PARTITION_OPTS="n |
482 |
fdisk ${HDD} &> /dev/null << EOF |
${partition_type} |
483 |
n |
${partition_number} |
484 |
p |
${partition_start_sector} |
485 |
1 |
${partition_size} |
486 |
|
w" |
487 |
|
# create the disk |
488 |
a |
auto_partition_command |
489 |
1 |
|
490 |
w |
# no boot disk? then this is the boot disk |
491 |
EOF |
if [[ -z ${BOOTHDD} ]] |
492 |
|
then |
493 |
|
# mark the disk bootable |
494 |
|
PARTITION_OPTS="a |
495 |
|
${partition_number} |
496 |
|
w" |
497 |
|
auto_partition_command |
498 |
fi |
fi |
499 |
fi |
fi |
500 |
else |
else |
559 |
clearconfig |
clearconfig |
560 |
if [[ -n ${BOOTHDD} ]] |
if [[ -n ${BOOTHDD} ]] |
561 |
then |
then |
562 |
addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/\t${FORMAT_FILESYSTEM_BOOTHDD}\tnoatime\t1 1" |
addconfig -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM_BOOTHDD}\tdefaults,noatime\t1 1" |
563 |
fi |
fi |
564 |
if [[ -n ${ROOTHDD} ]] |
if [[ -n ${ROOTHDD} ]] |
565 |
then |
then |
566 |
addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tnoatime\t0 0" |
addconfig -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM_ROOTHDD}\tdefaults,noatime\t0 0" |
567 |
fi |
fi |
568 |
if [[ -n ${SWAPHDD} ]] |
if [[ -n ${SWAPHDD} ]] |
569 |
then |
then |
682 |
if [[ ${FLASHDISK} = 1 ]] |
if [[ ${FLASHDISK} = 1 ]] |
683 |
then |
then |
684 |
message+=$"\n\ZnFlash memory detected.\Zn" |
message+=$"\n\ZnFlash memory detected.\Zn" |
685 |
message+=$"\n\ZnF2FS will be used as default filesystem withn the auto installation mode.\Zn" |
message+=$"\n\ZnF2FS will be used as default filesystem within the auto installation mode.\Zn" |
686 |
fi |
fi |
687 |
|
|
688 |
messagebox -y 12 -h $"Detected hardware:" "${message}" |
messagebox -y 12 -h $"Detected hardware:" "${message}" |
689 |
} |
} |
690 |
|
|
691 |
|
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 |
task_setup_hdd_partitions() |
task_setup_hdd_partitions() |
703 |
{ |
{ |
|
local i |
|
704 |
local retval |
local retval |
705 |
|
|
706 |
if [[ -z ${ALL_DISKS} ]] |
if [[ -z ${HDD} ]] |
707 |
then |
then |
708 |
dialog_no_harddrive_found |
dialog_no_harddrive_found |
709 |
exit 1 |
exit 1 |
710 |
else |
else |
711 |
HDD=$(dialog_select_target_harddrive) |
dialog_setup_hdd_info |
712 |
retval=$? |
setup_hdd_partitions |
|
[[ ${retval} -eq 1 ]] && return 1 |
|
|
if [[ ${retval} -eq 0 ]] |
|
|
then |
|
|
dialog_setup_hdd_info |
|
|
setup_hdd_partitions |
|
|
fi |
|
713 |
fi |
fi |
714 |
} |
} |
715 |
|
|
740 |
local method="$1" |
local method="$1" |
741 |
|
|
742 |
task_hardware_detection |
task_hardware_detection |
743 |
|
task_select_target_hdd |
744 |
|
|
745 |
case "${method}" in |
case "${method}" in |
746 |
auto) |
auto) |
749 |
export BOOTHDD="${HDD}1" |
export BOOTHDD="${HDD}1" |
750 |
export SWAPHDD="" |
export SWAPHDD="" |
751 |
export ROOTHDD="${HDD}2" |
export ROOTHDD="${HDD}2" |
752 |
export FORMAT_FILESYSTEM_BOOTHDD="f2fs" |
export FORMAT_FILESYSTEM_BOOTHDD="ext2" |
753 |
export FORMAT_FILESYSTEM_ROOTHDD="ext2" |
export FORMAT_FILESYSTEM_ROOTHDD="f2fs" |
754 |
else |
else |
755 |
export BOOTHDD="" |
# ext4 seems not to be compatible again |
756 |
export SWAPHDD="" |
if [[ ${FORMAT_FILESYSTEM} = ext4 ]] |
757 |
export ROOTHDD="${HDD}1" |
then |
758 |
export FORMAT_FILESYSTEM_BOOTHDD="" |
export BOOTHDD="${HDD}1" |
759 |
export FORMAT_FILESYSTEM_ROOTHDD="${FORMAT_FILESYSTEM}" |
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 |
fi |
fi |
771 |
export INSTALL_METHOD="${method}" |
export INSTALL_METHOD="${method}" |
772 |
;; |
;; |
790 |
export BOOTHDD="${HDD}1" |
export BOOTHDD="${HDD}1" |
791 |
export SWAPHDD="" |
export SWAPHDD="" |
792 |
export ROOTHDD="${HDD}2" |
export ROOTHDD="${HDD}2" |
793 |
export FORMAT_FILESYSTEM_BOOTHDD="${FORMAT_FILESYSTEM}" |
export FORMAT_FILESYSTEM_BOOTHDD="ext2" |
794 |
export FORMAT_FILESYSTEM_ROOTHDD="f2fs" |
export FORMAT_FILESYSTEM_ROOTHDD="f2fs" |
795 |
export INSTALL_METHOD="${method}" |
export INSTALL_METHOD="${method}" |
796 |
;; |
;; |