#!/bin/sh # # $Header: /home/cvsd/alx-cvs/alx-src/alxinstall-ng/bin/alxinstall-ng.sh,v 1.2 2005-04-18 20:27:57 niro Exp $ # # AutoSta_LX Installation Script # version: 0.8b # # Niels Rogalla # # # # Install Navigation Gui # #source /etc/alx_version #source /opt/alx-config/version #source /etc/alx-config/config.rc #images: (get ${CDIMAGENAME}) source /mnt/cdrom/system/images.conf #Includes source /usr/lib/alxinstall-ng/functions/findhdd.sh > /dev/null ### bugfix ############################### cdromdev="`echo $cdromdev|sed -e 's/ //'`" ######################################## ### System/Config Version VERSION="0.1" TITLE="alxinstall-ng - ${VERSION}" #CONFIGS_TEMPLATE="/opt/alx-config/configs" CDPATH="/mnt/cdrom" INSTALLPATH="/mnt/magellan" ### WICHTIG: anzahl lines in der autosta_lx.tar.gz -1 CURRENTLINE=0 #TOTALLINES=11072 # -> now in images.conf ################################################# # DIALOG BOXEN # ################################################# die() { #clear #echo -e "\nhuch, da ist ein script gestorben -> $?\n" #read #exit 0 ERROR=$1 RETVAL=$? dialog_install_failure exit 1 } dialog_warning() { dialog \ --backtitle "$TITLE" \ --colors \ --defaultno \ --yesno "\Z1 !!! Achtung !!! \Zn\n\n\ Diese Festplatte wird unwiederruflich geloescht werden.\n\n\ Soll ich wirklich fortfahren ?" 10 70 RES=$? if [ "$RES" == "1" ] then clear echo "Der Vorgang wurde abgebrochen." exit 1 fi } dialog_setup_hdd_info(){ local SHDD="`echo $HDD|sed -e 's/\/dev\///'`" dialog \ --colors \ --title "[ Festplatten Partitionierung ]" \ --backtitle "$TITLE" \ --ok-label "Weiter" \ --msgbox "\nBitte legen Sie 3 Partitionen an.\n\n\ [ \Z3${SHDD}1\Zn ] Typ: \Z3Linux\Zn mit ca. 50MB\n\ [ \Z3${SHDD}2\Zn ] Typ: \Z3Linux Swap\Zn mit ca. 256MB\n\ [ \Z3${SHDD}3\Zn ] Typ: \Z3Linux \Zn mit dem Rest (min. 256MB)\n\n\ Bitte ${SHDD}1 als \Z3bootable\Zn markieren." 12 81 } dialog_setup_hdd_menu() { I=`dialog \ --backtitle "$TITLE" \ --title "[ Festplatten Partitionierung ]" \ --cancel-label "Abbrechen" \ --ok-label "Weiter" \ --stdout \ --menu "\nWaehlen Sie zwischen Manuell und Automatisch" 14 70 5 \ "1" "Manuell" \ "2" "Automatisch"` RES=$? if [ "$RES" == "1" ];then return 1 fi if [ "$RES" == "0" ];then case "$I" in "1") dialog_setup_hdd_found_manuell ;; "2") dialog_warning setup_hdd_partitions_silent ;; esac fi } dialog_setup_hdd_found_manuell() { if [ ! -z "$installdevs" ] then installdevs="" fi echo "dialog \\" > /tmp/hddtmp.sh echo "--backtitle \"$TITLE\" \\" >> /tmp/hddtmp.sh echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh echo "--stdout \\" >> /tmp/hddtmp.sh echo "--colors \\" >> /tmp/hddtmp.sh echo "--msgbox \"Gefundene Hardware:\n\n \\" >> /tmp/hddtmp.sh echo " Festplatten:\n \\" >> /tmp/hddtmp.sh if [ ! -z "$scsidisks" ] then for I in $scsidisks do if [ "$I" != "$cdromdev" ] then echo " \\Z7SCSI: \\Z3$I\\Zn\n \\" >> /tmp/hddtmp.sh installdevs="$installdevs $I" fi done fi if [ ! -z "$idedisks" ] then for I in $idedisks do if [ "$I" != "$cdromdev" ] then echo " \\Z7IDE: \\Z3$I\\Zn\n \\" >> /tmp/hddtmp.sh installdevs="$installdevs $I" fi done fi if [ ! -z "$cdromdev" ] then echo " \n \\" >> /tmp/hddtmp.sh echo " \\Z7andere Laufwerke:\n \\" >> /tmp/hddtmp.sh echo " CDROM: \\Z3$cdromdev\\Zn\n \\" >> /tmp/hddtmp.sh fi echo " \" 13 70" >> /tmp/hddtmp.sh chmod a+x /tmp/hddtmp.sh /tmp/hddtmp.sh } dialog_setup_hdd_partitions_manuell() { if [ -z "$installdevs" ] then dialog \ --backtitle "$TITLE" \ --ok-label "Beenden" \ --msgbox "Kein geeignetes Laufwerk gefunden.\nDie Installation ist fehlgeschlagen." 6 70 exit 1 else echo "dialog \\" > /tmp/hddtmp.sh echo "--backtitle \"$TITLE\" \\" >> /tmp/hddtmp.sh echo "--ok-label \"Weiter\" \\" >> /tmp/hddtmp.sh echo "--cancel-label \"Beenden\" \\" >> /tmp/hddtmp.sh echo "--stdout \\" >> /tmp/hddtmp.sh echo "--menu \"Installations Laufwerk auswaehlen:\" 10 70 3 \\" >> /tmp/hddtmp.sh for I in $installdevs do echo "\"$I\" \"\" \\" >> /tmp/hddtmp.sh done echo -e "\n" >> /tmp/hddtmp.sh chmod a+x /tmp/hddtmp.sh HDD="`/tmp/hddtmp.sh`" RES=$? if [ "$RES" == "1" ] then return 1 fi if [ "$RES" == "0" ] then dialog_setup_hdd_info setup_hdd_partitions_manuell fi fi } dialog_setup_hdd_partitions_silent() { dialog \ --backtitle "$TITLE" \ --infobox "Erstelle Partitionen ..." 3 70 } dialog_setup_hdd_format() { dialog \ --backtitle "$TITLE" \ --infobox "Erstelle Datei-Systeme ..." 3 70 } dialog_install_settings() { dialog \ --backtitle "$TITLE" \ --infobox "Speichere System-Einstellungen ..." 3 70 } dialog_install_system_image() { dialog \ --backtitle "$TITLE" \ --gauge "Kopiere System-Image ..." 6 80 } dialog_install_meter() { while [ "${CURRENTLINE}" != "${TOTALLINES}" ] ; do CURRENTLINE=`grep --count . /tmp/install.log` PERCENT=`expr ${CURRENTLINE} \* 100 / ${TOTALLINES}` echo ${PERCENT} sleep 1 done rm -f /tmp/install.log return 0 } dialog_install_bootsector() { dialog \ --backtitle "$TITLE" \ --infobox "Schreibe den Bootsektor ..." 3 70 } dialog_install_alxconfig() { dialog \ --backtitle "$TITLE" \ --infobox "Installiere die ALX Setup-Tools ..." 3 70 } dialog_install_kernel_image() { dialog \ --backtitle "$TITLE" \ --infobox "Installiere den System-Kernel ..." 3 70 } dialog_install_hotfixes() { dialog \ --backtitle "$TITLE" \ --infobox "Installiere Hotfixes ..." 3 70 } dialog_install_successful() { dialog \ --backtitle "$TITLE" \ --colors \ --msgbox "Die Installation war \Z2erfolgreich\Zn." 5 81 } dialog_install_failure() { dialog \ --backtitle "$TITLE" \ --colors \ --msgbox "Die Installation ist \Z1Fehlgeschlagen\Zn.\n\n\ Fehler bei $ERROR, RetVal: $RETVAL \ " 10 81 } dialog_install_method() { METHOD=`dialog \ --backtitle "$TITLE" \ --cancel-label "Abbrechen" \ --ok-label "Weiter" \ --stdout \ --menu "Konfiguration" 14 70 5 \ "1" "Normale Installation" \ "2" "Silent Installation"` RES=$? if [ "$RES" == "1" ];then return 1 fi if [ "$RES" == "0" ];then case "$METHOD" in "1") run_install_normal ;; "2") dialog_warning run_install_silent ;; esac fi } dialog_main() { METHOD=0 while [ $METHOD -le 2 ] do METHOD=`dialog \ --backtitle "$TITLE" \ --no-cancel \ --ok-label "Weiter" \ --stdout \ --menu "Konfiguration" 14 70 5 \ "1" "AutoSta_LX installieren" \ "2" "Uebersicht gefundener Laufwerke" \ "3" "Beenden und neustarten" \ "4" "Beenden und eine Shell starten" ` RES=$? if [ "$RES" == "1" ];then exit 1 fi if [ "$RES" == "0" ];then case "$METHOD" in "1") #only for now later it will be used again #with 6.1-r2 only one install method available #dialog_install_method run_install_normal ;; "2") dialog_setup_hdd_found_manuell ;; "3") install_do_reboot ;; "4") /bin/bash --login -i ;; esac fi done } ################################################# # Install Komandos # ################################################# setup_hdd_partitions_manuell() { BOOTHDD="${HDD}1" SWAPHDD="${HDD}2" ROOTHDD="${HDD}3" ## hdds partitionieren manuell cfdisk $HDD || die } setup_hdd_partitions_silent() { ## hdds löschen dd if=/dev/zero of=$HDD bs=1024k count=1 || die ## hdds partitionieren silent fdisk $HDD < $CONFIGS_TEMPLATE/fdisksettings #1> /dev/null 3> /dev/null || die read } setup_hdd_format() { mkswap $SWAPHDD || die mke2fs -j -q $BOOTHDD || die mke2fs -j -q $ROOTHDD || die } install_mount_rootfs() { swapon $SWAPHDD || die mount $ROOTHDD $INSTALLPATH || die install -d $INSTALLPATH/boot || die mount $BOOTHDD $INSTALLPATH/boot || die cd $INSTALLPATH || die } install_system_image() { #tar xvzpf $CDPATH/system/autosta_lx.tar.gz tar xvjpf ${CDPATH}/system/${CDIMAGENAME} -C ${INSTALLPATH} } install_kernel_image() { declare -i CPUTYPE=`cat /proc/cpuinfo |grep "cpu family"|cut -d ' ' -f3` if [ $CPUTYPE -le 5 ];then #echo -e "\033[1;6m\033[36m""i386 Architektur gefunden.""\033[0m" #echo -e "Installiere i386 Kernel..." lastdir="`pwd`" mkdir -p $INSTALLPATH/INSTALL/kernel || die cd $INSTALLPATH/INSTALL/kernel || die tar xzpf $CDPATH/kernels/kernel-i386.tar.gz || die source $INSTALLPATH/INSTALL/kernel/kernelversion || die cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNLIB $INSTALLPATH/lib/modules || die cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNIMG $INSTALLPATH/boot || die cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNINITRD $INSTALLPATH/boot || die cp -aRf $INSTALLPATH/INSTALL/kernel/kernelversion $INSTALLPATH/boot || die cd $lastdir || die elif [ $CPUTYPE -ge 6 ];then #echo -e "\033[1;6m\033[36m""i686 Architektur gefunden.""\033[0m" #echo -e "Installiere i686 Kernel..." lastdir="`pwd`" mkdir -p $INSTALLPATH/INSTALL/kernel || die cd $INSTALLPATH/INSTALL/kernel || die tar xzpf $CDPATH/kernels/kernel-i686.tar.gz || die source $INSTALLPATH/INSTALL/kernel/kernelversion || die cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNLIB $INSTALLPATH/lib/modules || die cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNIMG $INSTALLPATH/boot || die cp -aRf $INSTALLPATH/INSTALL/kernel/$KRNINITRD $INSTALLPATH/boot || die cp -aRf $INSTALLPATH/INSTALL/kernel/kernelversion $INSTALLPATH/boot || die cd $lastdir || die fi } install_bootsector() { ### grubconf schreiben source $INSTALLPATH/INSTALL/kernel/kernelversion if [ -z $KRNVER ] then KRNVER="AutoSta_LX" fi if [ -z $KRNIMG ] then KRNIMG="bzImage" fi if [ -z $KRNINITRD ] then KRNINITRD="initrd" fi echo -e "default 0" > $INSTALLPATH/boot/grub/grub.conf || die echo -e "timeout 03" >> $INSTALLPATH/boot/grub/grub.conf ||die #no support for splash image in 6.1-r2 #echo -e "splashimage=(hd0,0)/boot/grub/splash.xpm.gz" >> $INSTALLPATH/boot/grub/grub.conf || die echo -e "\ntitle=${KRNVER}" >> $INSTALLPATH/boot/grub/grub.conf || die echo -e "root (hd0,0)" >> $INSTALLPATH/boot/grub/grub.conf || die #s3 cards don't support this #echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD vga=0x317 video:vesa:ywrap,mtrr splash=silent quiet" >> $INSTALLPATH/boot/grub/grub.conf || die #that's more safer: echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD quiet" >> $INSTALLPATH/boot/grub/grub.conf || die #not needed without bootsplash support #echo -e "initrd=/boot/${KRNINITRD}" >> $INSTALLPATH/boot/grub/grub.conf || die ### bootsector schreiben #grub --no-floppy < $CONFIGS_TEMPLATE/grubsettings || die /sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null || die root (hd0,0) setup (hd0) quit EOF } install_bootsector_chroot() { ### grubconf schreiben #source $INSTALLPATH/INSTALL/kernel/kernelversion source $INSTALLPATH/boot/kernelversion #for alx only if [ -e ${INSTALLPATH}/etc/alx_version ] then OLD_ALXVER="${ALXVER}" source ${INSTALLPATH}/etc/alx_version KRNVER="ALX-${ALXVER}" ALXVER="${OLD_ALXVER}" fi if [ -z "$KRNVER" ] then KRNVER="AutoSta_LX" fi if [ -z "$KRNIMG" ] then KRNIMG="bzImage" fi if [ -z "$KRNINITRD" ] then KRNINITRD="initrd" fi echo -e "default 0" > $INSTALLPATH/boot/grub/grub.conf || die echo -e "timeout 03" >> $INSTALLPATH/boot/grub/grub.conf ||die #no support for splash image in 6.1-r2 #echo -e "splashimage=(hd0,0)/boot/grub/splash.xpm.gz" >> $INSTALLPATH/boot/grub/grub.conf || die echo -e "\ntitle=${KRNVER}" >> $INSTALLPATH/boot/grub/grub.conf || die echo -e "root (hd0,0)" >> $INSTALLPATH/boot/grub/grub.conf || die #s3 cards don't support this #echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD vga=0x317 video:vesa:ywrap,mtrr splash=silent quiet" >> $INSTALLPATH/boot/grub/grub.conf || die #that's more safer: echo -e "kernel (hd0,0)/boot/${KRNIMG} root=$ROOTHDD quiet" >> $INSTALLPATH/boot/grub/grub.conf || die #not needed without bootsplash support #echo -e "initrd=/boot/${KRNINITRD}" >> $INSTALLPATH/boot/grub/grub.conf || die ### bootsector schreiben chrooted schreiben (gentoo) if [ -f $INSTALLPATH/sbin/grub ] then cat > $INSTALLPATH/root/.bashrc << CHROOTEOF /sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null root (hd0,0) setup (hd0) quit EOF exit 0 CHROOTEOF fi ### bootsector schreiben chrooted schreiben (lfs/magellan) if [ -f $INSTALLPATH/usr/sbin/grub ] then cat > $INSTALLPATH/root/.bashrc << CHROOTEOF /usr/sbin/grub --no-floppy --batch << "EOF" 1> /dev/null 2> /dev/null root (hd0,0) setup (hd0) quit EOF exit 0 CHROOTEOF fi ##enters chroot mount -t proc proc $INSTALLPATH/proc chroot $INSTALLPATH /bin/bash --rcfile /root/.bashrc -i umount $INSTALLPATH/proc rm $INSTALLPATH/root/.bashrc } install_alxconfig(){ lastdir="`pwd`" mkdir -p $INSTALLPATH/opt/alx-config || die cd $INSTALLPATH/opt/alx-config || die tar xzpf $CDPATH/alx-config/alx-config.tar.gz || die chmod a+x $INSTALLPATH/opt/alx-config/Configurator/config_functions.sh || die chmod a+x $INSTALLPATH/opt/alx-config/Configurator/config_menu.sh || die ln -sf /opt/alx-config/Configurator/config_menu.sh $INSTALLPATH/bin/ALXConfig || die cd $lastdir || die } install_system_settings(){ ### schreibe fstab echo -e "$BOOTHDD\t/\text3\tnoatime,noauto\t1 1" > $INSTALLPATH/etc/fstab || die echo -e "$ROOTHDD\t/\text3\tnoatime\t0 0" >> $INSTALLPATH/etc/fstab || die echo -e "$SWAPHDD\tswap\tswap\tpri=1\t0 0" >> $INSTALLPATH/etc/fstab || die echo -e "none\t/proc\tproc\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die #deprecated #echo -e "devpts\t/dev/pts\tdevpts\tgid=4,mode=620\t0 0" >> $INSTALLPATH/etc/fstab || die echo -e "none\t/dev/shm\ttmpfs\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die echo -e "none\t/proc/bus/usb\tusbfs\tdefaults\t0 0" >> $INSTALLPATH/etc/fstab || die } install_hotfixes(){ if [ -f $CDPATH/hotfixes/hotfixes.sh ] then dialog_hotfixes sleep1 $CDPATH/hotfixes/hotfixes.sh fi } install_umount_rootfs() { cd / umount $INSTALLPATH/boot || die umount $INSTALLPATH || die swapoff $SWAPHDD || die } install_do_reboot() { #only for now later it will be used again #with 6.1-r2 these options are not available #cd / #umount $CDPATH #eject #clear reboot } ################################################# # Install Ablauf Scripte # ################################################# run_install_normal() { #only for now later it will be used again #with 6.1-r2 only one install method available #dialog_setup_hdd_menu dialog_setup_hdd_found_manuell dialog_setup_hdd_partitions_manuell dialog_setup_hdd_format setup_hdd_format > /dev/null install_mount_rootfs (install_system_image > /tmp/install.log) 2> /tmp/install_errors.log | dialog_install_meter | dialog_install_system_image #only for now later it will be used again #with 6.1-r2 variable kernels are not available #dialog_install_kernel_image #install_kernel_image dialog_install_bootsector install_bootsector_chroot #only for now later it will be used again #with 6.1-r2 highest version of alx-config is already included #dialog_install_alxconfig #sleep 1 #install_alxconfig dialog_install_settings sleep 1 install_system_settings install_hotfixes install_umount_rootfs dialog_install_successful } run_install_silent() { echo "starting silent install ..." sleep 1 } run_install_unattended() { echo "starting unattended install ..." sleep 1 } if [ "$1" == "unattended" ] then run_install_unattended else dialog_main fi exit 0