21 |
######################################## |
######################################## |
22 |
|
|
23 |
### System/Config Version |
### System/Config Version |
24 |
VERSION="0.3.7" |
VERSION="%VERSIONTAG%" |
25 |
TITLE="alxinstall-ng - ${VERSION}" |
TITLE="alxinstall-ng - ${VERSION}" |
26 |
|
|
27 |
CDPATH="/mnt/cdrom" |
CDPATH="/mnt/cdrom" |
31 |
CURRENTLINE=0 |
CURRENTLINE=0 |
32 |
#TOTALLINES=11072 # -> now in images.conf |
#TOTALLINES=11072 # -> now in images.conf |
33 |
|
|
34 |
# standart kernel opts |
# standard kernel opts |
35 |
KERNELOPTS="quiet" |
KERNELOPTS="quiet video=1024x768" |
36 |
|
|
37 |
|
# grub options |
38 |
|
GRUBLEGACYOPTS="" |
39 |
|
GRUB2OPTS="" |
40 |
|
|
41 |
|
# fdisk options |
42 |
|
FDISKPARTIONBELOW256MB=0 |
43 |
|
|
44 |
# default specialdevices |
# default specialdevices |
45 |
SPECIALDEVICE="" |
SPECIALDEVICE="" |
207 |
run_hardware_detection |
run_hardware_detection |
208 |
case "${SPECIALDEVICE}" in |
case "${SPECIALDEVICE}" in |
209 |
zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
zotac) echo " \n\n\n \\Z2Zotac Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
210 |
|
rangee) echo " \n\n\n \\Z2Rangee Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
211 |
*) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
*) echo " \n\n\n \\ZnStandard Device erkannt!\\Zn \\" >> ${hwtmp} ;; |
212 |
esac |
esac |
213 |
|
|
439 |
################################################# |
################################################# |
440 |
run_hardware_detection() |
run_hardware_detection() |
441 |
{ |
{ |
442 |
|
local hwinfo |
443 |
|
|
444 |
|
hwinfo="$(hwinfo --bios --storage)" |
445 |
|
|
446 |
# check for special devices/clients: |
# check for special devices/clients: |
447 |
# if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd |
# if zotac a zotac and the disk is a removeable device, then add rootdelay to kernelcmd |
448 |
local removable=0 |
local removable=0 |
449 |
if [[ ! -z $(hwinfo --bios --storage | grep -i zotac) ]] |
if [[ ! -z $(echo "${hwinfo}" | grep -i zotac) ]] |
450 |
then |
then |
451 |
for i in /sys/block/[hs]d*/removable |
for i in /sys/block/[hs]d*/removable |
452 |
do |
do |
456 |
fi |
fi |
457 |
done |
done |
458 |
|
|
459 |
export KERNELOPTS="${KERNELOPTS} rootdelay=8" |
# only add this for grub legacy, grub2 detect these settings on its own |
460 |
|
export GRUBLEGACYOPTS="rootdelay=8" |
461 |
export SPECIALDEVICE="zotac" |
export SPECIALDEVICE="zotac" |
462 |
fi |
fi |
463 |
|
|
464 |
|
# check for special devices/clients: |
465 |
|
# if a rangee and disk ist smaller then 256mb move partion one block further ahead |
466 |
|
if [[ ! -z $(echo "${hwinfo}" | grep -i CLE266) ]] |
467 |
|
then |
468 |
|
# for a rangee always define partion startblock +1 |
469 |
|
export FDISKPARTIONBELOW256MB="1" |
470 |
|
export SPECIALDEVICE="rangee" |
471 |
|
export GRUBLEGACYOPTS="" |
472 |
|
fi |
473 |
|
} |
474 |
|
|
475 |
|
hdd_size_below_256mb() |
476 |
|
{ |
477 |
|
local hdd="$1" |
478 |
|
local size |
479 |
|
local retval |
480 |
|
[[ -z ${hdd} ]] && die "Error: get_hdd_size() no \$hdd given!" |
481 |
|
|
482 |
|
size=$(fdisk -l ${hdd} | grep "Disk.*${hdd}" | sed 's:.*,\ \(.*\)\ byte.*:\1:') |
483 |
|
if [[ ${size} -le 257000000 ]] |
484 |
|
then |
485 |
|
retval="0" |
486 |
|
else |
487 |
|
retval="1" |
488 |
|
fi |
489 |
|
|
490 |
|
return "${retval}" |
491 |
} |
} |
492 |
|
|
493 |
setup_hdd_partitions_auto() |
setup_hdd_partitions_auto() |
494 |
{ |
{ |
495 |
ROOTHDD="${HDD}1" |
ROOTHDD="${HDD}1" |
496 |
|
|
497 |
|
# run this only if FDISKPARTITIONBELOW256MB is not already 1 |
498 |
|
if [[ ${FDISKPARTIONBELOW256MB} != 1 ]] |
499 |
|
then |
500 |
|
if hdd_size_below_256mb ${HDD} |
501 |
|
then |
502 |
|
FDISKPARTIONBELOW256MB=1 |
503 |
|
else |
504 |
|
FDISKPARTIONBELOW256MB=0 |
505 |
|
fi |
506 |
|
fi |
507 |
|
|
508 |
## delete disk |
## delete disk |
509 |
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die |
dd if=/dev/zero of=${HDD} count=1 &> /dev/null || die |
510 |
|
|
511 |
## setup one bootable partition |
if [[ ${FDISKPARTIONBELOW256MB} = 1 ]] |
512 |
#1. n= new disk |
then |
513 |
#2. p= primary disk |
## setup one bootable partition |
514 |
#3. 1= first partition |
#1. n= new disk |
515 |
#4. ''= default sector start |
#2. p= primary disk |
516 |
#5. ''= defaul sector end |
#3. 1= first partition |
517 |
#6. a= bootable flag |
#4. 2= default sector start // small disk needs more space for grub2 mbr sector |
518 |
#7. 1= boot flag for partition 1 |
#5. ''= defaul sector end |
519 |
#8. w= write/quit |
#6. a= bootable flag |
520 |
fdisk ${HDD} &> /dev/null << EOF |
#7. 1= boot flag for partition 1 |
521 |
|
#8. w= write/quit |
522 |
|
fdisk ${HDD} &> /dev/null << EOF |
523 |
|
n |
524 |
|
p |
525 |
|
1 |
526 |
|
2 |
527 |
|
|
528 |
|
a |
529 |
|
1 |
530 |
|
w |
531 |
|
EOF |
532 |
|
else |
533 |
|
## setup one bootable partition |
534 |
|
#1. n= new disk |
535 |
|
#2. p= primary disk |
536 |
|
#3. 1= first partition |
537 |
|
#4. ''= default sector start |
538 |
|
#5. ''= defaul sector end |
539 |
|
#6. a= bootable flag |
540 |
|
#7. 1= boot flag for partition 1 |
541 |
|
#8. w= write/quit |
542 |
|
fdisk ${HDD} &> /dev/null << EOF |
543 |
n |
n |
544 |
p |
p |
545 |
1 |
1 |
549 |
1 |
1 |
550 |
w |
w |
551 |
EOF |
EOF |
552 |
|
fi |
553 |
} |
} |
554 |
|
|
555 |
setup_hdd_partitions_manuell() |
setup_hdd_partitions_manuell() |
606 |
install_bootsector_chroot() |
install_bootsector_chroot() |
607 |
{ |
{ |
608 |
local my_roothdd |
local my_roothdd |
609 |
|
local grubconf=${INSTALLPATH}/boot/grub/grub.conf |
610 |
|
local grub2conf=/boot/grub/grub.cfg |
611 |
|
|
612 |
### grubconf schreiben |
# check for grub2 |
613 |
source ${INSTALLPATH}/boot/kernelversion |
if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]] |
|
|
|
|
#for alx only |
|
|
if [ -e ${INSTALLPATH}/etc/alx_version ] |
|
614 |
then |
then |
615 |
OLD_ALXVER="${ALXVER}" |
# needed by grub-mkconfig on the first run |
616 |
source ${INSTALLPATH}/etc/alx_version |
if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]] |
617 |
KRNVER="ALX-${ALXVER}" |
then |
618 |
ALXVER="${OLD_ALXVER}" |
install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die |
619 |
fi |
fi |
620 |
|
|
621 |
[[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX" |
# set kernelopts |
622 |
[[ -z ${KRNINITRD} ]] && KRNINITRD="initrd" |
if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]] |
623 |
[[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz" |
then |
624 |
|
sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die |
625 |
|
else |
626 |
|
echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALLPATH}/etc/conf.d/grub || die |
627 |
|
fi |
628 |
|
echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die |
629 |
|
echo "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die |
630 |
|
echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die |
631 |
|
echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die |
632 |
|
|
633 |
# uuid support |
# grub-legacy |
|
if is_uuid_supported |
|
|
then |
|
|
my_roothdd="UUID=$(get_uuid ${ROOTHDD})" |
|
634 |
else |
else |
635 |
my_roothdd="${ROOTHDD}" |
### grubconf schreiben |
636 |
fi |
source ${INSTALLPATH}/boot/kernelversion |
637 |
|
|
638 |
local grubconf=${INSTALLPATH}/boot/grub/grub.conf |
#for alx only |
639 |
: > ${grubconf} || die |
if [ -e ${INSTALLPATH}/etc/alx_version ] |
640 |
echo "default 0" >> ${grubconf} || die |
then |
641 |
echo "timeout 3" >> ${grubconf} || die |
OLD_ALXVER="${ALXVER}" |
642 |
# using current root password |
source ${INSTALLPATH}/etc/alx_version |
643 |
echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} || die |
KRNVER="ALX-${ALXVER}" |
644 |
|
ALXVER="${OLD_ALXVER}" |
645 |
|
fi |
646 |
|
|
647 |
echo >> ${grubconf} || die |
[[ -z ${KRNVER} ]] && KRNVER="AutoSta_LX" |
648 |
echo "# normal boot" >> ${grubconf} || die |
[[ -z ${KRNINITRD} ]] && KRNINITRD="initrd" |
649 |
echo "title ${KRNVER}" >> ${grubconf} || die |
[[ -z ${KRNIMG} ]] && KRNIMG="vmlinuz" |
|
echo "root (hd0,0)" >> ${grubconf} || die |
|
|
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS}" >> ${grubconf} || die |
|
|
if is_initrd_supported |
|
|
then |
|
|
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
|
|
fi |
|
650 |
|
|
651 |
echo >> ${grubconf} || die |
# uuid support |
652 |
echo "# admin boot" >> ${grubconf} || die |
if is_uuid_supported |
653 |
echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die |
then |
654 |
echo "lock" >> ${grubconf} || die |
my_roothdd="UUID=$(get_uuid ${ROOTHDD})" |
655 |
echo "root (hd0,0)" >> ${grubconf} || die |
else |
656 |
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} hardware-auto-detection" >> ${grubconf} || die |
my_roothdd="${ROOTHDD}" |
657 |
if is_initrd_supported |
fi |
|
then |
|
|
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
|
|
fi |
|
658 |
|
|
659 |
echo >> ${grubconf} || die |
: > ${grubconf} || die |
660 |
echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die |
echo "default 0" >> ${grubconf} || die |
661 |
echo "lock" >> ${grubconf} || die |
echo "timeout 3" >> ${grubconf} || die |
662 |
echo "root (hd0,0)" >> ${grubconf} || die |
# using current root password |
663 |
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} alx-reset-settings" >> ${grubconf} || die |
echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} || die |
664 |
if is_initrd_supported |
|
665 |
then |
echo >> ${grubconf} || die |
666 |
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
echo "# normal boot" >> ${grubconf} || die |
667 |
fi |
echo "title ${KRNVER}" >> ${grubconf} || die |
668 |
|
echo "root (hd0,0)" >> ${grubconf} || die |
669 |
|
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die |
670 |
|
if is_initrd_supported |
671 |
|
then |
672 |
|
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
673 |
|
fi |
674 |
|
|
675 |
# bootsector schreiben chrooted schreiben (lfs/magellan) |
echo >> ${grubconf} || die |
676 |
cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF |
echo "# admin boot" >> ${grubconf} || die |
677 |
|
echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die |
678 |
|
echo "lock" >> ${grubconf} || die |
679 |
|
echo "root (hd0,0)" >> ${grubconf} || die |
680 |
|
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die |
681 |
|
if is_initrd_supported |
682 |
|
then |
683 |
|
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
684 |
|
fi |
685 |
|
|
686 |
|
echo >> ${grubconf} || die |
687 |
|
echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die |
688 |
|
echo "lock" >> ${grubconf} || die |
689 |
|
echo "root (hd0,0)" >> ${grubconf} || die |
690 |
|
echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die |
691 |
|
if is_initrd_supported |
692 |
|
then |
693 |
|
echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die |
694 |
|
fi |
695 |
|
|
696 |
|
# bootsector schreiben chrooted schreiben (lfs/magellan) |
697 |
|
cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF |
698 |
/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null |
/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null |
699 |
root (hd0,0) |
root (hd0,0) |
700 |
setup (hd0) |
setup (hd0) |
702 |
EOF |
EOF |
703 |
exit 0 |
exit 0 |
704 |
CHROOTEOF |
CHROOTEOF |
705 |
|
fi |
706 |
|
|
707 |
## enters chroot |
## enters chroot |
708 |
mount -t proc proc ${INSTALLPATH}/proc |
mount -t proc proc ${INSTALLPATH}/proc |
709 |
mount -t sysfs sysfs ${INSTALLPATH}/sys |
mount -t sysfs sysfs ${INSTALLPATH}/sys |
710 |
mount -o bind /dev ${INSTALLPATH}/dev |
mount -o bind /dev ${INSTALLPATH}/dev |
711 |
chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i |
chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i |
712 |
umount ${INSTALLPATH}/proc |
umount ${INSTALLPATH}/proc |
713 |
umount ${INSTALLPATH}/sys |
umount ${INSTALLPATH}/sys |
714 |
umount ${INSTALLPATH}/dev |
umount ${INSTALLPATH}/dev |
715 |
rm ${INSTALLPATH}/root/.bashrc |
rm ${INSTALLPATH}/root/.installrc |
716 |
} |
} |
717 |
|
|
718 |
is_initrd_supported() |
is_initrd_supported() |
727 |
# only generate initrds if the cmd exists |
# only generate initrds if the cmd exists |
728 |
is_initrd_supported || return 0 |
is_initrd_supported || return 0 |
729 |
|
|
730 |
cat > ${INSTALLPATH}/root/.bashrc << CHROOTEOF |
DISKMODS="sd_mod" |
731 |
echo "MODULES=\"${FORMAT_FILESYSTEM} amd74xx piix sis5513 via82cxxx sd_mod ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via sata_via sata_sis sata_nv\"" > /etc/conf.d/mkinitrd |
OLDPATAMODS="amd74xx piix sis5513 via82cxxx" |
732 |
|
PATAMODS="ata_piix pata_amd pata_mpiix pata_oldpiix pata_sis pata_via" |
733 |
|
SATAMODS="sata_via sata_sis sata_nv" |
734 |
|
DRMMODS="i915 mga nouveau r128 radeon savage sis tdfx ttm via" |
735 |
|
case ${SPECIALDEVICE} in |
736 |
|
zotac) FBMODS="" ;; |
737 |
|
rangee) FBMODS="viafb" ;; |
738 |
|
*) FBMODS="uvesafb" ;; |
739 |
|
esac |
740 |
|
|
741 |
|
# install an appropriate uvesafb.conf |
742 |
|
install -d ${INSTALLPATH}/etc/modprobe.d || die |
743 |
|
echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die |
744 |
|
|
745 |
|
# install an appropriate viafb.conf |
746 |
|
echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die |
747 |
|
|
748 |
|
cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF |
749 |
|
echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS}\"" > /etc/conf.d/mkinitrd |
750 |
mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null |
mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null |
751 |
exit 0 |
exit 0 |
752 |
CHROOTEOF |
CHROOTEOF |
755 |
mount -t proc proc ${INSTALLPATH}/proc |
mount -t proc proc ${INSTALLPATH}/proc |
756 |
mount -t sysfs sysfs ${INSTALLPATH}/sys |
mount -t sysfs sysfs ${INSTALLPATH}/sys |
757 |
mount -o bind /dev ${INSTALLPATH}/dev |
mount -o bind /dev ${INSTALLPATH}/dev |
758 |
chroot ${INSTALLPATH} /bin/bash --rcfile /root/.bashrc -i |
chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i |
759 |
umount ${INSTALLPATH}/proc |
umount ${INSTALLPATH}/proc |
760 |
umount ${INSTALLPATH}/sys |
umount ${INSTALLPATH}/sys |
761 |
umount ${INSTALLPATH}/dev |
umount ${INSTALLPATH}/dev |
762 |
rm ${INSTALLPATH}/root/.bashrc |
rm ${INSTALLPATH}/root/.installrc |
763 |
} |
} |
764 |
|
|
765 |
is_uuid_supported() |
is_uuid_supported() |
861 |
install_mount_rootfs |
install_mount_rootfs |
862 |
(install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image |
(install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image |
863 |
|
|
|
dialog_install_bootsector |
|
|
install_bootsector_chroot |
|
|
|
|
864 |
dialog_install_settings |
dialog_install_settings |
865 |
sleep 1 |
sleep 1 |
866 |
install_system_settings |
install_system_settings |
867 |
install_initrd_chroot |
install_initrd_chroot |
868 |
|
|
869 |
|
dialog_install_bootsector |
870 |
|
install_bootsector_chroot |
871 |
|
|
872 |
install_umount_rootfs |
install_umount_rootfs |
873 |
dialog_install_successful |
dialog_install_successful |
874 |
} |
} |
883 |
install_mount_rootfs_flash |
install_mount_rootfs_flash |
884 |
(install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image |
(install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image |
885 |
|
|
|
dialog_install_bootsector |
|
|
install_bootsector_chroot |
|
|
|
|
886 |
dialog_install_settings |
dialog_install_settings |
887 |
sleep 1 |
sleep 1 |
888 |
install_system_settings_flash |
install_system_settings_flash |
889 |
install_initrd_chroot |
install_initrd_chroot |
890 |
|
|
891 |
|
dialog_install_bootsector |
892 |
|
install_bootsector_chroot |
893 |
|
|
894 |
install_umount_rootfs_flash |
install_umount_rootfs_flash |
895 |
dialog_install_successful |
dialog_install_successful |
896 |
} |
} |
905 |
install_mount_rootfs_flash |
install_mount_rootfs_flash |
906 |
(install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image |
(install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image |
907 |
|
|
|
dialog_install_bootsector |
|
|
install_bootsector_chroot |
|
|
|
|
908 |
dialog_install_settings |
dialog_install_settings |
909 |
sleep 1 |
sleep 1 |
910 |
install_system_settings_flash |
install_system_settings_flash |
911 |
install_initrd_chroot |
install_initrd_chroot |
912 |
|
|
913 |
|
dialog_install_bootsector |
914 |
|
install_bootsector_chroot |
915 |
|
|
916 |
install_umount_rootfs_flash |
install_umount_rootfs_flash |
917 |
dialog_install_successful |
dialog_install_successful |
918 |
} |
} |