--- alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2015/07/23 11:26:26 6826 +++ alx-src/trunk/alxinstall-ng/bin/alxinstall-ng.sh.in 2015/07/23 12:28:10 6835 @@ -10,6 +10,7 @@ source /mnt/cdrom/system/images.conf # includes +source ${MLIBDIR}/functions/generic.sh source ${MLIBDIR}/functions/hwdetection.sh ### System/Config Version @@ -18,7 +19,7 @@ # locations CDPATH="/mnt/cdrom" -INSTALLPATH="/mnt/magellan" +INSTALL_ROOT="/mnt/magellan" # default system settings # standard kernel opts @@ -58,6 +59,7 @@ ERROR=$1 RETVAL=$? dialog_install_failure + trap_exit exit 1 } @@ -483,6 +485,8 @@ ;; single|auto) + BOOTHDD="" + SWAPHDD="" ROOTHDD="${HDD}1" ;; esac @@ -559,11 +563,11 @@ fi if [[ -n ${BOOTHDD} ]] then - mke2fs -j -q ${BOOTHDD} || die + mkfs.${FORMAT_FILESYSTEM} -q ${BOOTHDD} || die fi if [[ -n ${ROOTHDD} ]] then - mke2fs -j -q ${ROOTHDD} || die + mkfs.${FORMAT_FILESYSTEM} -q ${ROOTHDD} || die fi } @@ -575,61 +579,64 @@ fi if [[ -n ${ROOTHDD} ]] then - mount ${ROOTHDD} ${INSTALLPATH} || die + mount ${ROOTHDD} ${INSTALL_ROOT} || die fi if [[ -n ${BOOTHDD} ]] then - install -d ${INSTALLPATH}/boot || die - mount ${BOOTHDD} ${INSTALLPATH}/boot || die + install -d ${INSTALL_ROOT}/boot || die + mount ${BOOTHDD} ${INSTALL_ROOT}/boot || die fi - cd ${INSTALLPATH} || die + cd ${INSTALL_ROOT} || die } install_system_image() { - tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALLPATH} + tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALL_ROOT} } install_bootsector_chroot() { local my_roothdd - local grubconf=${INSTALLPATH}/boot/grub/grub.conf + local grubconf=${INSTALL_ROOT}/boot/grub/grub.conf local grub2conf=/boot/grub/grub.cfg + local CONFIG # check for grub2 - if [[ -f ${INSTALLPATH}/sbin/grub-mkconfig ]] + if [[ -f ${INSTALL_ROOT}/sbin/grub-mkconfig ]] then # needed by grub-mkconfig on the first run - if [[ ! -f ${INSTALLPATH}/boot/grub/video.lst ]] + if [[ ! -f ${INSTALL_ROOT}/boot/grub/video.lst ]] then - install -m0644 ${INSTALLPATH}/lib/grub/*/video.lst ${INSTALLPATH}/boot/grub/video.lst || die + install -m0644 ${INSTALL_ROOT}/lib/grub/*/video.lst ${INSTALL_ROOT}/boot/grub/video.lst || die fi # set kernelopts - if [[ -f ${INSTALLPATH}/etc/conf.d/grub ]] + if [[ -f ${INSTALL_ROOT}/etc/conf.d/grub ]] then - sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALLPATH}/etc/conf.d/grub || die - sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALLPATH}/etc/conf.d/grub || die + sed -i "s:^\(export GRUB_CMDLINE_LINUX_DEFAULT=\).*:\1\"${KERNELOPTS}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die + sed -i "s:^\(export GRUB_GFXPAYLOAD_LINUX=\).*:\1\"${GRUB2GFXPAYLOAD}\":" ${INSTALL_ROOT}/etc/conf.d/grub || die else - echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALLPATH}/etc/conf.d/grub || die - echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >> ${INSTALLPATH}/etc/conf.d/grub || die + echo "export GRUB_CMDLINE_LINUX_DEFAULT=\"${KERNELOPTS}\"" > ${INSTALL_ROOT}/etc/conf.d/grub || die + echo "export GRUB_GFXPAYLOAD_LINUX=\"${GRUB2GFXPAYLOAD}\"" >> ${INSTALL_ROOT}/etc/conf.d/grub || die fi - echo 'grub-mkdevicemap' > ${INSTALLPATH}/root/.installrc || die - echo "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die - echo "grub-install --no-floppy ${HDD} &> /dev/null" >> ${INSTALLPATH}/root/.installrc || die - echo "exit 0" >> ${INSTALLPATH}/root/.installrc || die + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig 'grub-mkdevicemap' + addconfig "LC_ALL=C grub-mkconfig -o ${grub2conf} &> /dev/null" + addconfig "grub-install --no-floppy ${HDD} &> /dev/null" + addconfig "exit 0" # grub-legacy else ### grubconf schreiben - source ${INSTALLPATH}/boot/kernelversion + source ${INSTALL_ROOT}/boot/kernelversion #for alx only - if [ -e ${INSTALLPATH}/etc/alx_version ] + if [ -e ${INSTALL_ROOT}/etc/alx_version ] then OLD_ALXVER="${ALXVER}" - source ${INSTALLPATH}/etc/alx_version + source ${INSTALL_ROOT}/etc/alx_version KRNVER="ALX-${ALXVER}" ALXVER="${OLD_ALXVER}" fi @@ -646,74 +653,67 @@ my_roothdd="${ROOTHDD}" fi - : > ${grubconf} || die - echo "default 0" >> ${grubconf} || die - echo "timeout 3" >> ${grubconf} || die + CONFIG="${grubconf}" + clearconfig + addconfig "default 0" + addconfig "timeout 3" # using current root password - echo "password --md5 $(cat ${INSTALLPATH}/etc/shadow | grep root | cut -d: -f2)" >> ${grubconf} || die - - echo >> ${grubconf} || die - echo "# normal boot" >> ${grubconf} || die - echo "title ${KRNVER}" >> ${grubconf} || die - echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" >> ${grubconf} || die + addconfig "password --md5 $(cat ${INSTALL_ROOT}/etc/shadow | grep root | cut -d: -f2)" + addconfig + addconfig "# normal boot" + addconfig "title ${KRNVER}" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS}" if is_initrd_supported then - echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + addconfig "initrd /boot/${KRNINITRD}" fi - - echo >> ${grubconf} || die - echo "# admin boot" >> ${grubconf} || die - echo "title ${KRNVER} - Re-run hardware-detection" >> ${grubconf} || die - echo "lock" >> ${grubconf} || die - echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" >> ${grubconf} || die + addconfig + addconfig "# admin boot" + addconfig "title ${KRNVER} - Re-run hardware-detection" + addconfig "lock" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} hardware-auto-detection" if is_initrd_supported then - echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + addconfig "initrd /boot/${KRNINITRD}" fi - - echo >> ${grubconf} || die - echo "title ${KRNVER} - Reset *all* local settings" >> ${grubconf} || die - echo "lock" >> ${grubconf} || die - echo "root (hd0,0)" >> ${grubconf} || die - echo "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" >> ${grubconf} || die + addconfig + addconfig "title ${KRNVER} - Reset *all* local settings" + addconfig "lock" + addconfig "root (hd0,0)" + addconfig "kernel /boot/${KRNIMG} root=${my_roothdd} ${KERNELOPTS} ${GRUBLEGACYOPTS} alx-reset-settings" if is_initrd_supported then - echo "initrd /boot/${KRNINITRD}" >> ${grubconf} || die + addconfig "initrd /boot/${KRNINITRD}" fi # write bootsector chrooted (lfs/magellan) - cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF -/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null -root (hd0,0) -setup (hd0) -quit -EOF -exit 0 -CHROOTEOF + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig '/usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null' + addconfig 'root (hd0,0)' + addconfig 'setup (hd0)' + addconfig 'quit' + addconfig 'EOF' + addconfig 'exit 0' fi - ## enters chroot - mount -t proc proc ${INSTALLPATH}/proc - mount -t sysfs sysfs ${INSTALLPATH}/sys - mount -o bind /dev ${INSTALLPATH}/dev - chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i - umount ${INSTALLPATH}/proc - umount ${INSTALLPATH}/sys - umount ${INSTALLPATH}/dev - rm ${INSTALLPATH}/root/.installrc + ## enter chroot + enter_chroot_installrc } is_initrd_supported() { # only generate initrds if the cmd exists - [[ -x ${INSTALLPATH}/sbin/mkinitrd ]] && return 0 + [[ -x ${INSTALL_ROOT}/sbin/mkinitrd ]] && return 0 return 1 } install_initrd_chroot() { + local CONFIG + # only generate initrds if the cmd exists is_initrd_supported || return 0 @@ -739,30 +739,27 @@ fi # install an appropriate uvesafb.conf - install -d ${INSTALLPATH}/etc/modprobe.d || die - echo "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" > ${INSTALLPATH}/etc/modprobe.d/uvesafb.conf || die + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/uvesafb.conf + clearconfig + addconfig "options uvesafb mode_option=1024x768-32@60 scroll=ywrap" # install an appropriate viafb.conf - echo "options viafb viafb_mode=1024x768 viafb_refresh=60" > ${INSTALLPATH}/etc/modprobe.d/viafb.conf || die + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/viafb.conf + clearconfig + addconfig "options viafb viafb_mode=1024x768 viafb_refresh=60" # install an appropriate i810fb.conf - echo "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60" > ${INSTALLPATH}/etc/modprobe.d/i810fb.conf || die - - cat > ${INSTALLPATH}/root/.installrc << CHROOTEOF -echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd -mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null -exit 0 -CHROOTEOF - - ## enters chroot - mount -t proc proc ${INSTALLPATH}/proc - mount -t sysfs sysfs ${INSTALLPATH}/sys - mount -o bind /dev ${INSTALLPATH}/dev - chroot ${INSTALLPATH} /bin/bash --rcfile /root/.installrc -i - umount ${INSTALLPATH}/proc - umount ${INSTALLPATH}/sys - umount ${INSTALLPATH}/dev - rm ${INSTALLPATH}/root/.installrc + CONFIG=${INSTALL_ROOT}/etc/modprobe.d/i810fb.conf + clearconfig + addconfig "options i810fb xres=1024 yres=768 bpp=16 mtrr=1 hsync1=30 hsync2=62 vsync1=30 vsync2=60" + + CONFIG=${INSTALL_ROOT}/.installrc + clearconfig + addconfig 'echo "MODULES=\"${FORMAT_FILESYSTEM} ${DISKMODS} ${OLDATAMODS} ${PATAMODS} ${SATAMODS} ${DRMMODS} ${FBMODS} ${OTHERMODS}\"" > /etc/conf.d/mkinitrd' + addconfig 'mkinitrd -f /boot/$(readlink /boot/initrd) $(readlink /boot/vmlinuz | sed "s:kernel-::g") > /dev/null' + addconfig 'exit 0' + ## enter chroot + enter_chroot_installrc } is_uuid_supported() @@ -805,29 +802,29 @@ then if [[ -n ${BOOTHDD} ]] then - echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die + echo -e "UUID=$(get_uuid ${BOOTHDD})\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALL_ROOT}/etc/fstab || die fi if [[ -n ${ROOTHDD} ]] then - echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + echo -e "UUID=$(get_uuid ${ROOTHDD})\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die fi else if [[ -n ${BOOTHDD} ]] then - echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALLPATH}/etc/fstab || die + echo -e "${BOOTHDD}\t/boot\t${FORMAT_FILESYSTEM}\tnoatime,noauto\t1 1" > ${INSTALL_ROOT}/etc/fstab || die fi if [[ -n ${ROOTHDD} ]] then - echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALLPATH}/etc/fstab || die + echo -e "${ROOTHDD}\t/\t${FORMAT_FILESYSTEM}\tnoatime\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die fi fi # not needed busybox loads all with swapon -a, even if not mentioned in fstab - #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALLPATH}/etc/fstab || die - echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die - echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALLPATH}/etc/fstab || die + #echo -e "UUID='$(get_uuid ${SWAPHDD})'\tswap\tswap\tpri=1\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die + echo -e "proc\t/proc\tproc\tdefaults\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die + echo -e "shm\t/dev/shm\ttmpfs\tdefaults\t0 0" >> ${INSTALL_ROOT}/etc/fstab || die # install network config skeleton - install -m0644 ${INSTALLPATH}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALLPATH}/etc/conf.d/ || die + install -m0644 ${INSTALL_ROOT}/etc/alxconfig-ng/skel/net/net.eth0 ${INSTALL_ROOT}/etc/conf.d/ || die # intel framebufer quirk if [[ -e /proc/fb ]] @@ -837,7 +834,7 @@ fbdev=$(grep 'inteldrmfb' /proc/fb | sed 's:\([0-9]\).*:\1:') if [[ ${fbdev} != 0 ]] then - sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALLPATH}/etc/splash/splash.conf || die + sed -i "s:^\(SPLASH_DEV=\).*:\1\"/dev/fb${fbdev}\":" ${INSTALL_ROOT}/etc/splash/splash.conf || die fi fi fi @@ -848,11 +845,11 @@ cd / if [[ -n ${BOOTHDD} ]] then - umount ${INSTALLPATH}/boot || die + umount ${INSTALL_ROOT}/boot || die fi if [[ -n ${ROOTHDD} ]] then - umount ${INSTALLPATH} || die + umount ${INSTALL_ROOT} || die fi if [[ -n ${SWAPHDD} ]] then @@ -917,6 +914,9 @@ dialog_install_successful } +# set some proper traps +trap "trap_exit" SIGINT SIGQUIT + dialog_main exit 0