home *** CD-ROM | disk | FTP | other *** search
/ PC Online 1997 August / PCO0897.ISO / delix / initrd / initrd-fixes.30.06.97 / usr / adm / setup / doinst1 < prev    next >
Encoding:
Text File  |  1997-06-27  |  33.7 KB  |  1,676 lines

  1. #!/bin/sh
  2. #
  3. ####################################################
  4. #                                                                    #
  5. # File:        doinst1                                            #
  6. # Authors:    Niels Mache, Ngo Than                        #
  7. # Last change:  16/06/97                                    #
  8. #                                                                    #
  9. # DLD - German Linux Distribution -                        #
  10. #                                                                    #
  11. # Copyright (c) 1993-1997  delix Computer GmbH        #
  12. #                          Schlo▀stra▀e 98            #
  13. #                          D-70176 Stuttgart            #
  14. # All rights reserved.                                        #
  15. #                                                                    #
  16. ####################################################
  17. #
  18.  
  19. umask 022
  20.  
  21. declare -i MountStat
  22. declare -i Stat
  23. clear="H"
  24. export DLDVersion="5.2"
  25. InstallRoot="/mnt"
  26. InstallPath="$InstallRoot/delix"
  27. RootPath="/dest"
  28. KernelImage="vmlinuz"
  29. SetupDir="/usr/lib/delix/setup"
  30. InstallLogDir="/usr/lib/delix/install"
  31. BOOTIMG=bootimg
  32. ErrorLogFile="$InstallLogDir/errors.log"
  33. BaseArchive=dldbase.tgz
  34. CDrom=
  35. CDFileSystem="iso9660"
  36. LIBM="libm.so.5"
  37. FIXES=/usr/adm/setup/fixes.tgz
  38.  
  39. [ "$TERM" = "xterm" ] && export TERM=color_xterm
  40.  
  41. PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/adm/setup:$RootPath$SetupDir
  42. PATH=$PATH:$RootPath/linux/bin:$RootPath/linux/usr/bin:$RootPath/linux/sbin:$RootPath/linux/$SetupDir:$RootPath/linux/usr/sbin
  43. export PATH
  44.  
  45. InstallUpdateDefault=
  46.  
  47. INSTSRC=
  48. INSTMEDIA=
  49. SYSCFG=
  50.  
  51.  
  52. DIALOGTITLE=" DLD $DLDVersion (C) 1993-1997 by delix GmbH, Schlo▀str. 98, 70176 Stuttgart, Germany"
  53. export DIALOGTITLE
  54. DIALOG=mydialog
  55.  
  56.  
  57. # programs
  58. CP="cp -f"
  59. TR=tr
  60. MV="mv -f"
  61. RM="rm -f"
  62. TAR=tar
  63. GZIP=gzip
  64. CUT=cut
  65. GREP=grep
  66. CAT=cat
  67. FDISK=fdisk
  68. MKDIR=mkdir
  69. CHMOD=chmod
  70. MOUNT=mount
  71. UMOUNT=umount
  72. SYNC=sync
  73. UMSSYNC=umssync
  74. SED=sed
  75. MKSWAP=mkswap
  76. SYSINSTALL=pkginst
  77.  
  78.  
  79. startup() {
  80.  
  81.     $RM /tmp/tmp.doi
  82.  
  83.     umsdos=
  84.     IPath=$RootPath
  85.     fstab=
  86.     swapDevives=
  87.     swapFiles=
  88.     primaryDOS=
  89.  
  90.     if [ ! -d $RootPath ]; then
  91.         $MKDIR -p $RootPath
  92.     fi
  93.  
  94.     if [ ! -f /lib/$LIBM ]; then
  95.         (cd /lib; ln -sf $IPath/lib/$LIBM)
  96.     fi
  97. }
  98.  
  99. cursorOff() {
  100.     echo -ne "\033[?25l"
  101. }
  102.  
  103. cursorOn() {
  104.     echo -ne "\033[?25h"
  105. }
  106.  
  107.  
  108. myreboot() {
  109.     reboot >/dev/null 2>&1
  110. }
  111.  
  112. mydialog() { 
  113.     dialog --backtitle "$DIALOGTITLE" "$@"
  114.  
  115. debug() {
  116.     if [ -n "$DEBUG" ]; then
  117.         echo -n "debug: "
  118.         echo $@
  119.     fi
  120. }
  121.  
  122. cleanup()  {
  123.     $RM /tmp/tmp.doi /tmp/ret.doi /tmp/err.doi
  124. }
  125.  
  126. Wait()  {
  127.     echo
  128.     echo -n "Weiter mit [return]: "
  129.     read ans
  130. }
  131.  
  132. userWait()  {
  133.     mydialog --msgbox "Weiter mit [return]" 5 40
  134. }
  135.  
  136. error() {
  137.     mydialog --title "Fehler:" --msgbox "$@" 12 73
  138. }
  139.  
  140. warning() {
  141.     mydialog --title "Achtung:" --msgbox "$@" 12 73
  142. }
  143.  
  144. errorCheck() {
  145.     if [ -s /tmp/err.doi ]; then
  146.         error "`cat /tmp/err.doi`"
  147.         if [ -f $ErrorLogFile ]; then
  148.             cat /tmp/err.doi >> $ErrorLogFile
  149.         fi
  150.     fi
  151.     $RM /tmp/err.doi
  152. }
  153.  
  154. umountAll() {
  155.     for i in $swapFiles; do
  156.         swapoff $i 2>/dev/null
  157.     done
  158.     swapFiles=
  159.     for i in $swapDevices; do
  160.         swapoff $i 2>/dev/null
  161.     done
  162.     swapoff -a 2>/dev/null
  163.     swapDevices=
  164.  
  165.     for i in $fstab; do
  166.         $UMOUNT $i 2>/dev/null
  167.     done
  168.     fstab=
  169.     SourceMounted=
  170. }
  171.  
  172. bye() {
  173.     cd /
  174.     cleanup
  175.     $RM /tmp/fdisk.out /tmp/fstab.tmp
  176.     umountAll
  177.     mydialog --infobox "\n  Installation beendet.\n" 5 28
  178.     sleep 2
  179.     exit 1
  180. }
  181.  
  182. listbox()  {
  183.     if [ $# = "0" ]; then
  184.         mydialog  --textbox /tmp/tmp.doi 20 73
  185.         $RM /tmp/tmp.doi
  186.     elif [ $# = "1" ]; then
  187.         mydialog  --textbox $1 20 73
  188.     elif [ $# = "2" ]; then
  189.         mydialog  --title "$2" --textbox $1 20 73
  190.     fi
  191. }
  192.  
  193. installArchive() {
  194.     local wert=0
  195.     local prozent=0
  196.     local size=0
  197.     local par
  198.     local status=0
  199.     local sizeF=0
  200.     par=$1
  201.  
  202.     cursorOff
  203.  
  204.     for i in `df -t ext2 | grep "$IPath" | cut -c29-36` ; do
  205.         sizeF=`echo "$sizeF $i + p" | dc`
  206.     done
  207.  
  208.     sizeG=55400
  209.  
  210.     cat <<EOF >/tmp/foo
  211. #!/bin/sh
  212. >/tmp/.err
  213. cd $IPath
  214. >fastboot
  215. tar zpxf $par 2>/dev/err.doi
  216.  
  217. if [ "\$?" != "0" ] ; then
  218.    echo "1" >/tmp/.err
  219.    exit 1
  220. fi
  221. echo "0" >/tmp/.err
  222. EOF
  223.  
  224.     chmod a+x /tmp/foo
  225.     /tmp/foo &
  226.  
  227.     (while [ 1 ] ; do
  228.         echo "XXX"
  229.         echo "$prozent"
  230.         echo "\n Paketname        : dldbasis\n"
  231.         echo " Gesamte Gr÷▀e    : `echo "$sizeG 1024 / p" | dc` MB\n"
  232.         echo " Verbliebene Gr÷▀e: `echo "$sizeG $size - 1024 / p" | dc 2>/dev/null` MB\n"
  233.         echo " Beschreibung     : das Paket dldbasis ist n÷tig fⁿr die weitere\n"
  234.         echo "                    Installation von DLD 5.2\n"
  235.         echo "XXX"
  236.  
  237.         wert=0
  238.         for i in `df -t ext2 | grep "$IPath" | cut -c29-36` ; do
  239.             wert=`echo "$wert $i + p" | dc`
  240.         done
  241.  
  242.         size="`echo "$wert $sizeF - p" | dc 2>/dev/null`"
  243.         prozent="`echo "$size 100 * $sizeG / p"| dc 2>/dev/null`"
  244.         [ "$prozent" -ge "100" ] && prozent=100
  245.  
  246.         case "`cat /tmp/.err`" in
  247.             1|0)  break ;;
  248.             *)      continue ;;
  249.         esac
  250.  
  251.     done) | mydialog --title "DLD Installation" --gauge "" 12 70 0
  252.  
  253.     if [ "`cat /tmp/.err`" = "1" ] ; then
  254.         echo -ne "\a"
  255.         errorCheck
  256.         status=1
  257.     else
  258.         status=0
  259.     fi
  260.  
  261.     rm -f /tmp/.err /tmp/foo
  262.     cursorOn
  263.     return $status
  264.  
  265. }
  266.  
  267.  
  268. domount() {
  269.     if [ ! -b "$1" ]; then
  270.         echo -ne "\a"
  271.         error "$1 ist keine Festplattenpartition."
  272.         return 2
  273.     fi
  274.  
  275.     MountType="ext2"
  276.     $MOUNT -t $MountType $1 $2 2>/dev/null
  277.     MNTSTAT=$?
  278.  
  279.     if [ $MNTSTAT != "0" ] ; then
  280.         echo -ne "\a"
  281.         mydialog --title "Fehler" --msgbox \
  282. "Die Partition \"$1\" kann nicht gemountet werden.\n\
  283. M÷gliche Fehlerursachen:\n\n\
  284.   - Diese Partition existiert nicht (Eingabefehler)\n\
  285.     --> Partitionen anzeigen lassen und neu versuchen\n\n\
  286.   - Falscher Partitionstyp (mu▀ vom Typ \"Linux ext\" sein, d.h Id = 83)\n\
  287.     --> wenn falscher Typ (unwahrscheinlich), dann\n\
  288.         mit fdisk verΣndern und neu booten\n\n\
  289.   - Ungⁿltiges Filesystem (nicht formatiert)\n\
  290.     --> Linux Filesystem einrichten und erneut mounten\n\n\
  291.   - Partition bereits gemountet\n\
  292.     --> Fehler ignorieren" 20 74
  293.         return 1
  294.     fi
  295.  
  296.     if [ "$2" = "$IPath" ]; then
  297.         echo "$1    /    $MountType    defaults    0    1" >/tmp/fstab.tmp
  298.         echo "/proc        /proc    proc    defaults    0    0" >>/tmp/fstab.tmp
  299.         echo "/dev/cdrom    /cdrom    iso9660    ro,noauto,user,exec    0    0" >>/tmp/fstab.tmp
  300.     else
  301.         echo "$1    $MountDir    $MountType    defaults    0    2" >>/tmp/fstab.tmp
  302.     fi
  303.  
  304.     fstab="$1 $fstab"
  305.     return 0
  306. }
  307.  
  308. showPartitions() {
  309.     cat << EOF > /tmp/tmp.doi
  310.  
  311. Folgende Partitionen wurden erkannt:
  312.  
  313. --------------------------------------------------------------------------------
  314. EOF
  315.     cat /tmp/fdisk.out >> /tmp/tmp.doi
  316.     echo "--------------------------------------------------------------------------------" >> /tmp/tmp.doi
  317.     listbox /tmp/tmp.doi "Partitionen"
  318.     cleanup
  319.  
  320. runfdisk() {
  321.     local disk
  322.  
  323.     cat /tmp/fdisk.out | $GREP Disk >/tmp/tmpmsg
  324.     choosePart1 "Partition partitionieren" "Welche Festplatte m÷chten Sie partitionieren ?"
  325.     if [ -z "$LINUX_PART" ]; then
  326.         return 1
  327.     fi
  328.         disk=$LINUX_PART
  329.  
  330.     if [ ! -b "$disk" ]; then
  331.         echo -ne "\a"
  332.         error "$disk ist keine Festplattenpartition."
  333.         return 2
  334.     fi
  335.  
  336.     echo $clear
  337.     $FDISK $disk
  338.  
  339.     mydialog --yesno "Wenn Sie VerΣnderungen vorgenommen haben und fdisk mit \
  340. \"w\" verlassen haben, mⁿssen Sie Ihren PC jetzt neu booten. \
  341. System jetzt rebooten?" 8 60
  342.     if [ $? = "0" ]; then
  343.         $SYNC
  344.         myreboot
  345.     fi
  346. }
  347.  
  348. domkfs() {
  349.     if [ "$1" = "" ]; then
  350.         return 1
  351.     fi
  352.  
  353.     if [ ! -b $1 ]; then
  354.         echo -ne "\a"
  355.         mydialog --title "Fehler" --msgbox \
  356. "\n $1 ist keine gⁿltige Partition." 7 50
  357.         return 1
  358.     fi
  359.  
  360.     if [ "`echo $1 | $CUT -c9`" = "" ]; then
  361.         echo -ne "\a"
  362.         mydialog --title "Fehler" --msgbox \
  363. "\n Die Partition ist ungⁿltig!" 7 35
  364.         return 1
  365.     fi
  366.  
  367.     mydialog --title "Partition formatieren" --yesno \
  368. "\n Wollen Sie die Partition nach kaputten Sektoren prⁿfen?" 7 64
  369.     if [ $? = "0" ]; then
  370.         OPTION="-c"
  371.     else
  372.         OPTION=""
  373.     fi
  374.  
  375.     mydialog --title "Partition formatieren" --infobox \
  376. "\nFormatiere die Partition $1. Bitte warten..." 5 62
  377.  
  378.     mke2fs $OPTION $1 2>/dev/tty4 >/dev/tty3
  379.     status=$?
  380.     if [ "$status" != "0" ]; then
  381.         echo -ne "\a"
  382.         mydialog --title "Fehler" --msgbox \
  383. "\n Die Partition konnte nicht formatiert werden!" 7 51
  384.         return 1
  385.     fi
  386.     return 0
  387. }
  388.  
  389. testPart() {
  390.     if [ "$1" = "" ]; then
  391.         status=
  392.     else
  393.         status=`cat /tmp/fdisk.out | $GREP $1`
  394.     fi
  395. }
  396.  
  397. choosePart()  {
  398. local Anz
  399. local Flag
  400. local Dev
  401. local Groesse
  402.  
  403.  
  404.     cat /tmp/tmpmsg | $TR -d "*" > /tmp/tmpmsg.new
  405.     $MV /tmp/tmpmsg.new /tmp/tmpmsg
  406.     for i in `wc /tmp/tmpmsg`; do
  407.         let Anz=$i+1
  408.         break
  409.     done
  410.  
  411.     let Anz1=$Anz+7
  412.     cat << EOF > /tmp/exec
  413. #!/bin/sh
  414. dialog --backtitle "$DIALOGTITLE" --title "$1" --menu "$2" $Anz1 60 $Anz \\
  415. EOF
  416.  
  417.     Flag="0"
  418.     for i in `cat /tmp/tmpmsg`; do
  419.         if [ "`echo $i | $GREP /dev/`" ]; then
  420.             Dev=$i
  421.             Flag="1"
  422.          fi
  423.  
  424.         if [ "$Flag" -gt "0" -a "$Flag" -lt "6" ]; then
  425.             let Flag=$Flag+1
  426.         fi
  427.  
  428.         if [ "$Flag" = "6" ]; then
  429.             Groesse=${i%+}
  430.             Flag="0"
  431.  
  432.             cat << EOF >> /tmp/exec 
  433. "$Dev" "$Groesse KByte" \\
  434. EOF
  435.         fi
  436.     done
  437.  
  438.     cat << EOF >> /tmp/exec
  439. "p" "Partitionsbezeichner eingeben" \\
  440. EOF
  441.  
  442.     cat << EOF >> /tmp/exec
  443. 2> /tmp/ret
  444. EOF
  445.  
  446.     $CHMOD 755 /tmp/exec
  447.     /tmp/exec
  448.     if [ $? != 0 ]; then
  449.         $RM /tmp/exec
  450.         $RM /tmp/tmpmsg
  451.         $RM /tmp/ret
  452.         LINUX_PART=
  453.     fi
  454.  
  455.     $RM /tmp/exec
  456.     $RM /tmp/tmpmsg
  457.     if [ -s /tmp/ret ]; then
  458.         LINUX_PART="`cat /tmp/ret`"
  459.         $RM /tmp/ret
  460.     else
  461.         LINUX_PART=
  462.     fi
  463.  
  464.     if [ "$LINUX_PART" = "p" ]; then
  465.         mydialog --title "Partitionsbezeichner" --inputbox \
  466. "Geben Sie den Partitionsbezeichner ein:" 9 50 2> /tmp/ret.doi
  467.         if [ $? != 0 ]; then
  468.             LINUX_PART=
  469.         else
  470.             LINUX_PART=`cat /tmp/ret.doi`
  471.         fi
  472.         rm -f /tmp/ret.doi
  473.     fi
  474. }
  475.  
  476. choosePart1()  {
  477. local Anz
  478. local Flag
  479. local Dev
  480. local msg
  481.  
  482.  
  483.     cat /tmp/tmpmsg | $TR -d ":" > /tmp/tmpmsg.new
  484.     $MV /tmp/tmpmsg.new /tmp/tmpmsg
  485.     for i in `wc /tmp/tmpmsg`; do
  486.         Anz=$i
  487.         break
  488.     done
  489.  
  490.     let Anz1=$Anz+7
  491.     cat << EOF > /tmp/exec
  492. #!/bin/sh
  493. dialog --backtitle "$DIALOGTITLE" --title "$1" --menu "$2" $Anz1 72 $Anz \\
  494. EOF
  495.  
  496.     Flag="0"
  497.     msg=
  498.     for i in `cat /tmp/tmpmsg`; do
  499.         if [ "`echo $i | $GREP /dev/`" ]; then
  500.             Dev=$i
  501.             Flag="1"
  502.          fi
  503.         if [ "$Flag" -gt "0" ]; then
  504.             msg="$msg $i"
  505.             let Flag=$Flag+1
  506.         fi
  507.  
  508.         if [ "$Flag" = "7" ]; then
  509.             Flag="0"
  510.             cat << EOF >> /tmp/exec 
  511. "$Dev" "$msg" \\
  512. EOF
  513.             msg=
  514.         fi
  515.     done
  516.  
  517.     cat << EOF >> /tmp/exec
  518. 2> /tmp/ret
  519. EOF
  520.  
  521.     $CHMOD 755 /tmp/exec
  522.     /tmp/exec
  523.     if [ $? != 0 ]; then
  524.         $RM /tmp/exec
  525.         $RM /tmp/tmpmsg
  526.         $RM /tmp/ret
  527.         LINUX_PART=
  528.     fi
  529.  
  530.     $RM /tmp/exec
  531.     $RM /tmp/tmpmsg
  532.     if [ -s /tmp/ret ]; then
  533.         LINUX_PART="`cat /tmp/ret`"
  534.         $RM /tmp/ret
  535.     else
  536.         LINUX_PART=
  537.     fi
  538. }
  539.  
  540.  
  541. formatPartition() {
  542.     cat /tmp/fdisk.out | $GREP "Linux native" > /tmp/tmpmsg
  543.     choosePart "Partition formatieren" "Welche Partition wollen Sie formatieren?"
  544.     if [ -z "$LINUX_PART" ]; then
  545.         return 0
  546.     fi
  547.  
  548.     NEWPART=$LINUX_PART
  549.  
  550.     testPart $NEWPART
  551.     if [ "$status" = "" ]; then
  552.         echo -ne "\a"
  553.         mydialog --title "Fehler" --msgbox "\nUngⁿltige Partitionsangabe!" 7 32
  554.         return 1
  555.     fi
  556.  
  557.     mount | grep "$NEWPART" 2>/dev/null >/dev/null
  558.     if [ "$?" = "0" ] ; then
  559.         echo -ne "\a"
  560.         mydialog --title "Fehler" --msgbox \
  561. "\nDie \"$NEWPART\" wurde bereits gemountet und\n\
  562. konnte nicht formatiert werden.\n" 8 48
  563.          return 1
  564.     fi
  565.  
  566.     $UMOUNT $NEWPART 2> /dev/null
  567.     $MOUNT -o errors=continue -t ext2 $NEWPART $IPath >/dev/null 2>&1
  568.     if [ "$?" = "0" ] ; then
  569.         freezeLinux
  570.         $UMOUNT $NEWPART 2>/dev/null
  571.     fi
  572.  
  573.     mydialog --title "Partition formatieren" --yesno \
  574. "\nDurch das Formatieren der Partition $NEWPART werden alle\n\
  575. darauf gespeicherten Daten gel÷scht.\n\n\
  576.              Wollen Sie wirklich fortfahren?\n"  10 63
  577.  
  578.     if [ "$?" = "0" ]; then
  579.         domkfs $NEWPART || return 1
  580.         mountit $NEWPART
  581.     else
  582.         return 0
  583.     fi
  584. }
  585.  
  586. mountPartition() {
  587.     local mountPart
  588.  
  589.     cat /tmp/fdisk.out | $GREP "Linux native" > /tmp/tmpmsg
  590.     choosePart "Partition mounten" "Welche Partition wollen Sie mounten?"
  591.  
  592.     if [ -z "$LINUX_PART" ]; then
  593.         return 0
  594.     fi
  595.  
  596.     mountPart=$LINUX_PART
  597.  
  598.     testPart $mountPart
  599.     if [ "$status" = "" ]; then
  600.         echo -ne "\a"
  601.         mydialog --title "Fehler" --msgbox "\nUngⁿltige Partitionsangabe!" 7 32
  602.         return 1
  603.     fi
  604.     mountit $mountPart
  605.     return $?
  606. }
  607.  
  608.  
  609. mountit() {
  610. while [ 1 ] ; do
  611.     if [ "$RootPartition"  = "" ]; then
  612.         mydialog --title "Partition mounten" --yesno \
  613. "\nSoll die Partition $1 als Root-Verzeichnis\n\
  614. gemountet werden?\n" 8 56
  615.  
  616.         if [ "$?" != "0" ]; then
  617.             echo -ne "\a"
  618.             mydialog --title "Fehler" --msgbox \
  619. "\nBitte mounten Sie zuerst die Root-Partition!" 7 50
  620.             return 1
  621.         fi
  622.         RootPartition=$1
  623.  
  624.         domount $RootPartition $IPath
  625.         MNTSTAT=$?
  626.         if [ $MNTSTAT != "0" ]; then
  627.             RootPartition=
  628.             return 1
  629.         fi
  630.         mydialog  --title "Partition mounten" --infobox \
  631. "\n$RootPartition wurde als Root Partition gemountet.\n" 5 51
  632.         sleep 2
  633.     else
  634.         mydialog --title "Partition mounten" \
  635. --menu "\nAn welchen Pfad soll diese Partition gemountet werden?\n" 16 60 6 \
  636. "/usr/local"  "" \
  637. "/home"  "" \
  638. "/usr"   "" \
  639. "/var"   "" \
  640. "/var/tmp" "" \
  641. "/tmp"   "" \
  642. "b" "Benutzerdefiniert" 2> /tmp/ret.doi
  643.  
  644.         if [ "$?" != "0" ]; then
  645.             return 1
  646.         fi
  647.  
  648.         MountDir=`cat /tmp/ret.doi`
  649.         if [ "$MountDir" = "b" ]; then
  650.             mydialog --title "Partition mounten" --inputbox \
  651. "\nAn welchen Pfad soll diese Partition gemountet werden :\n" 10 60 2> /tmp/ret.doi
  652.             MountDir=`cat /tmp/ret.doi`
  653.             if [ "$?" != "0" ] ; then 
  654.                 continue
  655.             fi
  656.         fi
  657.  
  658.         MountPoint=$IPath$MountDir
  659.         if [ "$MountDir" != "" ]; then
  660.             $MKDIR -p $MountPoint || return 1
  661.         else
  662.             return 1
  663.         fi
  664.  
  665.         [ "`basename $MountPoint`" = "tmp" ] && chmod 1777 $MountPoint
  666.  
  667.         domount $1 $MountPoint
  668.  
  669.                 MNTSTAT=$?
  670.                 if [ $MNTSTAT != "0" ]; then
  671.                         return 1
  672.                 fi
  673.  
  674.         mydialog  --title "Partition mounten" --msgbox \
  675. "\nEs wurde Partition $1 nach $MountDir gemountet.\n" 7 70
  676.  
  677.     fi
  678.     return 0
  679. done
  680. }
  681.  
  682.  
  683.  
  684. swappartsetup() {
  685. local swapsize
  686. local swappart
  687. local part
  688.  
  689.     cat /tmp/fdisk.out | $GREP "Linux swap" > /tmp/tmpmsg
  690.     if [ "$?" != "0" ] ; then
  691.         $RM /tmp/tmpmsg
  692.         echo -ne "\a"
  693.         mydialog --title "Fehler" --msgbox \
  694. "\nEs wurden keine Swap-Partitionen gefunden." 7 48
  695.         return 1
  696.     else
  697.         choosePart "Swap-Partitionen formatieren" "Welche Swap-Partition soll formatiert werden?"
  698.         if [ -z "$LINUX_PART" ]; then
  699.             return 1
  700.         fi
  701.  
  702.         swappart=$LINUX_PART
  703.         part=`cat /tmp/fdisk.out | $GREP swap | $GREP $swappart | $CUT -c1-10`
  704.         mydialog --title "Swap-Partitionen formatieren" --infobox \
  705. "\nDie Swap-Partition $swappart wird formatiert. Bitte warten...\n" 5 68
  706.         sleep 1
  707.         $MKSWAP $swappart 2>/dev/null >/dev/null
  708.         if [ "$?" != "0" ] ; then
  709.             echo -ne "\a"
  710.             mydialog --title "Fehler" --msgbox \
  711. "\nSwap-Partition konnte nicht erzeugt werden.\n\
  712. Bitte prⁿfen Sie Ihre Hardware und wiederholen\n\
  713. den Vorgang spΣter nochmals!" 9 50
  714.             return 1
  715.         fi
  716.         mydialog --title "Swap-Partitionen formatieren" --msgbox \
  717. "\nDie Swap-Partition $swappart wurde erfolgreich formatiert." 7 63
  718.     fi
  719. }
  720.  
  721.  
  722.  
  723. swapfilesetup() {
  724. local ipath
  725.  
  726.     if [ "$RootPartition" = "" ]; then
  727.         echo -ne "\a"
  728.         mydialog --title "Fehler" --msgbox \
  729. "\nBitte legen Sie zuerst das Root-Filesystem an." 7 51
  730.         return 1
  731.     fi
  732.  
  733.     mydialog --title "Swap-Datei erzeugen" --inputbox \
  734. "\nGr÷▀e des Swap-Bereiches in KByte (z.B. 10000):\n" 10 60 "10000" 2>/tmp/ret.doi
  735.  
  736.     if [ "$?" != "0" ]; then
  737.         return 1
  738.     fi
  739.  
  740.     mydialog --title "Swap-Datei erzeugen" --infobox \
  741. "\nSwap-Datei wird jetzt eingerichtet. Bitte warten..." 5 58
  742.  
  743.     sleep 1
  744.     swapsize=`cat /tmp/ret.doi`
  745.     ipath=$IPath
  746.  
  747.     if [ ! -d $ipath/dev ]; then
  748.         $MKDIR $ipath/dev
  749.     fi
  750.  
  751.     dd if=/dev/zero of=$ipath/dev/swapfile bs=1024 count=$swapsize >/dev/null 2>/dev/null
  752.     if [ "$?" != "0" ] ; then
  753.         echo -ne "\a"
  754.         mydialog --title "Fehler" --msgbox \
  755. "\nSwap-Datei konnte nicht erzeugt werden. Die Partition\n\
  756. hat nicht ausreichenden Platz." 8 58
  757.         return 1
  758.     fi
  759.  
  760.     $MKSWAP $ipath/dev/swapfile $swapsize >/dev/null 2>/dev/null
  761.     if [ "$?" != "0" ] ; then
  762.         echo -ne "\a"
  763.                 mydialog --title "Fehler" --msgbox \
  764. "\nSwap-Datei konnte nicht erzeugt werden. Die Partition\n\
  765. hat nicht ausreichenden Platz." 8 58
  766.         return 1
  767.     fi
  768.     sync
  769.     $CHMOD 600 $ipath/dev/swapfile
  770.     mydialog --title "Swap-Datei erzeugen" --msgbox \
  771. "\n Swap-Datei wurde erfolgreich erzeugt." 7 44
  772.     return
  773. }
  774.  
  775. swaponfile() {
  776. local ipath
  777. ipath=$IPath
  778.  
  779.     swapoff $ipath/dev/swapfile 2>/dev/null >/dev/null
  780.     swapon $ipath/dev/swapfile  2>/dev/null >/dev/null
  781.     grep "/dev/swapfile" /tmp/fstab.tmp 2>/dev/null >/dev/null
  782.     if [ "$?" != "0" ] ; then
  783.         echo "/dev/swapfile    none    swap    0    0" >> /tmp/fstab.tmp
  784.         swapFiles="$ipath/dev/swapfile $swapFiles"
  785.     fi
  786. }
  787.  
  788.  
  789. copyInstallFiles() {
  790.     if [ ! -d $IPath$SetupDir ]; then
  791.         $MKDIR -p $IPath$SetupDir
  792.         $CHMOD 755 $IPath$SetupDir
  793.     fi
  794.     if [ ! -d $IPath$InstallLogDir ]; then
  795.         $MKDIR -p $IPath$InstallLogDir
  796.         $CHMOD 755 $IPath$InstallLogDir
  797.     fi
  798.     cat /dev/null > $IPath$ErrorLogFile
  799.  
  800. #       $CP -a $SetupSrcDir/* $IPath$SetupDir 2> /dev/null
  801. #    hash -r
  802. }
  803.  
  804. checkFreeMemory()  {
  805.     declare -i mem
  806.  
  807.     mem="`filesize /proc/kcore`"
  808.     mem=$mem/1048576
  809.  
  810.     if [ $mem -lt 7 ]; then
  811.         cat << EOF > /tmp/tmp.doi
  812. Achtung: Es sind nur $mem MB Speicher vorhanden.
  813. Legen Sie vor der Installation Swapspace an.
  814. EOF
  815.         warning "`cat /tmp/tmp.doi`"
  816.         mydialog --title "Speichermangel" \
  817. --yesno "Trotzdem weitermachen?" 6 40
  818.         if [ "$?" != "0" ]; then
  819.             RootPartition=
  820.             return 1
  821.         fi
  822.     fi
  823.     return 0
  824. }
  825.  
  826. partitionSetup() {
  827. local choice
  828.  
  829.     while [ 1 ]; do
  830.         mydialog --title "Partitionen einrichten" --menu \
  831. "\nWΣhlen Sie bitte aus:\n" 15 70 5 \
  832. "1" "Partitionen anzeigen" \
  833. "2" "Festplatte partitionieren (danach Neustart erforderlich)" \
  834. "3" "Formatieren einer Linux Partition (mke2fs)" \
  835. "4" "Mounten einer Linux Partition (mount)" \
  836. "w" "weiter" \
  837. 2> /tmp/ret.doi
  838.  
  839.         if [ $? != "0" ]; then
  840.             RootPartition=
  841.             return 1
  842.         fi
  843.  
  844.         choice=`cat /tmp/ret.doi`
  845.         $RM /tmp/ret.doi
  846.  
  847.         case $choice in
  848.             w) if [ "$RootPartition" != "" ] ; then
  849.                 break
  850.                else
  851.                 echo -ne "\a"
  852.                             mydialog --title "Fehler" --msgbox \
  853. "\nBitte mounten Sie zuerst die Root-Partition!" 7 50
  854.  
  855.                fi
  856.                ;;
  857.             1) showPartitions;;
  858.             4) mountPartition
  859.                if [ "$?" != "0" ] ; then
  860.                 continue
  861.                else
  862.                    freezeLinux
  863.                fi
  864.                ;;
  865.             2) runfdisk;;
  866.             3) formatPartition;;
  867.         esac
  868.     done
  869.     return 0
  870. }
  871.  
  872. swapSetup() {
  873. local choice
  874.  
  875.     while [ 1 ]; do
  876.         mydialog  --title "Swap einrichten" --menu \
  877. "\nWΣhlen Sie aus:\n" 13 64 3 \
  878. "1" "Swap Partition einrichten (mkswap)" \
  879. "2" "Swap Datei im Root-Filesystem einrichten (mkswap)" \
  880. "w" "weiter" \
  881. 2> /tmp/ret.doi
  882.  
  883.         if [ "$?" != "0" ]; then
  884.             RootPartition=
  885.             return 1
  886.         fi
  887.  
  888.         choice=`cat /tmp/ret.doi`
  889.         $RM /tmp/ret.doi
  890.  
  891.         case $choice in
  892.             w) break ;;
  893.             1) swappartsetup ;;
  894.             2) swapfilesetup
  895.                if [ "$?" = "0" ]; then
  896.                    swaponfile
  897.                fi ;;
  898.         esac
  899.     done
  900.     return 0
  901. }
  902.  
  903.  
  904. mountAll() {
  905.     MountType="ext2"
  906.     $UMOUNT $1 >/dev/null 2>&1
  907.     $UMOUNT $2 >/dev/null 2>&1
  908.     $MOUNT $3 -t $MountType $1 $2 2>/dev/null
  909.     MountStat=$?
  910. }
  911.  
  912.  
  913. mountSource() {
  914. local ipaddr
  915. local network
  916. local netmask
  917. local gateway
  918. local nfsserver
  919. local nfspath
  920.  
  921.  
  922.     INSTSRC=$InstallPath
  923.     type=$2
  924.     CDrom=
  925.     MountStat=1
  926.  
  927.     $UMOUNT $InstallRoot >/dev/null 2>&1
  928.  
  929.     case $1 in 
  930.     harddrive)
  931.         mydialog --title "Harddisk" --infobox \
  932. "\nErtelle die List der vorhandenen Partitionen. Bitte warten...\n" 5 68
  933.         cat /tmp/fdisk.out | $GREP "^/dev/" | $GREP -v "Linux swap" |  $GREP -v "Extended" >/tmp/tmpmsg
  934.         choosePart "Partition auswΣhlen" "Von welcher Partition soll installiert werden?"
  935.         if [ -z "$LINUX_PART" ]; then
  936.             return 1
  937.         fi
  938.         HDdev=$LINUX_PART
  939.         mount | grep "$LINUX_PART" >/dev/null 2>&1
  940.         if [ "$?" = "0" ] ; then
  941.                     echo -ne "\a"
  942.                     mydialog --title "Fehler" --msgbox \
  943. "\nDie \"$LINUX_PART\" wurde bereits gemountet und\n\
  944. konnte nicht gemountet werden.\n" 8 48
  945.                     return 1
  946.         fi
  947.  
  948.         cleanup
  949.  
  950.         HDpath=`basename $INSTSRC`
  951.         while [ 1 ]; do
  952.         dialog --shadow --title "Harddisk" --inputbox \
  953. "\nIn welchem Verzeichnis befindet sich DLD Installationsfiles ?\n\
  954. Geben Sie bitte den Pfad ein:\n" 12 70 $HDpath 2>/tmp/ret.doi
  955.  
  956.         if [ $? != 0 ]; then
  957.             cleanup
  958.             return 1
  959.         fi
  960.  
  961.         HDpath=`cat /tmp/ret.doi`
  962.         if [ "$HDpath" != "" ]; then
  963.             INSTSRC=$InstallRoot/$HDpath
  964.             break
  965.         fi
  966.         done
  967.  
  968.         mountAll $HDdev $InstallRoot -r
  969.         cleanup
  970.     ;;
  971.  
  972.     cdrom)
  973. if [ ! -f /tmp/cdrom ]; then
  974. mydialog --title "CD-ROM Auswahl" \
  975. --menu "Installation der DLD von CD-ROM" 18 74 11 \
  976. "/dev/scd0" "SCSI Laufwerk 1" \
  977. "/dev/scd1" "SCSI Laufwerk 2" \
  978. "/dev/hda" "ATAPI Laufwerk (1. Laufwerk)" \
  979. "/dev/hdb" "ATAPI Laufwerk (2. Laufwerk)" \
  980. "/dev/hdc" "ATAPI Laufwerk (3. Laufwerk)" \
  981. "/dev/hdd" "ATAPI Laufwerk (4. Laufwerk)" \
  982. "/dev/mcd" "Mitsumi Laufwerk" \
  983. "/dev/sonycd" "Sony CDU31A/33A" \
  984. "/dev/cdu535" "Sony 535" \
  985. "/dev/sbpcd" "Matsushita/Panasonic (am Soundblaster)" \
  986. "/dev/aztcd0" "Aztech CDA268-01A, ORCHID CD-3110, OKANO/WEARNES CDD110" \
  987. "i" "Installations-Device eingeben" 2> /tmp/ret.doi
  988.         if [ $? != 0 ]; then
  989.             CDrom=
  990.             return 1
  991.         fi
  992.  
  993.         HDdev=`cat /tmp/ret.doi`
  994.         if [ "$HDdev" = "i" ]; then
  995.             mydialog --title "Laufwerksbezeichner" --inputbox \
  996. "Geben Sie das Installations-Device ein:" 9 40 2> /tmp/ret.doi
  997.             if [ $? != 0 ]; then
  998.                 CDrom=
  999.                 return 1
  1000.             fi
  1001.             HDdev=`cat /tmp/ret.doi`
  1002.         fi
  1003. else
  1004.     HDdev="`cat /tmp/cdrom`"
  1005. fi
  1006.  
  1007.         while [ 1 ]; do
  1008.             $UMOUNT $InstallRoot >/dev/null 2>&1
  1009.             $MOUNT -r -t $CDFileSystem $HDdev $InstallRoot 2>/dev/null
  1010.             MountStat=$?
  1011.  
  1012.             if [ $MountStat = 0 ]; then
  1013.                 mydialog --shadow --title "CD-Mount" --infobox \
  1014. "\n  Die CD-ROM wurde gemountet.\n" 5 35
  1015.                 sleep 2
  1016.                 CDrom="true"
  1017.                 fstab="$HDdev $fstab"
  1018.                 echo "$HDdev" > /tmp/cdrom
  1019.                 break
  1020.             fi
  1021.             $RM /etc/mtab~
  1022.             mydialog --title "Mount Fehler" --yesno \
  1023. "\nmount-Fehler (manchmal 2-3 Versuche n÷tig).\n\
  1024. M÷chten Sie nochmals versuchen ?\n" 8 49
  1025.  
  1026.             if [ $? != "0" ]; then
  1027.                 break
  1028.             fi
  1029.         done
  1030.     ;;
  1031.  
  1032.     network)
  1033.         MountStat=1
  1034.         netsetup
  1035.         [ "$?" != "0" ] && return 1
  1036.  
  1037.         [ -f /tmp/NETINST ] && source /tmp/NETINST
  1038.  
  1039.         nfsserver=$NFSSERVER
  1040.         nfspath=$NFSPATH
  1041.  
  1042.         mydialog --title "Netzwerk Setup" --infobox \
  1043. "\nDas Quellenverzeichnis des NFS-Servers:\n($nfsserver:$nfspath)\n\
  1044. wird gemountet. Bitte warten...\n" 7 73
  1045.  
  1046.         sleep 1
  1047.  
  1048.         while [ 1 ]; do
  1049.             $UMOUNT $InstallRoot > /dev/null 2> /dev/null
  1050.             $MOUNT -r -t nfs -o nodev,noexec $nfsserver:$nfspath/delix $InstallRoot 2>/tmp/err.doi
  1051.             MountStat=$?
  1052.             errorCheck
  1053.  
  1054.             if [ $MountStat = 0 ]; then
  1055.                 INSTSRC=$InstallRoot
  1056.                 fstab="$InstallRoot $fstab"
  1057.                 break
  1058.             fi
  1059.             
  1060.             $RM /etc/mtab~
  1061.             mydialog --title "Netzwerk Setup" \
  1062. --yesno "\nmount-Fehler (manchmal 2-3 Versuche n÷tig).\n\
  1063. M÷chte Sie nochmals versuchen ?" 8 50
  1064.  
  1065.             if [ $? != "0" ]; then
  1066.                 break
  1067.             fi
  1068.         done
  1069.     ;;
  1070.     esac
  1071.  
  1072.  
  1073.     if [ $MountStat != 0 ]; then
  1074.         echo -ne "\a"
  1075.         mydialog --title "Fehler" --msgbox \
  1076. "\nLaufwerk kann nicht gemountet werden." 7 42
  1077.         return 1
  1078.     fi
  1079.  
  1080.     if [ "$type" = "update" ]; then
  1081.         if [ ! -f $INSTSRC/update.tgz ]; then
  1082.             echo -ne "\a"
  1083.             mydialog --title "Fehler" --msgbox \
  1084. "\nDLD-Update unter $INSTSRC nicht gefunden." 7 62
  1085.             MountStat=1
  1086.             return 1
  1087.         fi
  1088.     elif [ ! -f $INSTSRC/$BaseArchive ]; then
  1089.         echo -ne "\a"
  1090.         error "$INSTSRC/$BaseArchive nicht gefunden."
  1091.         MountStat=1
  1092.         return 1
  1093.     fi
  1094.  
  1095.     SourceMounted="yes"
  1096.     return 0
  1097. }
  1098.  
  1099.  
  1100. getSourceDev() {
  1101.     Stat=0
  1102.     type=$1
  1103.  
  1104. while [ 1 ]; do
  1105.     mydialog --title "DLD $DLDVersion Installation" --menu \
  1106. "\nWΣhlen Sie bitte die Installations-Quelle:\n" 13 50 3 \
  1107. "1" "Installation von CDROM" \
  1108. "2" "Installation von Festplatte" \
  1109. "3" "Installation ⁿber Netzwerk (mit NFS)" 2>/tmp/ret.doi
  1110.  
  1111.     if [ $? != 0 ]; then
  1112.         Stat=1
  1113.         return 1
  1114.     fi
  1115.  
  1116.     ans=`cat /tmp/ret.doi`
  1117.  
  1118.     case $ans in
  1119.         1) INSTMEDIA=cdrom;;
  1120.         2) INSTMEDIA=harddrive;;
  1121.         3) INSTMEDIA=network;;
  1122.     esac
  1123.  
  1124.     mountSource $INSTMEDIA $type
  1125.     [ "$?" = "1" ] && continue
  1126.     Stat=MountStat
  1127.  
  1128.     break
  1129. done
  1130.  
  1131. return $Stat
  1132. }
  1133.  
  1134.  
  1135. checkDOSPartitions()  {
  1136. local i id line fstyp
  1137. declare -i counter=0
  1138.  
  1139.     for i in `cat /tmp/fdisk.out | $GREP DOS | $CUT -c 1-10`; do
  1140.         counter=$counter+1
  1141.     done
  1142.  
  1143.     if [ $counter -eq 0 ]; then
  1144.         return
  1145.     fi
  1146.  
  1147.     if [ $counter -eq 1 ]; then
  1148.         mydialog --title "MS-DOS Partition" \
  1149. --infobox "\n Es wurde eine MS-DOS Partition gefunden.\n" 5 47
  1150.  
  1151.         sleep 2
  1152.     fi
  1153.     if [ $counter -gt 1 ]; then
  1154.         mydialog --title "MS-DOS Partition" \
  1155. --infobox "\n Es wurden $counter MS-DOS Partitionen gefunden.\n" 5 52
  1156.         sleep 2
  1157.     fi
  1158.  
  1159.     counter=0
  1160.     for i in `cat /tmp/fdisk.out | $GREP DOS | $CUT -c 1-10`; do
  1161.         mydialog --title "MS-DOS Partition" \
  1162. --yesno "\nEnthΣlt die Partition \"$i\" ein Windows95 VFAT Filesystem?\n" 7 72
  1163.  
  1164.         if [ $? = "0" ]; then
  1165.             fstyp="vfat"
  1166.         else
  1167.             fstyp="msdos"
  1168.         fi
  1169.  
  1170.         mydialog --title "MS-DOS Partition mounten" --yesno \
  1171. "\nSoll die vorhandene MS-DOS Partition \"$i\" beim
  1172. Systemstart automatisch gemountet werden?\n" 8 60
  1173.  
  1174.         status=$?
  1175.  
  1176.         let counter=$counter+1
  1177.  
  1178.         case $counter in
  1179.             1) id="c"
  1180.                primaryDOS=$i;;
  1181.             2) id="d";;
  1182.             3) id="e";;
  1183.             4) id="f";;
  1184.         esac
  1185.  
  1186.         $MKDIR -p "$IPath/dos/${id}"
  1187.  
  1188.         if [ "$status" = "0" ]; then
  1189.             line="$i    /dos/${id}    $fstyp    user,noexec,nosuid,nodev    0    2"
  1190.         else
  1191.             line="$i    /dos/${id}    $fstyp    noauto,user,noexec,nosuid,nodev    0    2"
  1192.         fi
  1193.  
  1194.         echo "$line" >> /tmp/fstab.tmp
  1195.     done
  1196. }
  1197.  
  1198.  
  1199. checkSwapPartitions()  {
  1200. local i
  1201. success=0
  1202. declare -i counter=0
  1203.  
  1204.     for i in `cat /tmp/fdisk.out | $GREP "Linux swap" | $CUT -c 1-10`; do
  1205.         counter=$counter+1
  1206.     done
  1207.  
  1208.     if [ "$counter" = "0" ]; then
  1209.         return
  1210.     fi
  1211.  
  1212.     if [ "$counter" = "1" ]; then
  1213.         mydialog --title "Swap-Partition" \
  1214. --infobox "\nEs wurde eine Linux Swap-Partition gefunden.\n" 5 54
  1215.         sleep 2
  1216.     fi
  1217.  
  1218.     if [ $counter -gt 1 ]; then
  1219.         mydialog --title "Swap-Partition" \
  1220. --infobox "Es wurden $counter Linux Swap-Partitionen gefunden." 5 56
  1221.         sleep 2
  1222.     fi
  1223.  
  1224.     for i in `cat /tmp/fdisk.out | $GREP "Linux swap" | $CUT -c 1-10`; do
  1225.  
  1226.         swapoff $i >/dev/null 2>&1
  1227.         swapon  $i >/dev/null 2>&1
  1228.  
  1229.         if [ "$?" != "0" ]; then
  1230.             mydialog --title "Swap-Partition" --yesno \
  1231. "\nDie Swap-Partition \"$i\" wurde noch nicht formatiert.\n\
  1232. Wollen Sie \"$i\" jetzt formatieren?\n" 8 66
  1233.  
  1234.             if [ "$?" = "0" ] ; then
  1235.                 $MKSWAP $i 2>/dev/tty3 >/dev/tty3
  1236.                 status=$?
  1237.  
  1238.                 if [ "$status" != "0" ] ; then
  1239.                     mydialog --title "Fehler" --msgbox \
  1240. "\n Swap-Partition konnte nicht formatiert werden.\n\
  1241.  Prⁿfen Sie bitte Ihre Hardware und wiederholen\n\
  1242.  den Vorgang spΣter nochmals!" 9 52
  1243.                 else
  1244.                     success=1
  1245.                 fi
  1246.             fi
  1247.         else
  1248.             success=1
  1249.         fi
  1250.  
  1251.         if [ "$success" = "1" ] ; then
  1252.               swapDevices="$i $swapDevices"
  1253.               echo "$i    swap    swap    defaults    0    0" >> /tmp/fstab.tmp
  1254.         fi
  1255.     done
  1256. }
  1257.  
  1258.  
  1259. installBase() {
  1260.     local  options
  1261.     installArchive $INSTSRC/$BaseArchive
  1262. }
  1263.  
  1264.  
  1265. installSystem() {
  1266.     mydialog --title "System installieren" --yesno \
  1267. "\n M÷chten Sie die Installation jetzt beginnen?\n" 7 52
  1268.  
  1269.     [ $? = "1" ] && return 1
  1270.  
  1271.     installBase
  1272.  
  1273.     return 0
  1274. }
  1275.  
  1276. install1() {
  1277.     umsdos=
  1278.     hwsetup
  1279.     [ "$?" != "0" ] && return 1
  1280.  
  1281.     mydialog --title "Festplatte prⁿfen" --infobox \
  1282. "\nPrⁿfe Festplatten. Bitte warten..." 5 40
  1283.  
  1284.     rm -f /tmp/fdisk.out /tmp/fstab.tmp
  1285.     fdisk -l >/tmp/fdisk.out 2>/dev/tty3
  1286.     sleep 1
  1287.     
  1288.     IPath=$RootPath
  1289.     partitionSetup
  1290.     if [ "$?" != "0" -o "$RootPartition" = "" ]; then
  1291.         return 1
  1292.     fi
  1293.  
  1294.     swapSetup
  1295.  
  1296.     if [ "$?" != "0" ] ; then
  1297.         return 1
  1298.     fi
  1299.  
  1300.     checkFreeMemory
  1301.     if [ $? != "0" ] ; then
  1302.         return 1
  1303.     fi
  1304.     return 0
  1305. }
  1306.  
  1307.  
  1308.  
  1309. linuxSetup() {
  1310.     local choice
  1311.     umsdos=
  1312.     SourceMounted=
  1313.  
  1314.     while [ 1 ]; do
  1315.         cleanup
  1316.         umountAll
  1317.         mydialog --title "DLD $DLDVersion Basisinstallation" --menu \
  1318. "\nBewegen Sie den Menⁿ-Cursor mit den Cursor Tasten\n\
  1319. oder mit Tab. MenⁿeintrΣge k÷nnen mit <Return> oder\n\
  1320. <Space> ausgewΣhlt werden.\n" 17 57 5 \
  1321. "1" "DLD Installation" \
  1322. "2" "Hilfetext anzeigen" \
  1323. "3" "Kernel Meldungen anzeigen" \
  1324. "s" "System neu starten" \
  1325. "b" "Installation beenden" \
  1326. 2> /tmp/ret.doi
  1327.  
  1328.     if [ "$?" != "0" ]; then
  1329.         $RM /tmp/ret.doi
  1330.         return 1
  1331.     fi
  1332.  
  1333.     choice=`cat /tmp/ret.doi`
  1334.     $RM /tmp/ret.doi
  1335.  
  1336.         case $choice in
  1337.             s) mydialog --title "Neustart" --yesno \
  1338. "M÷chten Sie das System neu booten?" 6 50
  1339.                if [ $? != "0" ]; then continue; fi
  1340.                mydialog --title "Neustart" --infobox \
  1341. "\nBitte warten Sie bis das System neu gebootet wird." 6 54
  1342.                myreboot
  1343.                ;;
  1344.  
  1345.             3) dmesg > /tmp/tmp.doi
  1346.                listbox /tmp/tmp.doi "Kernel Meldungen"
  1347.                $RM /tmp/tmp.doi
  1348.                ;;
  1349.             2) dldhelp
  1350.                ;;
  1351.             b) return 1
  1352.             ;;
  1353.             1) install1
  1354.                if [ "$?" != "0" ]; then continue; fi
  1355.                break
  1356.                ;;
  1357.         esac
  1358.     done
  1359.     return 0
  1360. }
  1361.  
  1362.  
  1363. formatDisk() {
  1364.     formatdisk
  1365.     [ "$?" != "0" ] && return 1
  1366.     mydialog --title "Diskette formatieren" --infobox \
  1367. "\n  Ext2 Filesystem wird jetzt erzeugt. Bitte warten...\n" 5 58
  1368.  
  1369.     mke2fs /dev/fd0h1440 2>/dev/null >/dev/tty3
  1370.  
  1371.     if [ "$?" != "0" ]; then
  1372.         echo -ne "\a"
  1373.         mydialog --title "Fehler" --msgbox \
  1374. "\nExt2 Filesystem konnte nicht erzeugt werden." 7 50
  1375.         return 1
  1376.     fi
  1377.     mydialog --title "Diskette formatieren" --msgbox \
  1378. "\n  Ext2 Filesystem auf Diskette wurde erfolgreich erzeugt.\n" 7 62
  1379.  
  1380.     return 0
  1381. }
  1382.  
  1383. prepareFloppy() {
  1384. mydialog --title "Systemkonfiguration sichern"  --msgbox \
  1385. "\n                  -- Diskettenwechsel --\n\
  1386. Legen Sie jetzt eine Leerdiskette in Ihr A: Laufwerk ein." 8 61
  1387.  
  1388.     if [ -d /floppy/a ]; then
  1389.         $UMOUNT /floppy/a >/dev/null 2>&1
  1390.     else
  1391.         $MKDIR -p /floppy/a
  1392.     fi
  1393.  
  1394.     mydialog --title "Diskette formatieren" --yesno \
  1395. "\nDurch das Formatieren der Diskette werden alle darauf\n\
  1396. gespeicherten Daten gel÷scht.\n
  1397.            Wollen Sie wirklich fortfahren?"  10 58
  1398.  
  1399.     if [ "$?" = "0" ]; then
  1400.         formatDisk
  1401.         if [ "$?" != "0" ]; then
  1402.             return 1
  1403.         fi
  1404.     else
  1405.         return 1
  1406.     fi
  1407.  
  1408.     $MOUNT -t ext2 /dev/fd0 /floppy/a 2>/tmp/err.doi >/dev/tty3
  1409.     if [ $? != 0 ]; then
  1410.         echo -ne "\a"
  1411.         mydialog --title "Fehler" --msgbox \
  1412. "\nLaufwerk A kann nicht gemountet werden." 7 43
  1413.         return 1
  1414.     fi
  1415. }
  1416.  
  1417.  
  1418. saveConfig() {
  1419.     local savefil
  1420.     local i
  1421.     local count
  1422.  
  1423.     for i in \
  1424. etc/passwd etc/passwd- etc/shadow etc/shadow- etc/group \
  1425. etc/sysconfig etc/conf.modules etc/isdnlog \
  1426. usr/lib/news/inn.conf etc/flexlm etc/dosemu.conf \
  1427. usr/lib/news/nnrp.access usr/lib/news/nntp_access \
  1428. usr/lib/news/nntpsend.ctl usr/lib/news/hosts.nntp \
  1429. usr/lib/news/newsfeeds usr/lib/news/active \
  1430. etc/hosts etc/named.boot etc/named.cache etc/named.local etc/named.rev \
  1431. etc/ppp/chatbin.* etc/ppp/options.* etc/ppp/chat-public.* \
  1432. etc/sendmail.cf etc/resolv.conf \
  1433. etc/lilo.conf etc/lilo.msg \
  1434. etc/XF86Config etc/Xaccel.ini; do
  1435.  
  1436.         if [ -f $IPath/$i ]; then
  1437.             savefil="$savefil $i"
  1438.         fi
  1439.     done
  1440.  
  1441.     if [ $# = 1 ]; then
  1442.         SYSCFG=$1
  1443.     else
  1444.         SYSCFG=/tmp/syscfg.tgz
  1445.     fi
  1446.  
  1447.     while [ 1 ]; do
  1448.     mydialog --title "Systemkonfiguration sichern" --yesno \
  1449. "\nAuf der Partition $LINUX_PART ist bereits ein Linux System\n\
  1450. installiert.  Wollen Sie die Systemkonfiguration dieses\n\
  1451. Systems sichern?" 9 62
  1452.  
  1453.     if [ "$?" = "0" ]; then
  1454.         prepareFloppy
  1455.         if [ $? != "0" ]; then
  1456.             mydialog --title "Systemkonfiguration sichern" --msgbox \
  1457. "\n \"Systemkonfiguration sichern\" wurde abgebrochen!\n" 7 54
  1458.             break
  1459.         fi
  1460.         mydialog --title "Systemkonfiguration sichern" --infobox \
  1461. "\n Die Systemkonfiguration wird jetzt auf Diskette\n\
  1462.  (Ext2-Format) als Datei syscfg.tgz gesichert.\n\
  1463.  Bitte warten...\n" 8 53
  1464.         (cd $IPath; $TAR zcf /floppy/a/syscfg.tgz $savefil 2>/dev/null >/dev/tty3)
  1465.         umount /floppy/a 2>/dev/null >/dev/tty3
  1466.         mydialog --title "Systemkonfiguration gesichert" --msgbox \
  1467. "\n Die Systemkonfiguration wurde erfolgreich auf Diskette\n\
  1468.  (Ext2-Format) als Datei syscfg.tgz gesichert." 8 60
  1469.  
  1470.     fi
  1471.     break
  1472.     done
  1473. }
  1474.  
  1475. restoreConfig() {
  1476.     [ ! -f "$SYSCFG" ] && return
  1477.  
  1478.     local cfgfile
  1479.     local cfgpath
  1480.     local CFGFILE="syscfg"
  1481.  
  1482.     $MKDIR -p $IPath/$SetupDir/config
  1483.  
  1484.     cfgfile=$IPath$SetupDir/config/syscfg-$DLDVersion.tgz
  1485.  
  1486.     if [ -f "$cfgfile" ]; then
  1487.         $CP $SYSCFG $IPath$SetupDir/config/syscfg-old.tgz
  1488.     fi
  1489.  
  1490.     $CP $SYSCFG $cfgfile
  1491.     mydialog --title "Systemkonfiguration" --msgbox \
  1492. "Die Systemkonfiguration der DLD $DLDVersion wurde unter \
  1493. $SetupDir/config/syscfg-$DLDVersion.tgz gesichert." 9 73
  1494.  
  1495.     mydialog --title "Systemkonfiguration ⁿbernehmen" --yesno \
  1496. "\nSoll die Systemkonfiguration des bisher installierten \n\
  1497. Linux Systems auf das neue System ⁿbernommen werden?" 8 59
  1498.     if [ $? = "0" ]; then
  1499.         (cd $IPath; $GZIP -cd $SYSCFG | $TAR xpf -) 2>/tmp/err.doi
  1500.         errorCheck
  1501.     else
  1502.     while [ 1 ]; do
  1503.     mydialog --title "Systemkonfiguration herstellen" --yesno \
  1504. "\nSoll eine Systemkonfiguration von Diskette installiert werden?" 7 70
  1505.     if [ $? = "0" ]; then
  1506.         mydialog --title "Systemkonfiguration herstellen" --msgbox \
  1507. "        -- Diskettenwechsel --\n\
  1508. Legen Sie jetzt die Diskette mit der\n\
  1509. Systemkonfiguration in Ihr A: Laufwerk ein." 7 47
  1510.  
  1511.         mount /dev/fd0 /floppy/a 2> /tmp/err.doi >/dev/null
  1512.         if [ $? != 0 ]; then
  1513.             echo -ne "\a"
  1514.                     mydialog --title "Fehler" --msgbox \
  1515. "\nLaufwerk A kann nicht gemountet werden." 7 43
  1516.             mydialog --title "Systemkonfiguration" --yesno \
  1517. "Abbrechen ?" 5 35
  1518.             [ $? = "0" ] && break
  1519.         fi
  1520.         if [ ! -f /floppy/a/syscfg.tgz ]; then
  1521.             umount /floppy/a >/dev/null 2>&1
  1522.             mydialog --title "Systemkonfiguration herstellen" --msgbox \
  1523. "Es konnte keine Systemkonfiguration auf Diskette A: gefunden werden" 6 45
  1524.             mydialog --title "Systemkonfiguration" --yesno \
  1525. "Abbrechen ?" 5 35
  1526.             [ $? = "0" ] && break
  1527.         else
  1528.             (cd $IPath; $GZIP -cd /floppy/a/syscfg.tgz | $TAR xpf -) 2>/tmp/err.doi
  1529.             umount /floppy/a >/dev/null 2>/dev/tty3
  1530.             errorCheck
  1531.         fi
  1532.         mydialog --title "Systemkonfiguration wiederhergestellt" --infobox \
  1533. "Die Systemkonfiguration wurde wiederhergestellt." 5 61
  1534.         sleep 2
  1535.     fi
  1536.     break
  1537.     done
  1538.     fi
  1539. }
  1540.  
  1541. freezeLinux() {
  1542.     local i
  1543.     for i in etc/passwd etc/group etc/HOSTNAME; do
  1544.         if [ ! -f $IPath/$i ]; then return 0; fi
  1545.     done
  1546.     saveConfig
  1547. }
  1548.  
  1549. banner() {
  1550.    cat << EOF > /tmp/tmp.doi
  1551.  
  1552.       delix Computer GmbH
  1553.          Schlo▀str. 98
  1554.         70176 Stuttgart
  1555.             Germany
  1556.  
  1557.  
  1558.      eMail: delix@delix.de
  1559.     www: http://www.delix.de
  1560.     ftp:  ftp://ftp.delix.de
  1561.  
  1562.  
  1563.         Entwickelt von:
  1564.     Ngo Than <than@delix.de>
  1565.   Niels Mache <niels@delix.de>
  1566. EOF
  1567.  
  1568.    mydialog --title "DLD $DLDVersion Installation" --textbox /tmp/tmp.doi 20 36
  1569.    rm -f /tmp/tmp.doi
  1570. }
  1571.  
  1572. Inittab() {
  1573. ed $IPath/etc/inittab >/dev/null 2>&1 << EOF
  1574. 25
  1575. d
  1576. i
  1577. id:4:initdefault:
  1578. .
  1579. w
  1580. q
  1581. EOF
  1582. }
  1583.  
  1584.  
  1585. setupBase() {
  1586.     hash -r
  1587.     [ ! -d $IPath/etc ] && $MKDIR $IPath/etc
  1588.  
  1589.     $CP /tmp/fstab.tmp $IPath/etc/fstab
  1590.     echo $RootPartition > /tmp/ROOTDEV
  1591.     Inittab
  1592.  
  1593.     if [ -f /tmp/pcmcia ]; then
  1594.         $CP /tmp/pcmcia $IPath/etc/sysconfig/pcmcia
  1595.     fi
  1596.  
  1597.     if [ -f /tmp/conf.modules ]; then
  1598.         $CP /tmp/conf.modules $IPath/etc
  1599.     fi
  1600.  
  1601.     if [ -f /tmp/cdrom ]; then
  1602.         device=`cat /tmp/cdrom`
  1603.         (cd $IPath/dev; rm -f cdrom; ln -s `basename $device` cdrom)
  1604.         echo "CDROM_DEVICE=$device" > $IPath/etc/sysconfig/cdrom
  1605.     fi
  1606.  
  1607.     for i in NETINST ROOTDEV; do
  1608.         [ -f /tmp/$i ] && $CP /tmp/$i $IPath$SetupDir
  1609.     done
  1610.  
  1611.     echo "LANGUAGE=de" > $IPath/etc/sysconfig/language
  1612.     echo "KEYTABLE=/usr/lib/kbd/keytables/de-dld.map" > $IPath/etc/sysconfig/keyboard
  1613.  
  1614.     # restoreConfig
  1615. }
  1616.  
  1617.  
  1618. # -----------------------  main program ---------------------------
  1619.  
  1620. trap bye 2
  1621.  
  1622.  
  1623. startup
  1624. banner
  1625.  
  1626.  
  1627. while [ 1 ]; do
  1628.  
  1629.     RootPartition=
  1630.     umountAll
  1631.     umount /mnt >/dev/null 2>&1
  1632.     linuxSetup
  1633.  
  1634.     if [ $? != "0" ]; then
  1635.     bye
  1636.     fi
  1637.  
  1638.     getSourceDev
  1639.  
  1640.     if [ "$Stat" = "0" ]; then
  1641.     break
  1642.     fi
  1643.  
  1644. done
  1645.  
  1646. checkSwapPartitions
  1647. checkDOSPartitions
  1648. copyInstallFiles
  1649.  
  1650. installSystem
  1651. [ "$?" = "1" ] && bye
  1652.  
  1653. setupBase
  1654.  
  1655. $SYNC
  1656. $UMOUNT $InstallRoot 2>/dev/null
  1657.  
  1658. # Fixes
  1659. if [ -f $FIXES ] ; then
  1660.     (cd $IPath ; tar zopxf $FIXES >/dev/null 2>&1)
  1661. fi
  1662.  
  1663. if [ -x $IPath/install/doinst.sh ] ; then
  1664.     (cd $IPath ; sh install/doinst.sh)
  1665. fi
  1666.  
  1667. $RM -r $IPath/install
  1668. $SYNC
  1669.  
  1670. cleanup
  1671. umountAll
  1672.  
  1673. exit 0
  1674.