home *** CD-ROM | disk | FTP | other *** search
/ Dream 46 / Amiga_Dream_46.iso / bo / boot / root.bin / root / sbin / dinstall < prev    next >
Text File  |  1997-05-27  |  69KB  |  2,799 lines

  1. #!    /bin/ash
  2.  
  3. #set -x
  4.  
  5. Root=""
  6. Base_Archive_Dir=""
  7. readonly Arch=`( cd /etc; echo architecture.*) | sed -e 's/architecture.//'`
  8.  
  9. Arch2=""
  10.  
  11. if [ "$Arch" = "m68k" ]; then
  12.     Arch2=`cat /proc/hardware | ( read line; set -- $line; 
  13.         if [ "$1" = "Model:" ]; then echo $2 ;return 0; fi)`
  14.     case "$Arch2" in
  15.     Atari|Amiga)
  16.         ;;
  17.     *)
  18.         echo "Your m68k architecture is not supported yet"
  19.         read foo
  20.         exit 0
  21.     esac
  22. fi
  23.  
  24. readonly Arch2
  25.  
  26. readonly revext=`( cd /etc; echo revision_ext.*) | sed -e 's/revision_ext.//'`
  27.  
  28. readonly bold=''
  29. readonly clear='H'
  30. readonly norm=''
  31.  
  32. umask 022
  33. BACKTITLE="Debian GNU/Linux System Installation"
  34. export Swap
  35. CreatedBootFloppy=
  36. InstalledLILO=
  37. readonly TempFile="/tmp/`echo $0|sed -e 's/^.*\///'`.$$"
  38. readonly InstallationRootDevice="`block_device / 2>/dev/null`"
  39.  
  40. # Ignore interrupt in scripts, catch it in programs started by scripts.
  41. trap true 2 3
  42. # When the system halts, clear any menus that may be displayed on the first
  43. # console.
  44. trap "rm -f $TempFile; echo $clear; exit 0" 1 15
  45. cd /
  46.  
  47. count_words ()
  48. {
  49.     echo "$#"
  50. }
  51.  
  52. first ()
  53. {
  54.     echo "$1"
  55. }
  56.  
  57. second ()
  58. {
  59.     echo "$2"
  60. }
  61.  
  62. third ()
  63. {
  64.     echo "$3"
  65. }
  66.  
  67. fourth ()
  68. {
  69.     echo "$4"
  70. }
  71.  
  72. last ()
  73. {
  74.     eval echo $"$#"
  75. }
  76.  
  77. not ()
  78. {
  79.     if [ "$1" -eq 0 -o "$1" = "" ]; then
  80.         echo 1
  81.     else
  82.         echo 0
  83.     fi
  84. }
  85.  
  86. write_it_down ()
  87. {
  88.     local text="$1"
  89.     local reply
  90.     echo ""
  91.     echo "$bold\
  92. $text
  93.  
  94. You might want to write down the error messages before
  95. you continue. Please press ENTER when you are ready.$norm"
  96.     read reply
  97.     return $?
  98. }
  99.  
  100. not_on_lowmem ()
  101. {
  102.     local text="$1"
  103.     local reply
  104.     echo ""
  105.     echo "$bold\
  106. $text
  107.  
  108. This is not supported on the Low Memory Installation Floppy.
  109. Please press ENTER to continue.$norm"
  110.     read reply
  111.     return $?
  112. }
  113.  
  114. match_find ()
  115. {
  116.     local files="$1"
  117.     local name="$2"
  118.  
  119.     find "$1" | ( while read line; do
  120.                 case $line in
  121.                 */$2)
  122.                     echo $line
  123.                     ;;
  124.                 esac 
  125.             done)
  126. }
  127.  
  128. unreachable ()
  129. {
  130.     write_it_down "This line should never have been reached.
  131. This indicates a bug in this program."
  132.     exit 1
  133. }
  134.  
  135. color_or_monochrome () {
  136.     if [ "$TERM" = "linux" ]; then
  137.         export TERM=linux-m
  138.     fi
  139.  
  140.     local choice
  141.     while true; do
  142.         choice="`menu \
  143. "If your monitor displays color, please select \"Color\" here. Select
  144. \"Continue\" when you are satisfied with the display." \
  145.          "Select Color or Monochrome" \
  146.          "Next" "Continue with the installation." \
  147.          "Color" "Select color display." \
  148.          "Monochrome" "Select black-and-white display."`"
  149.         if [ $? -ne 0 ]; then return 1; fi
  150.  
  151.         case $choice in
  152.         Next|"")
  153.             return 0
  154.             ;;
  155.         Color)
  156.             export TERM=linux
  157.             ;;
  158.         Monochrome)
  159.             export TERM=linux-m
  160.             ;;
  161.         *)
  162.             unreachable
  163.         esac
  164.     done
  165.     return 0;
  166. }
  167.  
  168. configure_keyboard () {
  169.     local choice
  170.  
  171.     if [ ! -x /bin/loadkeys ]; then
  172.         not_on_lowmem "Keyboard configuration"
  173.     fi
  174.  
  175.     if [ "$Arch" = "m68k" ]; then
  176.         choice="`menu \
  177. "Please select a keyboard. If you don't find the exact
  178. right choice below, please choose something close. You'll
  179. be able to configure more keyboard choices by running
  180. kbdconfig once you installed the system." "Select Keyboard" \
  181.         "amiga-us" "U.S. English (amiga)" \
  182.         "amiga-de" "German (amiga)" \
  183.         "atari-us" "U.S. English (atari)" \
  184.         "atari-de" "German (atari)" \
  185.         "atari-se" "Sweden (atari)" \
  186.         "atari-uk-falcon" "English for Atari Falcon"`"
  187.     else
  188.         choice="`menu \
  189. "Please select a keyboard. If you don't find the exact
  190. right choice below, please choose something close. You'll
  191. be able to configure more keyboard choices once you
  192. install the system." "Select Keyboard" \
  193.         "us" "U.S. English (Qwerty)" \
  194.         "dvorak" "Dvorak" \
  195.         "de-latin1-nodeadkeys" "Germany" \
  196.         "es" "Spain" \
  197.         "fi" "Finland" \
  198.         "fr-latin1" "France" \
  199.         "it" "Italy" \
  200.         "no" "Norway" \
  201.         "pl" "Poland" \
  202.         "ru" "Russia" \
  203.         "se-latin1" "Sweden" \
  204.         "uk" "United Kingdom"`"
  205.     fi
  206.     if [ $? -ne 0 -o -z "$choice" ]; then return 255; fi
  207. #    (cd /usr/share/keytables; 
  208. #    zcat <keytables.tar.gz | star $choice.map)
  209. #    cp /usr/share/keytables/$choice.map > /etc/kbd/default.map
  210.     zcat < /usr/share/keytables/$choice.map.gz > /etc/kbd/default.map
  211. #    chmod 755 /etc/kbd/default.map
  212.     /bin/loadkeys /etc/kbd/default.map
  213.     return 0
  214. }
  215.  
  216. get_required_parameters () {
  217.     host="`inputBox \
  218. "Every Debian system has a name - even if it is not on a
  219. network. This name is called its \"hostname\". You should now
  220. specify a hostname for your new system.
  221.  
  222. If your system is going to be on a network, you should talk to the
  223. administrator of the network before you choose a hostname. If not,
  224. you may choose any name you like.
  225.  
  226. The hostname must not contain dots, and you must not append the domain
  227. name here.
  228.  
  229. If you can't think of a hostname for your new system, you may press
  230. <ENTER> to use the default hostname of \"debian\"." \
  231.     "Please enter your Host name" debian`"
  232.     if [ $? -ne 0 ]; then return 255; fi
  233.  
  234.     if [ -z "$host" ]; then
  235.         host="debian";
  236.     elif [ `count_words $host` -ne 1 ]; then
  237.         infoBox "Problem" "The host name must be one word."
  238.         return 1
  239.     else
  240.         local repl=`echo $host | sed -e 's/\./ /'`
  241.         if [ `count_words $repl` -ne 1 ]; then
  242.             infoBox "Problem" "The host name must not contain dots."
  243.             return 1
  244.         fi
  245.     fi
  246.  
  247.     return 0
  248. }
  249.  
  250. is_ip_number () {
  251.     local i1 i2 i3 i4
  252.  
  253.     ipa=`echo $1 | sed 's/\./ /g'`
  254.  
  255.     i1=`first $ipa`
  256.     i2=`second $ipa`
  257.     i3=`third $ipa`
  258.     i4=`fourth $ipa`
  259.  
  260.     for i in "$i1" "$i2" "$i3" "$i4"; do
  261.         case $i in
  262.         [0-9]|[0-9][0-9]|[0-9][0-9][0-9])
  263.             ;;
  264.         *)
  265.             return 1
  266.         esac
  267.         if [ $i -lt 0 -o $i -gt 255 ]; then
  268.             return 1
  269.         fi
  270.     done
  271.     return 0
  272. }
  273.  
  274. get_net_parameters () {
  275.     local I1 I2 I3 I4 R1 R2 R3 R4 N1 N2 N3 N4 S1 S2 S3 S4 ipa netm
  276.  
  277.     while true; do
  278.         if [ "$domain" = none ]; then domain=""; fi
  279.         domain="`inputBox \
  280. "As with individual systems, every network has a name.
  281. This name is called the domain name. Please enter your
  282. Domain Name." "Please enter your Domain name" "$domain"`"
  283.         if [ $? -ne 0 ]; then return 255; fi
  284.         if [ -n "$domain" ]; then break; fi
  285.     done
  286.  
  287.     hostname="$host.$domain"
  288.     yesNoBox "The full name of your system is $hostname . Correct?" \
  289.         "Confirm"
  290.     if [ $? -ne 0 ]; then return 255; fi
  291.  
  292.     while true; do
  293.         ipaddr="`inputBox \
  294.             "What is the IP address of system \"$host\"?" \
  295.             "Please Enter IP Address" \
  296.             "$ipaddr"`"
  297.         if [ $? -ne 0 ]; then return 255; fi
  298.         if is_ip_number $ipaddr ; then break; fi
  299.         msgBox "You entered an invalid IP address.
  300. Ask your network administrator." "Error"
  301.     done
  302.  
  303.     ipa=`echo $ipaddr | sed 's/\./ /g'`
  304.     I1=`first $ipa`
  305.     I2=`second $ipa`
  306.     I3=`third $ipa`
  307.     I4=`fourth $ipa`
  308.  
  309.     while true; do
  310.         netmask="`inputBox "What is your netmask?" \
  311.             "Please Enter Netmask" \
  312.             "$netmask"`"
  313.         if [ $? -ne 0 ]; then return 255; fi
  314.         if is_ip_number $netmask ; then break; fi
  315.         msgBox "You entered an invalid netmask.
  316. Ask your network administrator." "Error"
  317.     done
  318.  
  319.     netm=`echo $netmask | sed 's/\./ /g'`
  320.     N1=`first $netm`
  321.     N2=`second $netm`
  322.     N3=`third $netm`
  323.     N4=`fourth $netm`
  324.  
  325.     R1=`math $I1 $N1 and`
  326.     R2=`math $I2 $N2 and`
  327.     R3=`math $I3 $N3 and`
  328.     R4=`math $I4 $N4 and`
  329.  
  330.     network="$R1.$R2.$R3.$R4"
  331.  
  332.     R1=`math $N1 not 255 and $I1 or`
  333.     R2=`math $N2 not 255 and $I2 or`
  334.     R3=`math $N3 not 255 and $I3 or`
  335.     R4=`math $N4 not 255 and $I4 or`
  336.     S1=`math $N1 $I1 and`
  337.     S2=`math $N2 $I2 and`
  338.     S3=`math $N3 $I3 and`
  339.     S4=`math $N4 $I4 and`
  340.  
  341.     broadcast="`menu \
  342.          "What is your IP broadcast address?
  343. Unless your network has very specific needs choose the first option." \
  344.          "Choose Broadcast Address"  \
  345.          "$R1.$R2.$R3.$R4" "Last bits set to one" \
  346.          "$S1.$S2.$S3.$S4" "Last bits set to zero" \
  347.          "another" "choose another broadcast address"`"
  348.     if [ $? -ne 0 ]; then return 255; fi
  349.     if [ "$broadcast" = another ]; then
  350.         while true; do
  351.             [ -n "$broadcast" ] || $broadcast=$R1.$R2.$R3.$R4
  352.             broadcast="`inputBox \
  353.                 "What is your IP broadcast address?" \
  354.                 "Please Enter Broadcast Address"`"
  355.             if [ $? -ne 0 ]; then return 255; fi
  356.             if is_ip_number $broadcast ; then break; fi
  357.             msgBox "You entered an invalid broadcast address.
  358. Ask your network administrator." "Error"
  359.         done
  360.     fi
  361.  
  362.     yesNoBox \
  363. "A gateway system is one that connects your network to
  364. other networks such as your company wide-area net or the
  365. Internet. Is there a gateway system on your network?" "Is there a Gateway?"
  366.     if [ $? -eq 0 ]; then
  367.         R1=`math $I1 $N1 and`
  368.         R2=`math $I2 $N2 and`
  369.         R3=`math $I3 $N3 and`
  370.         while true; do
  371.             [ -n "$gateway" ] || gateway="$R1.$R2.$R3.1"
  372.             gateway="`inputBox "What is your IP gateway address?" \
  373.                 "Please Enter Gateway Address" "$gateway"`"
  374.             if [ $? -ne 0 ]; then return 255; fi
  375.             if is_ip_number $gateway ; then break; fi
  376.             msgBox "You entered an invalid gateway address.
  377. Ask your network administrator." "Error"
  378.         done
  379.     fi
  380.  
  381.     local choice
  382.     choice="`menu \
  383. "Where is the DNS (Domain Name Service) server?" \
  384. "Locate DNS Server" \
  385.     "1" "System \"$host\" will be its own DNS server." \
  386.     "2" "Another system will be the DNS server for system \"$host\"." \
  387.     "3" "There will be no DNS server."`"
  388.     if [ $? -ne 0 ]; then return 255; fi
  389.  
  390.     case $choice in
  391.     1)
  392.         nameserver="127.0.0.1"
  393.         ;;
  394.     2)
  395. # XXX verify nameserver ip addresses
  396.         nameserver="`inputBox \
  397. "Please enter the IP addresses (not host names) of up to 5 name
  398. servers, separated by spaces. Do not use commas. The input line
  399. will scroll to allow you to enter a long line. The servers will
  400. be queried in the order in which you enter them." \
  401.  "Please Enter Name Server Address" "$gateway"`"
  402.         ;;
  403.     3|*)
  404.         nameserver="none"
  405.         ;;
  406.     esac
  407.  
  408.     yesNoBox \
  409. "IP Address:           $ipaddr
  410. Netmask:              $netmask
  411. Network Address:      $network
  412. Broadcast Address:    $broadcast
  413. Gateway Address:      $gateway
  414. Nameserver Addresses: $nameserver
  415.  
  416. Correct?" "Please Confirm"
  417.     if [ $? -ne 0 ]; then return 1; fi
  418.  
  419.     return 0
  420. }
  421.  
  422. write_network_configuration ()
  423. {
  424.     # This uses the following variables
  425.     #
  426.     # $broadcast
  427.     # $domain
  428.     # $gateway
  429.     # $host
  430.     # $hostname
  431.     # $ipaddr
  432.     # $nameserver
  433.     # $netmask
  434.     # $network
  435.     # $netinterface
  436.  
  437.     for i in /target/etc /target/etc/init.d ; do
  438.         [ -d $i ] || mkdir $i;
  439.     done
  440.  
  441.     echo $host >/target/etc/hostname
  442.     
  443.     echo "localnet    $network" > /target/etc/networks
  444.  
  445.     if [ "$domain" != "none" ]; then
  446.         cat >/target/etc/resolv.conf << EOF
  447. search $domain
  448. EOF
  449.         if [ "$nameserver" != "none" ]
  450.         then
  451.             for i in $nameserver; do
  452.                 echo "nameserver    $i" >> /target/etc/resolv.conf
  453.             done
  454.         fi
  455.     fi
  456.  
  457.  
  458.     cat > /target/etc/init.d/network << EOF
  459. #!    /bin/sh
  460. ifconfig lo 127.0.0.1
  461. route add -net 127.0.0.0
  462. EOF
  463.     chmod 755 /target/etc/init.d/network
  464.  
  465.     if [ "$netinterface" != none ]; then
  466.         cat >> /target/etc/init.d/network << EOF
  467. IPADDR=$ipaddr
  468. NETMASK=$netmask
  469. NETWORK=$network
  470. BROADCAST=$broadcast
  471. GATEWAY=$gateway
  472. ifconfig $netinterface \${IPADDR} netmask \${NETMASK} broadcast \${BROADCAST}
  473. route add -net \${NETWORK}
  474. [ "\${GATEWAY}" ] && route add default gw \${GATEWAY} metric 1
  475. EOF
  476.     fi
  477.  
  478.     case "$netinterface" in
  479.     eth0|tr0)
  480.         cat > /target/etc/hosts << EOF
  481. 127.0.0.1    localhost
  482. $ipaddr        $hostname    $host
  483. EOF
  484.         ;;
  485.     none)
  486.         cat > /target/etc/hosts << EOF
  487. 127.0.0.1    $host    localhost
  488. EOF
  489.         ;;
  490.     slip|ppp|plip)
  491.         cat > /target/etc/hosts << EOF
  492. 127.0.0.1    localhost
  493. $ipaddr        $hostname    $host
  494. EOF
  495.         msgBox \
  496. "This installation program does not create a complete SLIP, PPP or
  497. PLIP configuration. For SLIP and PPP you need additional packages like
  498. dip or ppp. For PPP you have to create the configuration entries in
  499. /etc/init.d/network ." "Information"
  500.         ;;
  501.     pcmcia)
  502.         cat >> /target/etc/pcmcia/network.opts << EOF
  503.  
  504. # Automatically configured during Debian installation
  505. IPADDR="$ipaddr"
  506. NETMASK="$netmask"
  507. NETWORK="$network"
  508. BROADCAST="$broadcast"
  509. GATEWAY="$gateway"
  510. DOMAIN="$domain"
  511. EOF
  512.         if [ "$nameserver" != "none" ]; then
  513.             cat >> /target/etc/pcmcia/network.opts << EOF
  514. DNSSRVS="$nameserver"
  515. EOF
  516.         fi
  517.         ;;
  518.     *)
  519.         unreachable
  520.     esac
  521.  
  522.     return 0
  523. }
  524.  
  525. configure_network () {
  526.     require_root
  527.     if [ $? -ne 0 ]; then return 1; fi
  528.  
  529.     local broadcast gateway host hostname netinterface ipaddr nameserver \
  530.      netmask network
  531.  
  532.     while true; do
  533.         get_required_parameters
  534.         local status=$?
  535.         if [ $status -eq 255 ]; then return 255; fi
  536.         if [ $status -eq 0 ]; then break; fi
  537.     done
  538.  
  539.     yesNoBox \
  540. "Is your system connected to a network?
  541.  
  542. If you decide to use a network you must ask your 
  543. network administrator for an IP address and the 
  544. network parameters !" "Use a Network?"
  545.     if [ $? -ne 0 ]; then
  546.         broadcast="127.0.0.255"
  547.         domain="none"
  548.         gateway="none"
  549.         hostname="$host"
  550.         ipaddr="127.0.0.1"
  551.         nameserver="none"
  552.         netmask="255.255.255.0"
  553.         network="127.0.0.0"
  554.         netinterface=none
  555.     else
  556.         while true; do
  557.             [ -n "$ipaddr" ] || ipaddr="192.168.1.1"
  558.             [ -n "$netmask" ] || netmask="255.255.255.0"
  559.             get_net_parameters
  560.             local status=$?
  561.             if [ $status -eq 255 ]; then return 255; fi
  562.             if [ $status -eq 0 ]; then break; fi
  563.         done
  564.  
  565.         netinterface="`menu \
  566.             "Choose the type of your primary network interface.
  567. If you have more than one network interface, choose the one that you will
  568. need for installing Debian (via NFS or FTP)" \
  569.             "Choose network interface" \
  570.             "eth0" "Ethernet or Fast Ethernet" \
  571.             "tr0" "Token Ring" \
  572.             "ppp" "PPP" \
  573.             "slip" "SLIP" \
  574.             "plip" "PLIP" \
  575.             "pcmcia" "PCMCIA Ethernet or Token Ring"`"
  576.         if [ $? -ne 0 ]; then return 255 ;fi        
  577.  
  578.     fi
  579.  
  580.     write_network_configuration
  581.  
  582.     if [ -x /sbin/ifconfig ]; then
  583.         /target/etc/init.d/network
  584.         (cd /etc; rm -rf resolv.conf; \
  585.             ln -s /target/etc/resolv.conf . )
  586.     fi
  587.  
  588.     return 0
  589. }
  590.  
  591. configure_timezone () {
  592.     require_root
  593.     if [ $? -ne 0 ]; then return 1; fi
  594.  
  595.     local target=/target
  596.     local dir=$target/usr/lib/zoneinfo
  597.     local basedir=$dir
  598.     local tz
  599.     local tzdir
  600.     local input
  601.  
  602.     cd $dir || write_it_down "Base not yet installed"
  603.  
  604.     done=0
  605.     until [ $done = 1 ]; do
  606.  
  607.         echo -n $clear$bold"Timezone setup... "$norm
  608.         echo "(Current directory: $dir)"
  609.         cat << EOF
  610.  
  611. Please select the appropriate location in the world in which you
  612. live.  A name followed by a slash (/) indicates that this option
  613. leads to further options, such as specific sections of a country.
  614.  
  615. You may enter \`..' to go up a level.
  616.  
  617. ---------------------------------------------------------------------------
  618. EOF
  619.  
  620.         ls -F $dir
  621.  
  622.         cat << EOF
  623. ---------------------------------------------------------------------------
  624. EOF
  625.  
  626.         echo
  627.         echo -n "Which? "
  628.         read input
  629.  
  630.         if [ "$input" = localtime -o "$input" = posixrules ]; then
  631.             continue
  632.         fi
  633.         if [ -d "$input" ]; then
  634.             if [ "$input" = .. ]; then
  635.                 if [ $dir = $basedir ]; then
  636.                     continue
  637.                 fi
  638.             fi
  639.             cd $input
  640.             dir=`pwd`
  641.         elif [ -f $dir/$input ]; then
  642.             tzdir=`echo $dir/$input | sed -e "s,$target,,"`
  643.             tz=`echo $dir/$input | sed -e "s,$basedir/,,"`
  644.             done=1
  645.         else
  646.             echo
  647.             echo "\`$input' does not exist; try again."
  648.             echo
  649.             sleep 1
  650.         fi
  651.     done
  652.  
  653.     rm -f /target/etc/localtime
  654.     ln -s $tzdir /target/etc/localtime
  655.     echo $tz >/target/etc/timezone
  656.  
  657.     while true; do
  658.         cat << EOF
  659. Unix system clocks are generally set to GMT (also known as Universal
  660. Time) and use time zone files to convert this value into local time.
  661. If you want your new Debian Linux system to use GMT rather than
  662. local time, you should answer \`y' to the following question.  If you
  663. want the clock to continue to run on local time, answer \`n'.
  664.  
  665. NOTE: If this system previously ran MS-DOS, the clock is probably set
  666. to local time.  If you want your new Debian Linux system to use
  667. GMT, answer \`y' to the following question and reset the clock after
  668. you have Debian Linux installed.
  669.  
  670. EOF
  671.         echo -n "According to the system, the time is "
  672.         date
  673.         echo
  674.         echo -n "Is your system clock set to GMT (y/n) [y]? "
  675.         read input
  676.         case $input in
  677.         n)
  678.             GMT=""
  679.             sed -e 's:^GMT="-u":GMT="":' /target/etc/init.d/boot \
  680.                 > /target/etc/init.d/boot.new
  681.             mv /target/etc/init.d/boot.new \
  682.                 /target/etc/init.d/boot
  683.             chmod 755 /target/etc/init.d/boot
  684.             break
  685.             ;;
  686.         y|"")
  687.             break
  688.             ;;
  689.         *)
  690.             echo "
  691. $boldPlease answer \`y' or \`n'.$norm
  692. "
  693.         esac 2>/dev/null
  694.     done
  695.  
  696.     return $?
  697. }
  698.  
  699. configure_base() {
  700.     require_root
  701.     if [ $? -ne 0 ]; then return 1; fi
  702.     require_swap
  703.     if [ $? -ne 0 ]; then return 1; fi
  704.     if [ ! -f /target/sbin/init ]; then
  705.         msgBox "You have to install base for configuring it" "Error"
  706.     fi
  707.     output=`write_fstab`
  708.     if [ $? -ne 0 -o -n "$output" ]; then
  709.         msgBox \
  710. "Failed to write /etc/fstab:
  711. $output" "Problem"
  712.         return 1
  713.     fi
  714.     if [ ! -f /target/root/.bash_profile.real ]; then
  715.         mv /target/root/.bash_profile \
  716.             /target/root/.bash_profile.real
  717.     fi
  718.     zcat < /etc/root.sh.tar.gz | (cd /target/root; star)
  719.     chown -R root.root /target/root
  720.  
  721.     configure_timezone
  722.     rm -f /target/sbin/unconfigured.sh
  723. }
  724.  
  725. # Shell interface to "dialog"
  726. # Bruce Perens, November 1995
  727. # This is free software under the GNU General Public License.
  728.  
  729. # Global options
  730. #    The variable $BACKTITLE specifies the back title.
  731. #    The variable $DIALOG_OPTIONS, initialized here to --clear, provides
  732. #    options you want on the command line of each dialog invocation.
  733. #    The variable $DIALOG_TEST can be set to "echo" to see the calls
  734. #    to dialog without executing them.
  735.  
  736. DIALOG_OPTIONS=""
  737.  
  738. # Make any dialogue box, with default settings and backtitle from
  739. # $BACKTITLE in the environment.
  740. #
  741. # dialog --type arg arg ...
  742. #
  743. dialogBox () {
  744.     local type="$1"
  745.     shift
  746.     local title=""
  747.     local backtitle=""
  748.  
  749.     local text="$1"
  750.     shift
  751.  
  752.     if [ $# -ge 1 ]; then
  753.         title="$1"
  754.         shift
  755.     fi
  756.  
  757.     if [ -n "$BACKTITLE" ]; then
  758.         backtitle="$BACKTITLE"
  759.     fi
  760.  
  761.     $DIALOG_TEST dialog $DIALOG_OPTIONS --title "$title" --backtitle \
  762.      "$backtitle" "$type" "$text" 0 0 "$@" 2>&1 1>/dev/tty
  763.     local result=$?
  764.     return $result
  765. }
  766.  
  767. # Display a file.
  768. #
  769. # fileBox filename [title]
  770. #
  771. fileBox () {
  772.     dialogBox --textbox "$1" "$2"
  773. }
  774.  
  775. # textBox takes presents its standard input in a dialog box. This
  776. # is useful for "here documents" and pipes.
  777. #
  778. # textBox [title]
  779. #
  780. textBox () {
  781.     cat >$TempFile
  782.  
  783.     if [ $? -ne 0 ]; then
  784.         echo "Can't make temporary file for dialog box." 1>&2
  785.         return 255
  786.     fi
  787.  
  788.     # Note that dialog needs stdin to be the terminal, so I redirect here.
  789.     < /dev/tty dialogBox --textbox $TempFile "$1"
  790.     local result=$?
  791.     rm -f $TempFile
  792.     return $result
  793. }
  794.  
  795. msgBox () {
  796.     dialogBox --msgbox "$1" "$2"
  797. }
  798.  
  799. infoBox () {
  800.     dialogBox --infobox "$1" "$2"
  801. }
  802.  
  803. yesNoBox () {
  804.     dialogBox --yesno "$1" "$2"
  805.     return $?
  806. }
  807.  
  808. inputBox () {
  809.     dialogBox --inputbox "$1" "$2" "$3"
  810.     return $?
  811. }
  812.  
  813. # menu text title tag1 item1 ...
  814. menu () {
  815.     local text="$1"
  816.     shift
  817.     local title="$1"
  818.     shift
  819.     dialogBox --menu "$text" "$title" 0 "$@"
  820.     return $?
  821. }
  822.  
  823. # menu text title tag1 item1 status1 ...
  824. checklist () {
  825.     local text="$1"
  826.     shift
  827.     local title="$1"
  828.     shift
  829.     dialogBox --checklist "$text" "$title" 0 "$@"
  830.     return $?
  831. }
  832.  
  833. # menu text title tag1 item1 status1 ...
  834. radiolist () {
  835.     local text="$1"
  836.     shift
  837.     local title="$1"
  838.     shift
  839.     dialogBox --radiolist "$text" "$title" 0 "$@"
  840.     return $?
  841. }
  842.  
  843. # XXX this isn't only for base archive anymore ...
  844. choose_base_archive_dir () {
  845.  
  846.     local type=$1 # kernel or base
  847.     local mountpoint=$2
  848.     local pattern
  849.     local descr
  850.  
  851.     local default
  852.     local choice
  853.  
  854.     case $type in
  855.     kernel)
  856.         pattern='resc1440.bin' # this could be a wildcard pattern
  857.                     # but no multiple match
  858.         descr="the Kernel and the Modules"
  859.         ;;
  860.     base)
  861.         pattern='base1_3.tgz'
  862.         descr="the Base System"
  863.         ;;
  864.     *)
  865.         unreachable
  866.     esac
  867.  
  868.     for i in $mountpoint/stable/disks-${Arch}/current \
  869.             $mountpoint/*/stable/disks-${Arch}/current ; do
  870.         if [ -f $i/$pattern -a -z "$default" ] ; then
  871.             if [ $type = base -o -f $i/drv1440.bin ]; then
  872.                 default=$i;
  873.             fi
  874.         fi
  875.     done
  876.  
  877.     cat > $TempFile << EOF
  878.         menu \\
  879. "Please select the directory containing a file $pattern
  880.  that you will use to install $descr.
  881. Unless you really know what you need choose the default." \\
  882. "Select Base Archive file" \\
  883. EOF
  884.     if [ -n "$default" -a -f $default/base1_3.tgz \
  885.             -a -f $default/resc1440.bin \
  886.             -a -f $default/drv1440.bin ]; then
  887.         cat >> $TempFile << EOF
  888. "default" "The default stable Archive" \\
  889. EOF
  890.     fi
  891.     cat >> $TempFile << EOF
  892. "list" "Choose from a list of all Base Archive Files" \\
  893. "manually" "Enter the directory containing the Base Archive File manually"
  894. EOF
  895.  
  896.     choice=`. $TempFile`
  897.     if [ $? -ne 0 -o -z "$choice" ]; then return 1; fi
  898.  
  899.     case $choice in
  900.     default)
  901.         Base_Archive_Dir=$default
  902.         ;;
  903.     list)
  904.         cat > $TempFile <<EOF
  905.             menu \\
  906. "Please select the directory that you will use to install
  907. the base archive." \\
  908.             "Select the Base Archive directory" \\
  909. EOF
  910.  
  911.         local dir
  912.         for i in `match_find $mountpoint $pattern`; do
  913.             dir=`echo $i|sed -e 's,/[^/]*$,,'`
  914.             if [ $type = base -o -f $dir/drv1440.bin ]; then
  915.                 echo "\"$dir\" \"\"" \\ >> $TempFile
  916.             fi
  917.         done
  918.         echo >>$TempFile
  919.  
  920.         Base_Archive_Dir=`. $TempFile`
  921.         if [ $? -ne 0 -o -z "$Base_Archive_Dir" ]; then return 1; fi
  922.         ;;
  923.     manually)
  924.         Base_Archive_Dir="`inputBox \
  925.             "Please enter the name of the directory that
  926. contains the Base Archive
  927.  
  928. The installation medium is mounted
  929. below $mountpoint/ ." \
  930.             "Enter the Base Archive directory" \
  931.             "$mountpoint/"`"
  932.         if [ $? -ne 0 ]; then return 1; fi
  933.         if [ ! -f $Base_Archive_Dir/$pattern ]; then
  934.             msgBox "$Base_Archive_Dir does not
  935. contain the file $pattern that is needed to install
  936. $descr" "Error"
  937.             return 1
  938.         fi
  939.         if [ $type = kernel -a \
  940.                 ! -f $Base_Archive_Dir/drv1440.bin ]; then
  941.             msgBox "$Base_Archive_Dir does not
  942. contain the file drv1440.bin that is needed to install
  943. $descr" "Error"
  944.             return 1
  945.         fi
  946.         ;;
  947.     *)
  948.         unreachable
  949.     esac
  950.     return 0
  951. }
  952.  
  953. choose_medium ()
  954. {
  955.     local type=$1 # kernel or base
  956.     local old_medium_device="$Medium_Device"
  957.  
  958.     local offer_default
  959.  
  960.     cat > $TempFile <<EOF
  961.     menu \\
  962. "Please select the medium you will use to install
  963. the system." \\
  964.      "Select Installation Medium" \\
  965. EOF
  966.     
  967.     if [ -n "$Medium_Device" ]; then
  968.         case "$type" in
  969.         kernel)
  970.             if [ -f $Medium_Device/resc1440.bin -a \
  971.                     -f $Medium_Device/drv1440.bin ]; then
  972.                 offer_default=true
  973.             fi
  974.             ;;
  975.         base)
  976.             if [ -f $Medium_Device/base1_3.tgz ]; then
  977.                 offer_default=true
  978.             fi
  979.             ;;
  980.         *)
  981.             unreachable
  982.         esac
  983.         if [ -n "$offer_default" ]; then
  984.             echo "\"default\" \"Previous selection\"" \\>>$TempFile
  985.         fi
  986.     fi
  987.     if [ "$InstallationRootDevice" != /dev/fd0 ]; then
  988.         echo "\"/dev/fd0\" \"First floppy drive\"" \\>>$TempFile
  989.     fi
  990.     if [ "$InstallationRootDevice" != /dev/fd1 ]; then
  991.         echo "\"/dev/fd1\" \"Second floppy drive\"" \\>>$TempFile
  992.     fi
  993.     echo "\"cdrom\" \"CD-ROM drive\"" \\>>$TempFile
  994.     echo "\"harddisk\" \"filesystem on the hard disk\"" \\>>$TempFile
  995.     echo "\"mounted\" \"already mounted filesystem\"" \\>>$TempFile
  996.     if [ -f /target/etc/init.d/network -a -x /sbin/ifconfig ]; then
  997.         echo "\"nfs\" \"NFS (network filesystem)\"" \\>>$TempFile
  998.     fi
  999.     echo >>$TempFile
  1000.     Medium_Device="`. $TempFile`"
  1001.     if [ $? -ne 0 -o -z "$Medium_Device" ]; then return 1; fi
  1002.  
  1003.     case $Medium_Device in
  1004.     default)
  1005.         Medium_Device=$old_medium_device
  1006.         ;;
  1007.     /dev/fd*)
  1008.         case $Medium_Device in
  1009.         /dev/fd0)
  1010.             Medium_Designation=first
  1011.             ;;
  1012.         /dev/fd1)
  1013.             Medium_Designation=second
  1014.             ;;
  1015.         *)
  1016.             unreachable
  1017.         esac
  1018.         ;;
  1019.     cdrom|harddisk|mounted|nfs)
  1020.         case $Medium_Device in
  1021.         cdrom)
  1022.             choose_cdrom
  1023.             Medium_Dir=/instmnt
  1024.             if [ $? -ne 0 ]; then return 1; fi
  1025.             ;;
  1026.         harddisk)
  1027.             choose_harddisk
  1028.             Medium_Dir=/instmnt
  1029.             if [ $? -ne 0 ]; then return 1; fi
  1030.             ;;
  1031.         mounted)    
  1032.             Medium_Dir="`inputBox \
  1033. "Please choose the directory where the Debian archive resides" \
  1034. "Choose Debian directory"`"
  1035.             if [ $? -ne 0 ]; then return 1; fi
  1036.             ;;
  1037.         nfs)
  1038.             modprobe nfs
  1039.             local nfsmountpath
  1040.             while true; do
  1041.                 nfsmountpath="`inputBox \
  1042. "Please choose the NFS server and the mount path of the NFS filesystem 
  1043. that contains the Debian archive.
  1044. Enter them in this way:  server:/ftp/debian 
  1045. " \
  1046. "Choose Debian NFS filesystem"`"
  1047.                 if [ $? -ne 0 -o -z "$nfsmountpath" ]; then \
  1048.                     return 1;
  1049.                 fi
  1050.                 umount /instmnt 2>/dev/null
  1051.                 mount $nfsmountpath /instmnt
  1052.                 if [ $? -ne 0 ]; then
  1053.                     write_it_down \
  1054. "Error mounting NFS filesystem \`$nfsmountpath\'"
  1055.                 else
  1056.                     break
  1057.                 fi
  1058.             done
  1059.  
  1060.             while true; do
  1061.                 local nfspath
  1062.                 nfspath="`inputBox \
  1063. "Please choose the path inside the mounted NFS filesystem
  1064. where the Debian archive resides" \
  1065. "Choose Debian NFS path" `"
  1066.                 if [ $? -ne 0 ]; then return 1; fi
  1067.                 Medium_Dir=/instmnt/$nfspath
  1068.                 if [ -d $Medium_Dir ]; then
  1069.                     break
  1070.                 fi
  1071.             done
  1072.             ;;
  1073.         esac
  1074.  
  1075.         choose_base_archive_dir $type $Medium_Dir
  1076.         if [ $? -ne 0 ]; then return 1; fi
  1077.  
  1078.         ;;
  1079.     *)
  1080.         unreachable
  1081.     esac
  1082. }
  1083.  
  1084. extract_base ()
  1085. {
  1086.     require_root
  1087.     if [ $? -ne 0 ]; then return 1; fi
  1088.  
  1089.     choose_medium base
  1090.     if [ $? -ne 0 ]; then return 1; fi
  1091.  
  1092.     case $Medium_Device in
  1093.     /dev/fd*)
  1094.         extract_base_from_floppy $Medium_Device;
  1095.         ;;
  1096.     *)
  1097.         extract_from_file ${Base_Archive_Dir}/base*.tgz "base system"
  1098.     esac
  1099.  
  1100.     if [ $? -ne 0 ]; then
  1101.         return 1
  1102.     fi
  1103.  
  1104.     echo '#! /bin/sh
  1105.  
  1106. cat << EOF
  1107. WARNING!  You are attempting to boot an unconfigured base system.
  1108. You need to configure it before proceeding.  To do this, you need
  1109. to reboot using the Debian Rescue disk and select the
  1110. "Configure the Base System" option from the installation menu.
  1111.  
  1112. Please make sure that the Debian Rescue Disk is in the boot
  1113. floppy drive and press <ENTER> to reboot: 
  1114.  
  1115. EOF
  1116.  
  1117. read input
  1118. reboot' > /target/sbin/unconfigured.sh
  1119.         chmod 755 /target/sbin/unconfigured.sh
  1120.  
  1121.     if [ ! -f /target/etc/inittab ]; then
  1122. # XXX Kludge for broken inittab package. Remove before Debian 1.3 .
  1123.         mv /target/etc/init.d/inittab /target/etc/inittab.real
  1124.     else
  1125.         mv /target/etc/inittab /target/etc/inittab.real
  1126.     fi
  1127.     cp /etc/init_tab /target/etc/inittab
  1128.  
  1129. # XXX chown root.root /target/etc/inittab
  1130.  
  1131.     if [ -f /etc/kbd/default.map ]; then
  1132.         if [ ! -d /target/etc/kbd ]; then
  1133.             mkdir /target/etc/kbd
  1134.         fi
  1135.         cp -p /etc/kbd/default.map /target/etc/kbd/default.map
  1136.     fi
  1137.  
  1138.     sync
  1139.     return 0
  1140. }
  1141.  
  1142. extract_base_from_floppy () {
  1143.     local device=$1
  1144.  
  1145.     echo  $clear$bold\
  1146. "The system is being installed from the $Medium_Designation floppy drive.
  1147. Please respond to the prompts below."$norm
  1148.     echo ""
  1149.     echo ""
  1150.     local status=$?
  1151.     if [ -f /target/base.tar.gz ]; then
  1152.         rm -f /target/base.tar.gz
  1153.     fi
  1154.     floppy_merge $device > /target/base.tar.gz
  1155.     status=$?
  1156.     if [ "$status" -eq 0 ]; then
  1157.         echo $bold"Extracting files, this may take several minutes..."
  1158.         echo $norm
  1159.         cd /target
  1160.         zcat < /target/base.tar.gz | star
  1161.         status=$?
  1162.     fi
  1163.     if [ -f /target/base.tar.gz ]; then
  1164.         rm -f /target/base.tar.gz
  1165.     fi
  1166.     cd /
  1167.     if [ $status -ne 0 ]; then
  1168.         write_it_down "There was a problem extracting the $type floppy from
  1169. $device ."
  1170.         return 1
  1171.     fi
  1172. }
  1173.  
  1174. extract_from_file ()
  1175. {
  1176.     local file=$1
  1177.     local descr="$2"
  1178.  
  1179.     echo \
  1180. $clear$bold"The $descr is being extracted from
  1181. $file ..."$norm
  1182.     echo ""
  1183.     ( cd /target && zcat < $file | star )
  1184.     local status=$?
  1185.     if [ $status -ne 0 ]; then
  1186.         write_it_down "There was a problem extracting the $type from
  1187. $file ."
  1188.         return 1
  1189.     fi
  1190. }
  1191.  
  1192. mount_and_check_floppy () {
  1193.      local device="$1"
  1194.     local type="$2"
  1195.     local actualType
  1196.     local text
  1197.  
  1198.     case "$type" in
  1199.         rescue)
  1200.             text="Rescue Floppy"
  1201.             ;;
  1202.         drivers)
  1203.             text="Drivers Floppy"
  1204.             ;;
  1205.         *)
  1206.             unreachable
  1207.     esac
  1208.  
  1209.     while true; do
  1210.         if [ "$device" = "" ]; then
  1211.             cat > $TempFile <<EOF
  1212. menu \\
  1213. "Please select the floppy drive you will use to read
  1214. the $text." \\
  1215.      "Select Disk Drive" \\
  1216. EOF
  1217.             if [ "$InstallationRootDevice" != /dev/fd0 ]; then
  1218.                 echo "\"/dev/fd0\" \"First floppy drive\"" \\ \
  1219.                     >>$TempFile
  1220.             fi
  1221.             if [ "$InstallationRootDevice" != /dev/fd1 ]; then
  1222.                 echo "\"/dev/fd1\" \"Second floppy drive\"" \\ \
  1223.                     >>$TempFile
  1224.             fi
  1225.             echo >>$TempFile
  1226.             device="`. $TempFile`"
  1227.             if [ $? -ne 0 -o -z "$device" ]; then continue ; fi
  1228.         fi
  1229.         umount /floppy 2>/dev/null
  1230.  
  1231.         case $device in
  1232.         /dev/fd0)
  1233.             Medium_Designation=first
  1234.             ;;
  1235.         /dev/fd1)
  1236.             Medium_Designation=second
  1237.             ;;
  1238.         /dev/loop*)
  1239.             ;;
  1240.         *)
  1241.             unreachable
  1242.         esac
  1243.         
  1244.         case $device in
  1245.         /dev/fd*)
  1246.             msgBox "Please place the $text in the 
  1247. $Medium_Designation floppy drive." \
  1248.                 "Please Insert Disk"
  1249.             ;;
  1250.         esac
  1251.  
  1252.         mount -t msdos -o ro $device /floppy
  1253.         if [ $? -ne 0 ]; then return 1; fi
  1254.  
  1255.         if [ ! -f /floppy/type.txt ]; then
  1256.             echo \
  1257. "This isn't the $type floppy. Please place the
  1258. $type floppy in the $device floppy drive and try again."
  1259.             cd /; umount /floppy; read foo; continue
  1260.         fi
  1261.         actualType=`cat /floppy/type.txt`
  1262.         if [ $? -ne 0 ]; then 
  1263.             cd /
  1264.             umount /floppy
  1265.             write_it_down "Cannot read /floppy/type.txt"
  1266.             continue
  1267.         fi
  1268.         if [ `cat /floppy/type.txt` != $type ]; then
  1269.             echo \
  1270. "This is not the $text .
  1271. Please place the $text 
  1272. in the $device floppy drive and try again."
  1273.             cd /; umount /floppy; read foo; continue
  1274.         else
  1275.             return 0
  1276.         fi
  1277.     done
  1278. }
  1279.  
  1280. install_floppy () {
  1281.     local device="$1"
  1282.     local type="$2"
  1283.  
  1284.     mount_and_check_floppy  $device $type
  1285.     echo $clear$bold"Installing from the $type floppy ..."$norm
  1286.     cd /floppy
  1287.     sh ./install.sh /target
  1288.     local status=$?
  1289.     cd /
  1290.     umount /floppy 2>/dev/null
  1291.     if [ $status -ne 0 ]; then return 1; fi
  1292.     return 0
  1293. }
  1294.  
  1295. extract_kernel_and_modules () {
  1296.     require_root
  1297.     if [ $? -ne 0 ]; then return 1; fi
  1298.  
  1299.     # Only verify root choice if it is not empty.
  1300.     if [ -n "`ls /target/. 2>/dev/null | sed -e 's/lost+found//'`" ]; then
  1301.         cat > $TempFile << EOF
  1302.         yesNoBox \\
  1303. "The following filesystems are mounted, and will have the
  1304. kernel, the modules and the base system installed to them:
  1305. EOF
  1306.         mount | sed -n '/\/target/p' | sed -e 's:target/::' \
  1307.          -e 's:/target:/:' >> $TempFile
  1308.  
  1309. echo '
  1310. Install the kernel and the modules?" "Verify Filesystem Choice?"' >> $TempFile
  1311.         . $TempFile
  1312.         if [ $? -ne 0 ]; then return 1; fi
  1313.     fi
  1314.  
  1315.     choose_medium kernel
  1316.     if [ $? -ne 0 -o -z "$Medium_Device" ]; then return 1; fi
  1317.  
  1318.     case $Medium_Device in
  1319.     /dev/fd*)
  1320.         for type in rescue drivers; do
  1321.  
  1322.             fdflush $Medium_Device
  1323.             echo -n $clear
  1324.  
  1325.             install_floppy $Medium_Device $type
  1326.             if [ $? -ne 0 ]; then
  1327.                 write_it_down "The attempt to extract the $type floppy failed."
  1328.                 return 1
  1329.             fi
  1330.         done
  1331.         ;;
  1332.     cdrom|harddisk|mounted)
  1333.         if [ -n "$Base_Archive_Dir" ]; then
  1334.             if [ -f $Base_Archive_Dir/r*s[c,q]1440.bin -a \
  1335.                     -f $Base_Archive_Dir/drv1440.bin ]; then
  1336. #                if [ "$revext" = lowmem ]; then
  1337. #                    mount_and_check_floppy "" lowmemdrivers
  1338. #                    modconf --source floppy \
  1339. #                        --load-only loop
  1340. #                    umount /floppy 2>/dev/null
  1341. #                fi
  1342.                 echo $clear"Extracting from floppy images on mounted medium
  1343. "
  1344.                 local status
  1345.                 losetup /dev/loop0 `first $Base_Archive_Dir/r*s[c,q]1440.bin`
  1346.                 install_floppy /dev/loop0 rescue
  1347.                 status=$?
  1348.                 losetup -d /dev/loop0
  1349.                 if [ $status -ne 0 ]; then
  1350.                     write_it_down "The attempt to extract the rescue floppy failed."
  1351.                     return 1
  1352.                 fi
  1353.                 losetup /dev/loop0 $Base_Archive_Dir/drv1440.bin
  1354.                 install_floppy /dev/loop0 drivers
  1355.                 status=$?
  1356.                 losetup -d /dev/loop0
  1357.                 if [ $status -ne 0 ]; then
  1358.                     write_it_down "The attempt to extract the driver floppy failed."
  1359.                     return 1
  1360.                 fi
  1361.             else
  1362.                 msgBox \
  1363. "$Base_Archive_Dir does not contain the
  1364. rescue and the driver disk images. You must install them from floppy." \
  1365. "Error"
  1366.             fi
  1367.         fi
  1368.         ;;
  1369.     *)
  1370.         unreachable
  1371.     esac
  1372.  
  1373.     return 0
  1374. }
  1375.  
  1376. find_root () {
  1377.     local root_device
  1378.     root_device="`block_device / 2>/dev/null`"
  1379.     if [ $? -ne 0 ]; then return 1; fi
  1380.     local target_device
  1381.     target_device="`block_device /target 2>/dev/null`"
  1382.     if [ $? -ne 0 ]; then return 1; fi
  1383.     if [ $root_device != $target_device ]; then
  1384.         echo $target_device
  1385.     fi
  1386.     return 0
  1387. }
  1388.  
  1389. require_root () {
  1390.     local status=0
  1391.  
  1392.     if [ -n "$TEST" ]; then
  1393.         return 0
  1394.     fi
  1395.     if [ -z "$Root" ]; then
  1396.         msgBox \
  1397. "The requested operation can't be performed until the root
  1398. filesystem is mounted.
  1399.  
  1400. Before you begin installation, you must first partition
  1401. your disk, and then initialize and mount your root filesystem,
  1402. and initialize a swap partition.
  1403. Please use the main menu to complete any of those steps
  1404. that you have not done, and then use the main menu to return
  1405. to this step." \
  1406.         "Problem"
  1407.         return 1
  1408.     fi
  1409.     return 0
  1410. }
  1411.  
  1412. require_swap () {
  1413.     local status=0
  1414.     if [ -z "$Swap" ]; then
  1415.         msgBox \
  1416. "Your swap partition has not been set up.
  1417. Before you begin installation, you must first partition
  1418. your disk, and then initialize and mount your root filesystem,
  1419. and initialize a swap partition.
  1420. Please use the main menu to complete any of those steps
  1421. that you have not done, and then use the main menu to return
  1422. to this step." \
  1423.         "Problem"
  1424.         return 1
  1425.     fi
  1426.     return 0
  1427. }
  1428.  
  1429. choose_cdrom ()
  1430. {
  1431.     local choice
  1432.     choice="`menu \
  1433. "Choose the type of your CD interface" \
  1434. "Select CD interface type" \
  1435.         "/dev/scd0" "SCSI" \
  1436.         "/dev/hda" "ATAPI (IDE), first drive on the primary controller" \
  1437.         "/dev/hdb" "ATAPI (IDE), second drive on the primary controller" \
  1438.         "/dev/hdc" "ATAPI (IDE), first drive on the secondary controller" \
  1439.         "/dev/hdd" "ATAPI (IDE), second drive on the secondary controller" \
  1440.         "/dev/hde" "ATAPI (IDE), first drive on the third controller" \
  1441.         "/dev/hdf" "ATAPI (IDE), second drive on the third controller" \
  1442.         "proprietary" "proprietary CD-ROM interface"`"
  1443.     if [ $? -ne 0 -o -z "$choice" ]; then return 1; fi
  1444.  
  1445.     case $choice in
  1446.     /dev/scd0)
  1447.         if [ ! -f /proc/scsi/*/0 ]; then
  1448.             msgBox \
  1449. "No SCSI adapter was detected, so I cannot access a
  1450. SCSI CD-ROM drive. Please check that you really have a SCSI
  1451. host adapter and a SCSI CD-ROM drive. Check also that
  1452. they are supported by Linux"
  1453.         fi
  1454. #        if [ "$revext" = lowmem ]; then
  1455. #            mount_and_check_floppy "" lowmemdrivers
  1456. #            modconf --source floppy --load-only sr_mod
  1457. #            umount /floppy 2>/dev/null
  1458. #        fi
  1459.         (cd /dev; rm -f cdrom; ln -s scd0 cdrom)
  1460.         ;;
  1461.     /dev/hd*)
  1462.         (cd /dev; rm -f cdrom; ln -s $choice cdrom)
  1463.         ;;
  1464.     proprietary)
  1465.         if [ -d /target/lib/modules/*/net ]; then
  1466.             modconf --restrict-section cdrom \
  1467.                 --run-shell cdromsymlink
  1468.         else
  1469.             mount_and_check_floppy "" drivers
  1470.             modconf --source floppy --restrict-section cdrom \
  1471.                 --run-shell cdromsymlink
  1472.             umount /floppy 2>/dev/null
  1473.         fi
  1474.         ;;
  1475.     *)
  1476.         unreachable
  1477.     esac
  1478.  
  1479. #    if [ "$revext" = lowmem ]; then
  1480. #        mount_and_check_floppy "" lowmemdrivers
  1481. #        modconf --source floppy --load-only isofs
  1482. #        umount /floppy 2>/dev/null
  1483. #    fi
  1484.  
  1485.     msgBox \
  1486. "Please place the Debian CD-ROM in the CD-ROM drive." \
  1487. "Please insert the CD-ROM"
  1488.  
  1489.     umount /instmnt 2>/dev/null
  1490.     mount -t iso9660 -r /dev/cdrom /instmnt
  1491.     if [ $? -ne 0 ]; then
  1492.         write_it_down "The CD-ROM was not mounted successfully."
  1493.         return 1
  1494.     fi
  1495. }
  1496.  
  1497. choose_harddisk ()
  1498. {
  1499.     local partition
  1500.  
  1501.     umount /instmnt 2>/dev/null
  1502.  
  1503.     partition=`select_not_mounted \
  1504. "Please select the partition where your Debian Archive resides." \
  1505. "Select Partition" ext2 minix msdos`
  1506.     if [ $? -ne 0 ]; then return 1; fi
  1507.     
  1508.     local fstype=`partition_to_fstype $partition`
  1509.  
  1510.     mount -t $fstype -r $partition /instmnt
  1511.     if [ $? -ne 0 ]; then
  1512.         write_it_down "The Partition was not mounted successfully."
  1513.         return 1
  1514.     fi
  1515. }
  1516.  
  1517. init_linux () {
  1518.     sync
  1519.     local partition
  1520.     partition=`select_not_mounted \
  1521. "Please select the partition to initialize as a
  1522. Linux \"ext2\" filesystem." "Select Partition" ext2`
  1523.     if [ $? -ne 0 -o -z "$partition" ]; then return 1; fi
  1524.     local cflag
  1525.     cflag="`get_cflag $partition`"
  1526.     if [ $? -ne 0 ]; then return 1; fi
  1527.     yesNoBox \
  1528. "You have chosen to initialize $partition as a Linux \"ext2\"
  1529. filesystem. This will permanently erase any data on this
  1530. partition. Are you sure you want to do this?" "Are You Sure?"
  1531.     if [ $? -ne 0 ]; then return 1; fi
  1532.     echo $clear$bold"Creating filesystem..."$norm
  1533.     echo ""
  1534.     mkfs.ext2 $cflag $partition
  1535.     if [ $? -ne 0 ]; then
  1536.         write_it_down "The filesystem was not created."
  1537.         return 1
  1538.     fi
  1539.     mount_partition $partition
  1540.     return $?
  1541. }
  1542.  
  1543. init_swap () {
  1544.     if [ -n "$Swap" -a "$Swap" != "None" ]; then
  1545.         yesNoBox \
  1546. "You have already activated $Swap as your swap partition. If you
  1547. choose to initialize another swap partition, $Swap will be de-activated
  1548. as your swap partition. If you wish to have multiple swap partitions,
  1549. you can set them up after you've installed the system - this installer
  1550. can only handle one at a time. Answer \"no\" to the following question
  1551. if you wish to keep your present swap partition active.
  1552.  
  1553. Initialize and activate a new swap partition?" "Initialize Another Swap Partition?"
  1554.         if [ $? -ne 0 ]; then return 1; fi
  1555.         swapoff $Swap
  1556.         Swap=""
  1557.     fi
  1558.  
  1559.     local partition
  1560.     partition=`select_not_mounted \
  1561. "Please select the partition to initialize as a swap device." \
  1562. "Select Swap Partition" swap`
  1563.     if [ $? -ne 0 -o -z "$partition" ]; then return 1; fi
  1564.     local cflag
  1565.     cflag="`get_cflag $partition`"
  1566.     if [ $? -ne 0 ]; then return 1; fi
  1567.     yesNoBox \
  1568. "You have chosen to initialize $partition as a swap device. This
  1569. will permanently erase any data on this partition. Are
  1570. you sure you want to do this?" "Are You Sure?"
  1571.     if [ $? -ne 0 ]; then return 1; fi
  1572.     echo $clear$bold"Initializing swap partition..."$norm
  1573.     echo ""
  1574.     mkswap $cflag $partition
  1575.     if [ $? -ne 0 ]; then
  1576.         write_it_down "The swap partition could not be initialized."
  1577.         return 1
  1578.     fi
  1579.     swapon $partition
  1580.     if [ $? -ne 0 ]; then
  1581.         write_it_down "The swap partition could not be activated."
  1582.         return 1
  1583.     fi
  1584.     Swap=$partition
  1585.     return 0
  1586. }
  1587.  
  1588. no_swap () {
  1589.     yesNoBox \
  1590. "A swap partition is a good idea for all systems, even
  1591. ones with lots of memory. It's strongly encouraged that
  1592. you create one.
  1593.  
  1594. If you have less than 8 megabytes of RAM in your system,
  1595. you will need to create a swap partition simply so that
  1596. there is enough virtual memory to finish the installation.
  1597.  
  1598. If you answer \"Yes\" to the following question, the system
  1599. will not require you to create a swap partition. It's strongly
  1600. advised that you answer \"No\".
  1601.  
  1602. Would you like to do without a swap partition?" "Do Without a Swap Partition"
  1603.     if [ $? -eq 0 ]; then
  1604.         if [ -n "$Swap" -a "$Swap" != "None" ]; then
  1605.             swapoff $Swap
  1606.         fi
  1607.         Swap="None"
  1608.     fi
  1609. }
  1610.  
  1611. activate_swap () {
  1612.     if [ -n "$Swap" -a "$Swap" != "None" ]; then
  1613.         yesNoBox \
  1614. "You have already activated $Swap as your swap partition. If you
  1615. choose to activate another swap partition, $Swap will be de-activated
  1616. as your swap partition. If you wish to have multiple swap partitions,
  1617. you can set them up after you've installed the system - this installer
  1618. can only handle one at a time. Answer \"no\" to the following question
  1619. if you wish to keep your present swap partition active.
  1620.  
  1621. Activate a new swap partition?" "Activate Another Swap Partition?"
  1622.         if [ $? -ne 0 ]; then return 1; fi
  1623.         swapoff $Swap
  1624.         Swap=""
  1625.     fi
  1626.  
  1627.     local partition
  1628.     partition=`select_not_mounted \
  1629. "Please select the partition to activate as a swap device." \
  1630. "Select Swap Partition" swap`
  1631.     if [ $? -ne 0 -o -z "$partition" ]; then return 1; fi
  1632.     yesNoBox \
  1633. "You have chosen to activate $partition as a swap device. This
  1634. will permanently erase any data on this partition. Are
  1635. you sure you want to do this?" "Are You Sure?"
  1636.     if [ $? -ne 0 ]; then return 1; fi
  1637.     echo $clear$bold"Activating swap partition..."$norm
  1638.     echo ""
  1639.     swapon $partition
  1640.     if [ $? -ne 0 ]; then
  1641.         write_it_down "The swap partition was not activated."
  1642.         return 1
  1643.     fi
  1644.     Swap=$partition
  1645.     return 0
  1646. }
  1647.  
  1648. get_cflag () {
  1649.     local partition=$1
  1650.  
  1651.     if [ ! -x /sbin/badblocks ]; then
  1652. #        not_on_lowmem "/sbin/badblocks not on lowmem disk"
  1653.         return 0
  1654.     fi
  1655.  
  1656.     yesNoBox \
  1657. "The system can scan the entire partition for un-readable disk
  1658. blocks and will mark any such bad blocks it finds so that they
  1659. will not be used. This requires that every block be read, and
  1660. thus could take a long time, but may save you trouble later.
  1661.  
  1662. Should the bad-block scan be performed on $partition?" \
  1663.     "Scan for Bad Blocks?"
  1664.     case $? in
  1665.         0) echo "-c";;
  1666.         1) echo "";;
  1667.         *) return 1;;
  1668.     esac
  1669.     return 0
  1670. }
  1671.  
  1672. interactive_shell() {
  1673.     cd /
  1674.     echo \
  1675. "You are running \"ash\", a Bourne-shell clone. The root filesystem is a
  1676. RAM disk or floppy. The hard disk filesystems are mounted on \"/target\".
  1677. The editor available to you on this floppy is \"ae\". It's very small
  1678. and easy to figure out - sorry but \"vi\" and \"emacs\" wouldn't fit. To
  1679. get an idea of what Unix utilities are available to you, run \"ls /bin
  1680. /sbin /usr/bin /usr/sbin\". Use the \"exit\" command to return to the
  1681. installation menu.
  1682. "
  1683.     /bin/sh
  1684.     cd /
  1685. }
  1686.  
  1687. main_menu ()
  1688. {
  1689.     title="Debian GNU/Linux Installation Main Menu"
  1690.     while true; do
  1691.         # Ignore interrupt in scripts, catch it in programs started by scripts.
  1692.         trap true 2 3
  1693.         infoBox \
  1694. "The installation program is determining the current state
  1695. of your system and the next installation step that should
  1696. be performed." \
  1697.          "Please Wait"
  1698.         if [ $? -ne 0 ]; then return 255; fi
  1699.  
  1700.         local next_action=true
  1701.         local previous_action=true
  1702.         local previous1_action=true
  1703.         local alternate_action=true
  1704.         local alternate1_action=true
  1705.  
  1706.         fdisk -l 2>/dev/null >/tmp/fdisk
  1707.  
  1708.         local linux_partitions="`scan_partitions ext2 minix`"
  1709.         local dos_partitions="`scan_partitions msdos`"
  1710.         local swap_partitions="`scan_partitions swap`"
  1711.  
  1712.         local found_root
  1713.         found_root=`find_root`
  1714.         if [ $? -ne 0 ]; then
  1715.             echo 
  1716.             msgBox \
  1717. "I had trouble checking the choice of root device. I'll assume that
  1718. the root fs is still \""$Root"\". Press enter to continue." "Problem"
  1719.         elif [ -z "$Root" ]; then
  1720.             Root="$found_root"
  1721.         elif [ "$Root" != "$found_root" ]; then
  1722.             msgBox \
  1723. "The root device has changed unexpectedly, from \""$Root"\" to
  1724. \""$found_root"\". Press enter to continue." "Root File System has Changed"
  1725.             Root="$found_root"
  1726.         fi
  1727.  
  1728.         echo "menu \\" > $TempFile
  1729.  
  1730.         if [ ! -f /etc/kbd/default.map -a -x /bin/loadkeys ]; then
  1731.             next_action=configure_keyboard
  1732.             alternate_action=partition_disk
  1733.             cat >> $TempFile << EOF
  1734. " Your keyboard has not yet been configured.
  1735. Please select \\"Next\\" from the menu to configure the keyboard." "$title" \\
  1736.             "Next" "Configure the Keyboard" \\
  1737.             "Alternate" "Partition a Hard Disk" \\
  1738. EOF
  1739.         elif [ -z "$Swap" -a -z "$swap_partitions" ]; then
  1740.             # No "Linux swap" partitions have been created.
  1741.             next_action=partition_disk
  1742.             alternate_action=no_swap
  1743.             cat >> $TempFile << EOF
  1744. " There are no \\"Linux swap\\" partitions present on the system. A
  1745. swap partition is necessary to provide virtual memory for
  1746. Linux. Please select \\"Next\\" from the menu to partition your hard
  1747. disk. Use the partitioning program to add \\"Linux native\\" and
  1748. \\"Linux swap\\" partitions to your disks." "$title" \\
  1749.             "Next" "Partition a Hard Disk" \\
  1750.             "Alternate" "Do Without a Swap Partition" \\
  1751. EOF
  1752.         elif [ -z "$linux_partitions" ]; then
  1753.             # No "Linux native" partitions have been created.
  1754.             next_action=partition_disk
  1755.             cat >> $TempFile << EOF
  1756. "There are no \\"Linux native\\" partitions present on the system.
  1757. You must create at least one \"Linux native\" partition to hold the
  1758. root filesystem, and you may create additional ones. Please select \\"Next\\"
  1759. from the menu to partition your hard disk. Use the partitioning
  1760. program to add \\"Linux native\\" partitions to your disks." \\
  1761.             "$title" \\
  1762.             "Next" "Partition a Hard Disk" \\
  1763. EOF
  1764.         elif [ -z "$Swap" ]; then
  1765.             # The swap partition has not been initialized and activated.
  1766.             next_action=init_swap
  1767.             alternate_action=activate_swap
  1768.             alternate1_action=no_swap
  1769.             previous_action=partition_disk
  1770.             cat >> $TempFile << EOF
  1771. "There are \\"Linux native\\" and \\"Linux swap\\" partitions
  1772. present on your system. The next step would be to initialize
  1773. and activate a swap partition to provide virtual memory to your
  1774. system. If you have not finished partitioning your disks or wish to
  1775. change the partitions, please select \\"Previous\\" from the menu
  1776. to partition them. If you are satisfied with your partitions,
  1777. please select \\"Next\\" from the menu to initialize and activate
  1778. your swap partition, or \\"Alternate\\" to activate a
  1779. previously-initialized swap partition. If you absolutely insist on
  1780. doing without a swap partition, select \\"Alternate1\\"." "$title" \\
  1781.             "Next" "Initialize and Activate the Swap Partition" \\
  1782.             "Alternate" "Activate a Previously-Initialized Swap Partition" \\
  1783.             "Alternate1" "Do Without a Swap Partition" \\
  1784.             "Previous" "Partition a Hard Disk" \\
  1785. EOF
  1786.         elif [ -z "$Root" ]; then
  1787.             # The root partition has not been mounted.
  1788.             next_action=init_linux
  1789.             alternate_action=mount_any
  1790.             cat >> $TempFile << EOF
  1791. "There are \\"Linux native\\" partitions present on your system but
  1792. none are mounted. You must mount a root filesystem, and you may mount
  1793. other filesystems, before installing the system. If you have just created
  1794. the partitions, you must initialize them before you can mount them. Please
  1795. select \\"Next\" to initialize and mount a Linux partition, or
  1796. \\"Alternate\\" to mount a previously-initialized partition." \\
  1797.             "$title" \\
  1798.             "Next" "Initialize a Linux Partition" \\
  1799.             "Alternate" "Mount a Previously-Initialized Partition" \\
  1800. EOF
  1801.         elif [ ! -f /target/vmlinuz \
  1802.                 -o ! -d /target/lib/modules/*/net ]; then
  1803.             # The operating system kernel and the modules
  1804.             # have not been installed.
  1805.             next_action=extract_kernel_and_modules
  1806.             alternate_action=init_linux
  1807.             alternate1_action=mount_any
  1808.             cat >> $TempFile << EOF
  1809. "You've mounted your root filesystem. You may initialize and mount
  1810. additional filesystems, or you may go on to install the 
  1811. operating system kernel and the modules." "$title" \\
  1812.             "Next" "Install Operating System Kernel and Modules" \\
  1813.             "Alternate" "Initialize a Linux Partition" \\
  1814.             "Alternate1" "Mount a Previously-Initialized Partition" \\
  1815. EOF
  1816.         elif [ ! -f /target/etc/modules ]; then
  1817.             # The modules have not been configured.
  1818.             next_action=configure_drivers
  1819.             cat >> $TempFile << EOF
  1820. "You've installed the operating system kernel and the modules.
  1821. Please select \\"Next\\" to configure the device driver modules." "$title" \\
  1822.             "Next" "Configure Device Driver Modules" \\
  1823. EOF
  1824.         elif [ ! -f /target/etc/hostname ]; then
  1825.             # The network has not been configured.
  1826.             next_action=configure_network
  1827.             cat >> $TempFile << EOF
  1828. "You've configured the base system but not the network.
  1829. Please select \\"Next\\" to configure the network." "$title" \\
  1830.             "Next" "Configure the Network" \\
  1831. EOF
  1832.         elif [ ! -f /target/sbin/init ]; then
  1833.             # The base system has not been installed.
  1834.             next_action=extract_base
  1835.             cat >> $TempFile << EOF
  1836. "You've configured the device driver modules.
  1837. Please select \\"Next\\" to install the base system." "$title" \\
  1838.             "Next" "Install the Base System" \\
  1839. EOF
  1840.         elif [ -f /target/sbin/unconfigured.sh ]; then
  1841.             # The base system has not been configured.
  1842.             next_action=configure_base
  1843.             cat >> $TempFile << EOF
  1844. "You've installed the base system and the operating system kernel.
  1845. Please select \\"Next\\" to configure the base system." "$title" \\
  1846.             "Next" "Configure the Base System" \\
  1847. EOF
  1848.         elif [ -z "$CreatedBootFloppy" -a -z "$InstalledLILO" ]; then
  1849.             next_action=make_bootable
  1850.             alternate_action=make_boot_floppy
  1851.             alternate1_action=reboot_system
  1852.             cat >> $TempFile << EOF
  1853. "You will either boot Linux from a floppy disk, or you will have it
  1854. boot from the hard disk when your system is turned on.
  1855. Please select \\"Next\\" to make Linux bootable the hard disk, select
  1856. \\"Alternate\\" to make a boot floppy, or select \\"Alternate1\\" to
  1857. reboot the system." \\
  1858.             "$title" \\
  1859.             "Next" "Make Linux Bootable Directly From Hard Disk" \\
  1860.             "Alternate" "Make a Boot Floppy" \\
  1861.             "Alternate1" "Reboot the System" \\
  1862. EOF
  1863.         elif [ -z "$CreatedBootFloppy" ]; then
  1864.             # The boot floppy has not been created.
  1865.             next_action=make_boot_floppy
  1866.             alternate_action=reboot_system
  1867.             cat >> $TempFile << EOF
  1868. "You've built your system. You should build a boot floppy that will
  1869. start the system just in case it doesn't start directly from the hard
  1870. disk. Please select \\"Next\\" to build the boot floppy." \\
  1871.             "$title" \\
  1872.             "Next" "Make a Boot Floppy" \\
  1873.             "Alternate" "Reboot the System" \\
  1874. EOF
  1875.         else
  1876.             # Nothing left to do but reboot the system.
  1877.             next_action=reboot_system
  1878.             cat >> $TempFile << EOF
  1879. "You've built your system and boot floppy. The moment of truth
  1880. approaches!  Please select \\"Next\\" to reboot the system." "$title" \\
  1881.             "Next" "Reboot The System" \\
  1882. EOF
  1883.         fi
  1884.         
  1885. cat >>$TempFile << EOF
  1886.         " " " " \\
  1887.         "A" "Configure the Keyboard" \\
  1888.         "B" "Partition a Hard Disk" \\
  1889.         "C" "Initialize and Activate a Swap Partition" \\
  1890.         "D" "Activate a Previously-Initialized Swap Partition" \\
  1891.         "E" "Do Without a Swap Partition" \\
  1892.         "F" "Initialize a Linux Partition" \\
  1893.         "G" "Mount a Previously-Initialized Partition" \\
  1894.         "H" "Un-Mount a Partition" \\
  1895.         "I" "Install Operating System Kernel and Modules" \\
  1896.         "J" "Install the Base System" \\
  1897.         "L" "Configure Device Driver Modules" \\
  1898.         "M" "Configure the Base System" \\
  1899.         "N" "Configure the Network" \\
  1900.         "O" "Make Linux Bootable Directly From Hard Disk" \\
  1901.         "P" "Make a Boot Floppy" \\
  1902.         "Q" "Reboot The System" \\
  1903.         "R" "View the Partition Table" \\
  1904.         "S" "Execute a Shell"
  1905. EOF
  1906.  
  1907.         local action
  1908.         action="`. $TempFile`"
  1909.         if [ $? -ne 0 -o -z "$action" ]; then continue; fi
  1910.         case $action in
  1911.         Next) $next_action;;
  1912.         Alternate) $alternate_action;;
  1913.         Alternate1) $alternate1_action;;
  1914.         Previous) $previous_action;;
  1915.         Previous1) $previous1_action;;
  1916.         A) configure_keyboard;;
  1917.         B) partition_disk;;
  1918.         C) init_swap;;
  1919.         D) activate_swap;;
  1920.         E) no_swap;;
  1921.         F) init_linux;;
  1922.         G) mount_any;;
  1923.         H) unmount_any;;
  1924.         I) extract_kernel_and_modules;;
  1925.         J) extract_base;;
  1926.         L) configure_drivers;;
  1927.         M) configure_base;;
  1928.         N) configure_network;;
  1929.         O) make_bootable;;
  1930.         P) make_boot_floppy;;
  1931.         Q) reboot_system;;
  1932.         R) view_partitions;;
  1933.         S) interactive_shell;;
  1934.         *) unreachable ;;
  1935.         esac
  1936.     done
  1937. }
  1938.  
  1939. write_boot_floppy ()
  1940. {
  1941.     local device="$1"
  1942.     if [ "$Arch2" = Amiga ]; then
  1943.         echo $bold"Creating the boot floppy is still not possible for Amiga."$norm
  1944.         echo ""
  1945.         return 0
  1946.     fi
  1947.     echo $bold"Please wait while the boot floppy is created."$norm
  1948.     echo ""
  1949.     umount $device 2>/dev/null
  1950.     umount /floppy 2>/dev/null
  1951.     fdflush $device
  1952.     if [ $? -ne 0 ]; then return 1; fi;
  1953.     local size
  1954.     size="`getfdprm $device`"
  1955.     if [ $? -ne 0 ]; then return 1; fi;
  1956.     size=`first $size`
  1957.     size=`math $size 2 div`
  1958.     if [ -x /usr/bin/superformat ]; then
  1959.         echo "Formatting the floppy..."
  1960.         superformat -d $device
  1961.         if [ $? -ne 0 ]; then return 1; fi;
  1962.     else
  1963.         echo "Hope that the floppy is formatted."
  1964.     fi
  1965.     echo "Creating a filesystem on the floppy..."
  1966.     zcat</target/usr/lib/syslinux/img""$size""k""$Arch2"".gz >$device
  1967.     if [ $? -ne 0 ]; then return 1; fi;
  1968.     echo "Mounting..."
  1969.     mount -t msdos $device /floppy
  1970.     if [ $? -ne 0 ]; then return 1; fi;
  1971.     echo "Copying the operating system kernel..."
  1972.     cp /target/vmlinuz /floppy/linux
  1973.     if [ $? -ne 0 ]; then umount /floppy; return 1; fi;
  1974.     sync
  1975.     echo "Writing the configuration files..."
  1976.     if [ "$Arch" = "m68k" -a "$Arch2" = "Atari" ]; then
  1977.         cat >/floppy/bootargs << EOF
  1978. -s -k a:\\linux root=$Root
  1979. EOF
  1980.     elif [ "$Arch" = "i386" ]; then
  1981.         cat >/floppy/syslinux.cfg << EOF
  1982. DISPLAY message.txt
  1983. TIMEOUT 40
  1984. PROMPT 1
  1985. DEFAULT linux
  1986. APPEND root=$Root ro
  1987. EOF
  1988.     fi
  1989.     if [ $? -ne 0 ]; then umount /floppy; return 1; fi;
  1990.     cat >/floppy/message.txt << EOF
  1991.  
  1992. Linux will be started automatically using the kernel on this floppy disk.
  1993. The root filesystem will be mounted from $Root .
  1994.  
  1995. When you start to type a command at the "boot: " prompt, the automatic
  1996. bootstrap process will stop. You may then type the name of the kernel to
  1997. use followed by any kernel options in the form option=value .
  1998.  
  1999. The kernel must be on the floppy disk in the first floppy drive. A kernel
  2000. file called "linux" was installed on this floppy when it was created. If you
  2001. wish to use a kernel on the hard disk, remove the floppy and press RESET.
  2002.  
  2003. EOF
  2004.     if [ $? -ne 0 ]; then umount /floppy; return 1; fi;
  2005.     echo "Done! Un-mounting the floppy"
  2006.     umount /floppy
  2007.     return 0
  2008. }
  2009.  
  2010. make_boot_floppy ()
  2011. {
  2012.     require_root
  2013.     if [ $? -ne 0 ]; then return 1; fi
  2014.  
  2015.     local device=/dev/fd0
  2016.     local designation=first
  2017.     local formatted
  2018.  
  2019.     if [ "`block_device / 2>/dev/null`" = /dev/fd0 ]; then
  2020.         yesNoBox \
  2021. "You are not using the RAM-disk, and thus the Installation Root
  2022. Disk in the first floppy drive can not be removed.
  2023.  
  2024. If your second floppy drive is the same size as the first one,
  2025. you can use it to write a boot floppy which you will place in
  2026. the first drive when you boot the system. Otherwise, you can
  2027. skip this step and use the Debian Rescue floppy to boot
  2028. your hard disk by typing \"linux root=$Root\" at the
  2029. \"boot: \" prompt, or you may be able to boot directly from the
  2030. hard disk.
  2031.  
  2032. Use the second floppy drive to create a boot floppy?" \
  2033.         "Use Second Floppy Drive?"
  2034.         if [ $? -ne 0 ]; then return 1; fi
  2035.         device=/dev/fd1
  2036.         designation=second
  2037.     fi
  2038.     if [ ! -x /usr/bin/superformat ]; then
  2039.         formatted=", formatted"
  2040.     fi
  2041.     msgBox \
  2042. "Please place a blank$formatted floppy disk in the $designation
  2043. floppy disk drive, and press ENTER." "Change Disk"
  2044.     if [ $? -ne 0 ]; then return 1; fi
  2045.     echo -n $clear
  2046.     write_boot_floppy $device
  2047.     if [ $? -ne 0 ]; then
  2048.         write_it_down \
  2049. "Creation of a boot floppy failed. Please make sure that
  2050. the floppy was not write-protected, and that you put it
  2051. in the $designation drive. Try another floppy if the
  2052. problem persists."
  2053.         return 1
  2054.     fi
  2055.     CreatedBootFloppy=true
  2056.     return 0
  2057. }
  2058.  
  2059. run_lilo () {
  2060.     local boot=$1
  2061.  
  2062.     echo "$clear$bold\
  2063. Running LILO to make the kernel able to boot from the hard disk without a
  2064. boot floppy...$norm"
  2065.     echo ""
  2066.     cat >/target/etc/lilo.conf << EOF
  2067. boot=$boot
  2068. root=$Root
  2069. compact
  2070. install=/boot/boot.b
  2071. map=/boot/map
  2072. vga=normal
  2073. delay=20
  2074. image=/vmlinuz
  2075. label=Linux
  2076. read-only
  2077. EOF
  2078.     if [ $? -ne 0 -o -z "$boot" ]; then return 1; fi
  2079.     (export LD_LIBRARY_PATH="/target/lib:/target/usr/lib"; \
  2080.      /target/sbin/lilo -r /target >/dev/null)
  2081.     return $?
  2082. }
  2083.  
  2084. install_mbr () {
  2085.     local device=`echo $1 | sed -e 's/[0-9]$//'`
  2086.  
  2087.     yesNoBox \
  2088. "A master boot record is required to boot the system.
  2089. If you are already using a boot manager, and want to
  2090. keep it, answer \"no\" to the following question. If you
  2091. don't know what a boot manager is or whether you have
  2092. one, answer \"yes\".
  2093.  
  2094. Install a master boot record on $device""?" "Create Master Boot Record?"
  2095.  
  2096.     if [ $? -eq 0 ]; then
  2097.         cp /target/boot/mbr.b $device
  2098.         if [ $? -ne 0 ]; then return 1; fi
  2099.     fi
  2100.     return 0
  2101. }
  2102.  
  2103. set_boot_default () {
  2104.     local device=`echo $1 | sed -e 's/[0-9]$//'`
  2105.     local partition=`echo $1 | sed -e 's/^[^0-9]*//'`
  2106.  
  2107.     yesNoBox \
  2108. "If you want the Debian system to boot automatically from the
  2109. hard disk when you turn your system on, answer \"yes\" to the
  2110. following question.  If you have another operating system
  2111. that you'd prefer to be the one that boots automatically,
  2112. answer \"no\".
  2113.  
  2114. Boot the Debian system on $1 as the default?" \
  2115.     "Make Linux the Default Boot Partition?"
  2116.     if [ $? -eq 0 ]; then
  2117.         (export LD_LIBRARY_PATH="/target/lib:/target/usr/lib"; \
  2118.         /target/sbin/activate $device $partition)
  2119.         if [ $? -ne 0 ]; then return 1; fi
  2120.     fi
  2121.     return 0
  2122. }
  2123.  
  2124. make_bootable () {
  2125.     local boot
  2126.     local status=0
  2127.  
  2128.     if [ "$Arch" = "m68k" ]; then
  2129.         write_it_down \
  2130. "Installing LILO is not yet not possible for linux-m68k."
  2131.     else
  2132.         first_disk=`cat /tmp/fdisk | \
  2133.             ( read foo ; read foo; set -- $foo ; echo $2) | \
  2134.             sed -e 's,:,,'`
  2135.         case $Root in
  2136.         ${first_disk}*)
  2137.             case $Root in
  2138.             /dev/?da1|/dev/?da2|/dev/?da3|/dev/?da4)
  2139.                 boot=$Root
  2140.                 ;;
  2141.             *)
  2142.                 boot="`scan_partitions extended`"
  2143.                 if [ -z "$boot" ]; then
  2144.                     write_it_down "Couldn't find extended partition"
  2145.                     return 1
  2146.                 fi
  2147.                 boot=`first $boot`
  2148.                 ;;
  2149.             esac
  2150.  
  2151.             run_lilo $boot
  2152.             status=$?
  2153.             if [ $status -ne 0 ]; then
  2154.                 write_it_down \
  2155. "LILO wasn't able to install. You'll still be able to boot
  2156. your system if you create a boot floppy, but it won't be able
  2157. to boot without a floppy.
  2158.  
  2159. The most common reason for LILO to fail is an over-large
  2160. root (\"/\") partition. LILO is unable to load any block
  2161. of the kernel from a disk cylinder numbered higher than 1023.
  2162. This is often a problem with disks larger than a Gigabyte
  2163. (1024 MB) or so. One way to solve the problem is to make a
  2164. separate \"/\" and \"/usr\" partition, so that the
  2165. entire \"/\" partition will be below the 1023rd cylinder."
  2166.                 return 1
  2167.             fi
  2168.             if [ $status -eq 0 ]; then
  2169.                 install_mbr $boot
  2170.                 status=$?
  2171.             fi
  2172.             if [ $status -eq 0 ]; then
  2173.                 set_boot_default $boot
  2174.                 status=$?
  2175.             fi
  2176.             ;;
  2177.         *)
  2178.             write_it_down \
  2179. "Currently it is impossible to boot from the second harddisk.
  2180. Please boot the system using the rescue boot method and configure
  2181. LILO manually."
  2182.             run_lilo ""
  2183.             return 0
  2184.         esac
  2185.  
  2186.     fi
  2187.     InstalledLILO=true
  2188.     return $status
  2189. }
  2190.  
  2191. mount_any () {
  2192.     local partition
  2193.     partition=`select_not_mounted \
  2194.      "Please select the partition to mount" "Select Partition" ext2 minix msdos`
  2195.     if [ $? -ne 0 -o -z "$partition" ]; then return 1; fi
  2196.     mount_partition $partition
  2197.     return $?
  2198. }
  2199.  
  2200. unmount_any () {
  2201.     local partitions
  2202.     partitions="`mounted_partitions`"
  2203.     if [ $? -ne 0 -o -z "$partitions" ]; then
  2204.         msgBox \
  2205. "$partitions No mounted partitions were detected." \
  2206.         "Problem"
  2207.         return 1
  2208.     fi
  2209.     cat >$TempFile <<EOF
  2210.     menu \\
  2211.      "Select the partition to un-mount." \\
  2212.      "Select Partition" \\
  2213. EOF
  2214.     local index=0
  2215.     for p in $partitions; do
  2216.         index=`math $index 1 add`
  2217.         echo -n " "$p" " >>$TempFile
  2218.         echo " \"\" \\" >>$TempFile
  2219.     done
  2220.     echo "">>$TempFile
  2221.     local partition
  2222.     partition="`. $TempFile`"
  2223.     if [ $? -ne 0 -o -z "$partition" ]; then return 1; fi
  2224.     unmount_partition $partition
  2225.     return $?
  2226. }
  2227.  
  2228. unmount_partition () {
  2229.     local partition="$1"
  2230.  
  2231.     umount $partition
  2232.     if [ $? -ne 0 ]; then
  2233.         msgBox \
  2234. "$partition could not be un-mounted. This could mean you
  2235. have another process running in a directory on $partition,
  2236. or you have another filesystem mounted on a mount point
  2237. on $partition." "Problem"
  2238.         return 1
  2239.     fi
  2240.     if [ $partition = "$Root" ]; then
  2241.         Root=""
  2242.     fi
  2243.     return 0
  2244. }
  2245.  
  2246. mounted_partitions () {
  2247.     local partitions
  2248.     partitions="`< /etc/mtab sed -e 's/[     ].*$//' -e '/proc$/d' \
  2249.      -e '/ramdisk0$/d' -e '/ram$/d' `"
  2250.     if [ $? -ne 0 -o -z "$partitions" ]; then return 1; fi
  2251.     # Reverse the partitions from the mount-table order, as this is the order
  2252.     # in which they would be un-mounted.
  2253.     echo $Swap `reverse "$partitions"`
  2254.     return 0
  2255. }
  2256.  
  2257. mount_partition () {
  2258.     local device="$1"
  2259.     local type
  2260.     type=`partition_to_fstype $device`
  2261.     if [ $? -ne 0 ]; then
  2262.         msgBox "$device has an unrecognised filesystem type." \
  2263.             "Problem"
  2264.         return 1
  2265.     fi
  2266.     case $type in
  2267.         ext2|msdos)
  2268.         ;;
  2269.         *)
  2270.         msgBox "$device filesystem type '$type' is not native Linux or DOS." \
  2271.             "Problem"
  2272.         return 1;;
  2273.     esac
  2274.     if [ -z "$Root" ]; then
  2275.         yesNoBox \
  2276. "You must mount your root filesystem (\"/\") before you can
  2277. mount any other filesystems. Would you like to mount
  2278. $device as the root filesystem?" "Mount as the Root Filesystem?"
  2279.         if [ $? -ne 0 ]; then return 1; fi
  2280.         local mount_point=/
  2281.         local real_mount_point=/target
  2282.     else
  2283.         if [ ! -d /target/usr ]; then
  2284.             local prototype=/usr
  2285.         elif [ "`block_device /target/usr 2>/dev/null`" = $Root ]; then
  2286.             local prototype=/usr
  2287.         elif [ ! -d /target/var ]; then
  2288.             local prototype=/var
  2289.         elif [ "`block_device /target/var 2>/dev/null`" = $Root ]; then
  2290.             local prototype=/var
  2291.         elif [ ! -d /target/home ]; then
  2292.             local prototype=/home
  2293.         elif [ "`block_device /target/home 2>/dev/null`" = $Root ]; then
  2294.             local prototype=/home
  2295.         else
  2296.             local prototype=/
  2297.         fi
  2298.         local mount_point
  2299.         mount_point=`inputBox \
  2300. "Select the mount point for $device." "Select Mount Point" $prototype`
  2301.         if [ $? -ne 0 -o -z "$mount_point" ]; then return 1; fi
  2302.         local real_mount_point="/target$mount_point"
  2303.     fi
  2304.  
  2305.     echo -n $clear
  2306.     if [ ! -d $real_mount_point ]; then
  2307.         local mode
  2308.         case $real_mount_point in
  2309.         /target/tmp)
  2310.             mode=1777
  2311.             ;;
  2312.         *)
  2313.             mode=755
  2314.         esac
  2315.         mkdir -p -m $mode $real_mount_point 2>/dev/null >/dev/null
  2316.         if [ $? -eq 0 ]; then
  2317.             chown root.sys $real_mount_point
  2318.         fi
  2319.     fi
  2320.  
  2321.     echo -n $clear
  2322.     mount -t $type $device $real_mount_point
  2323.     if [ $? -ne 0 -o -n "$output" ]; then
  2324.         write_it_down "Mount of $device on $mount_point failed
  2325. $output"
  2326.         return 1
  2327.     fi
  2328.     if [ $mount_point = "/" ]; then
  2329.         Root=$device
  2330.     fi
  2331.     return 0
  2332. }
  2333.  
  2334. # XXX currently unused
  2335. # XXX PCMCIA currently  set in network configuration
  2336. select_drivers() {
  2337.     local choice
  2338.  
  2339.     choice="`checklist "Please select the hardware that you have" \
  2340. "Select special hardware" \
  2341. "SCSI" "SCSI adapters and devices" off \
  2342. "PCMCIA" "PCMCIA equipment" off`"
  2343.     for i in $choice; do
  2344.         case $i in
  2345.         \"SCSI\")
  2346.             # XXX load SCSI modules
  2347.             if [ "$revext" = lowmem ]; then
  2348.                 mount_and_check_floppy "" lowmemdrivers
  2349.                 modconf --source floppy \
  2350.                     --load-before scsi_mod \
  2351.                     --restrict-section scsi \
  2352.                     --load-after sd_mod
  2353.                 umount /floppy 2>/dev/null
  2354.             else
  2355.                 true
  2356.             fi
  2357.             ;;
  2358.         \"PCMCIA\")
  2359.             
  2360.             # XXX load PCMCIA
  2361. #            mount_and_check_floppy "" ${revext}drivers
  2362. #            modconf --source floppy --restrict-section pcmcia
  2363. #            umount /floppy 2>/dev/null
  2364.             pcmcia=true
  2365.             ;;
  2366.         *)
  2367.             unreachable
  2368.         esac
  2369.     done
  2370. }
  2371.  
  2372. partition_disk () {
  2373.     sync
  2374.     local status=0
  2375.     local disk
  2376.     disk="`select_drive`"
  2377.     if [ $? -ne 0 -o -z "$disk" ]; then return 1; fi
  2378.     local mounts="`match_list $disk \"\`mounted_partitions\`\"`"
  2379.     local swap_disk="`match_list $disk $Swap`"
  2380.     local dialog=""
  2381.     if [ -n "$mounts" ]; then
  2382.         dialog=\
  2383. "You have mounted
  2384. $mounts from disk $disk
  2385. If you choose to go ahead and re-partition $disk,
  2386. the filesystem(s) will be un-mounted, and you can re-mount
  2387. when you have finished partitioning the disk. If you change
  2388. a previously existing filesystem, you will have to re-initialize
  2389. that filesystem before you mount again, and any data you
  2390. installed on it will be erased.
  2391.  
  2392. "
  2393.     fi
  2394.     if [ -n "$swap_disk" ]; then
  2395.         dialog="$dialog""You have activated a swap partition on $Swap.
  2396. If you choose to go ahead and re-partition $disk,
  2397. your swap partition will be de-activated, and you
  2398. will have to re-initialize and/or re-activate the swap
  2399. partition after you have re-partitioned $disk.
  2400.  
  2401. "
  2402.     fi
  2403.     if [ -n "$mounts" -o -n "$swap_disk" ]; then
  2404.         dialog="$dialog""Re-partition the disk?"
  2405.         yesNoBox "$dialog" "Re-Partition the Disk?"
  2406.         if [ $? -ne 0 ]; then return 1; fi
  2407.     fi
  2408.     if [ -n "$mounts" ]; then
  2409.         for m in $mounts; do
  2410.             unmount_partition $m
  2411.             if [ $? -ne 0 ]; then return 1; fi
  2412.         done
  2413.     fi
  2414.     if [ -n "$swap_disk" ]; then
  2415.         swapoff $Swap
  2416.         Swap=""
  2417.     fi
  2418.     if [ -x /sbin/cfdisk ]; then
  2419.         cfdisk $disk
  2420.     else
  2421.         fdisk $disk
  2422.     fi
  2423.     return $?
  2424. }
  2425.  
  2426. reboot_system () {
  2427.     sync
  2428.  
  2429.     if [ $InstallationRootDevice = /dev/fd0 ]; then
  2430.         yesNoBox "Since you've booted from the first floppy drive without
  2431. using the RAM disk, please keep the Installation Root Disk
  2432. in the drive until the system reboots. Then remove it, and
  2433. press the <RESET> button on your system.
  2434.  
  2435. Reboot the system?" "Reboot the system?"
  2436.         if [ $? -ne 0 ]; then return 1; fi
  2437.     else
  2438.         yesNoBox "If you are ready to reboot the system, you should have the
  2439. boot floppy (if you created one) in the first floppy drive,
  2440. or no floppy in the first floppy drive if you want to boot
  2441. directly from the hard disk, or the Debian Rescue floppy
  2442. if you want to reboot the installation system.
  2443. Please take care of that before you answer \"yes\" to the following
  2444. question.
  2445.  
  2446. Reboot the system?" "Reboot the system?"
  2447.         if [ $? -ne 0 ]; then return 1; fi
  2448.     fi
  2449.  
  2450.     sync
  2451.     echo $clear$bold
  2452.     exec reboot
  2453.     exit 1
  2454. }
  2455.  
  2456. scan_partitions () {
  2457.     local types="$*"
  2458.     local partitions
  2459.     local i
  2460.     local j
  2461.     local all_partitions
  2462.     
  2463.     sed -n -e '/^\/dev\//p' </tmp/fdisk >/tmp/fdisk.scan_partitions
  2464.     all_partitions="`sed -e 's/[     ].*$//' </tmp/fdisk.scan_partitions `"
  2465.     rm -f /tmp/fdisk.scan_partitions
  2466.  
  2467.     if [ -n "${types}" ]; then
  2468.         for i in $all_partitions; do
  2469.             type=`partition_to_fstype $i`
  2470.             for j in ${types}; do
  2471.                 if [ "$type" = $j ]; then
  2472.                     partitions="$partitions $i"
  2473.                 fi
  2474.             done
  2475.         done
  2476.     else
  2477.         partitions="$all_partitions"
  2478.     fi
  2479.  
  2480.     if [ -z "$partitions" ]; then return 1; fi
  2481.     echo "$partitions"
  2482.     return 0
  2483. }
  2484.  
  2485. partition_to_fstype () {
  2486.     local type
  2487.  
  2488.     sed -n -e "s:^$1:$1:p" </tmp/fdisk >/tmp/fdisk.to_fstype
  2489.     type="`sed -e 's/.*[     ][     ]//g' </tmp/fdisk.to_fstype`"
  2490.     rm -f /tmp/fdisk.to_fstype
  2491.  
  2492.     case "$type" in
  2493.     "Linux native")
  2494.         echo ext2
  2495.         ;;
  2496.     "Linux swap")
  2497.         echo swap
  2498.         ;;
  2499.     Linux/MINIX)
  2500.         echo minix
  2501.         ;;
  2502.     Extended)
  2503.         echo extended
  2504.         ;;
  2505. # for Linux/m68k - Atari
  2506.     Minix)
  2507.         echo minix
  2508.         ;;
  2509.     *DOS*)
  2510.         echo msdos
  2511.         ;;
  2512.     *)
  2513.         return 1   
  2514.     esac
  2515.     echo -n . >/dev/tty
  2516.     return 0
  2517. }
  2518.  
  2519. # XXX does this work ?
  2520. select_drive () {
  2521.     
  2522.     local drives="`tryopen -w /dev/hd[a-z] /dev/sd[a-z] 2>/dev/null`"
  2523.     if [ -z "$drives" ]; then
  2524.         msgBox \
  2525. "No hard disk drives could be found. Make sure they are cabled
  2526. correctly and are turned on before the system is started. You
  2527. may have to change driver settings when you start the system
  2528. with a command at the \"boot:\" prompt, or you may have to load
  2529. a driver that is in a loadable module to solve this problem." "Problem"
  2530.         return 1;
  2531.     fi
  2532. cat >$TempFile <<EOF
  2533.     menu \\
  2534. "Select the drive to partition. SCSI drives are listed in disk ID
  2535. number order. Only drives that were connected and operating when
  2536. the system was started will show up in this display. CD-ROM drives
  2537. may be mis-identified as writable disk drives by this menu." \\
  2538.     "Select Disk Drive" \\
  2539. EOF
  2540.     local index=0
  2541.     for d in $drives; do
  2542.         index=`math $index 1 add`
  2543.         echo -n $d" " >>$TempFile
  2544.         local description=""
  2545.         case $d in
  2546.         /dev/hda)
  2547.             description="First drive on primary controller (not SCSI)."
  2548.             ;;
  2549.         /dev/hdb)
  2550.             description="Second drive on primary controller (not SCSI)."
  2551.             ;;
  2552.         /dev/hdc)
  2553.             description="First drive on secondary controller (not SCSI)."
  2554.             ;;
  2555.         /dev/hdd)
  2556.             description="Second drive on secondary controller (not SCSI)."
  2557.             ;;
  2558.         /dev/sda)
  2559.             description="Lowest-numbered SCSI drive."
  2560.             ;;
  2561.         /dev/sdb)
  2562.             description="Second-lowest-numbered SCSI drive."
  2563.             ;;
  2564.         /dev/sdc)
  2565.             description="Third-lowest-numbered SCSI drive."
  2566.             ;;
  2567.         /dev/sdd)
  2568.             description="Fourth-lowest-numbered SCSI drive."
  2569.             ;;
  2570.         /dev/sde)
  2571.             description="Fifth-lowest-numbered SCSI drive."
  2572.             ;;
  2573.         /dev/sdf)
  2574.             description="Sixth-lowest-numbered SCSI drive."
  2575.             ;;
  2576.         /dev/sdg)
  2577.             description="Seventh-lowest-numbered SCSI drive."
  2578.             ;;
  2579.         /dev/sdh)
  2580.             description="Eigth-lowest-numbered SCSI drive."
  2581.             ;;
  2582.         *)
  2583.             unreachable
  2584.         esac
  2585.         echo " \"$description\" \\" >>$TempFile
  2586.     done
  2587.     echo "">>$TempFile
  2588.     . $TempFile
  2589.     if [ $? -ne 0 ]; then return 1; fi
  2590. }
  2591.  
  2592. select_not_mounted () {
  2593.     local message="$1"
  2594.     local title="$2"
  2595.     shift 2
  2596.     local types="$*"
  2597.     
  2598.     local partitions="`scan_partitions $types`"
  2599.     local in_use="`mounted_partitions`"
  2600.     partitions="`exclude "$in_use" "$partitions"`"
  2601.     if [ -z "$partitions" ]; then
  2602.         if [ -z "$types" ]; then
  2603.             msgBox \
  2604. "No partitions that had not
  2605. already been mounted were detected." "Problem"
  2606.         else
  2607.             msgBox \
  2608. "No \"$types\" partitions that had not
  2609. already been mounted were detected." "Problem"
  2610.         fi
  2611.         return 1
  2612.     fi
  2613.     cat >$TempFile <<EOF
  2614.     menu \\
  2615.      "$message" \\
  2616.      "$title" \\
  2617. EOF
  2618.     local index=0
  2619.     for p in $partitions; do
  2620.         index=`math $index 1 add`
  2621.         echo -n " "$p" " >>$TempFile
  2622.         echo " \"\" \\" >>$TempFile
  2623.     done
  2624.     echo "">>$TempFile
  2625.     local partition
  2626.     partition="`. $TempFile`"
  2627.     local status=$?
  2628.     if [ $status -ne 0 -o -z "$partition" ]; then return 1; fi
  2629.     echo $partition
  2630.     return 0
  2631. }
  2632.  
  2633. view_partitions () {
  2634.   (fdisk -l 2>&1)|textBox "Partition Table"
  2635. }
  2636.  
  2637. write_fstab () {
  2638.     cat > /target/etc/fstab <<EOF
  2639. # /etc/fstab: static file system information.
  2640. #
  2641. # <file system>     <mount point>   <type>  <options>   <dump>  <pass>
  2642. $Root               /               ext2    defaults    0       1
  2643. EOF
  2644.     if [ $? -ne 0 ]; then return 1; fi
  2645.  
  2646.     if [ -n "$Swap" -a "$swap" != "None" ]; then
  2647.     echo \
  2648.      "$Swap               none            swap    sw          0       0" \
  2649.      >> /target/etc/fstab
  2650.         if [ $? -ne 0 ]; then return 1; fi
  2651.     fi
  2652.  
  2653.     echo "proc                /proc           proc    defaults    0       0" \
  2654.      >> /target/etc/fstab
  2655.     if [ $? -ne 0 ]; then return 1; fi
  2656.  
  2657.     < /etc/mtab sed -n '/target\//p' | sed -e 's/target\///' -e 's/ /   /g' \
  2658.      -e 's/ 0   0/  0   2/' -e 's/  rw  /   defaults    /' >> /target/etc/fstab
  2659.     if [ $? -ne 0 ]; then return 1; fi
  2660.  
  2661.     return 0;
  2662. }
  2663.  
  2664. # List-processing functions for the shell.
  2665.  
  2666. # Exclude the members of the first from the second list. Write the result
  2667. # to stdout.
  2668. exclude () {
  2669.     local exclude="$1"
  2670.     local members="$2"
  2671.     local result=""
  2672.  
  2673.     if [ -z "$members" ]; then
  2674.         return 0
  2675.     fi
  2676.     if [ -z "$exclude" ]; then
  2677.         echo "$members"
  2678.         return 0
  2679.     fi
  2680.  
  2681.     for m in $members; do
  2682.         local add_to_set=1
  2683.         for e in $exclude; do
  2684.             if [ $m = $e ]; then
  2685.                 add_to_set=0
  2686.                 break
  2687.             fi
  2688.         done
  2689.         if [ $add_to_set -eq 1 ]; then
  2690.             result="$result $m"
  2691.         fi
  2692.     done
  2693.     echo $result
  2694.     return 0
  2695. }
  2696.  
  2697. # Search for a pattern in a list.
  2698. match_list () {
  2699.     local pattern="`echo \"$1\" | sed -e 's:/:\\\/:g'`"
  2700.     local candidates="$2"
  2701.     local matches=""
  2702.     local match
  2703.  
  2704.     for c in $candidates; do
  2705.         match=`echo $c | sed -n -e "/$pattern/p"`
  2706.         if [ $? -eq 0 -a -n "$match" ]; then
  2707.             matches="$matches $c"
  2708.         fi
  2709.     done
  2710.     echo $matches | sed -e 's:\\::g'
  2711.     return 0
  2712. }
  2713.  
  2714. # Reverse a list.
  2715. reverse () {
  2716.     local reversed=""
  2717.     for p in ""$@; do
  2718.         reversed="$p $reversed"
  2719.     done
  2720.     echo $reversed
  2721. }
  2722.  
  2723. is_root_a_floppy () {
  2724.     if [ "$InstallationRootDevice" = /dev/fd0 \
  2725.      -o "$InstallationRootDevice" = /dev/fd1 ]; then
  2726.         msgBox "You have bootstrapped the Installation Root Disk without
  2727. using the RAM disk. If this is a low-memory installation,
  2728. that's OK, but the installation is going to run a whole
  2729. lot slower this way. If you didn't intend to boot without
  2730. the RAM disk, it probably happened because you didn't have
  2731. to root floppy inserted when the system first asked for it
  2732. at boot time. You might want to reboot with the RAM disk
  2733. if that's the case." "No RAM Disk?"
  2734.     fi
  2735.     return 0
  2736. }
  2737.  
  2738. configure_drivers () {
  2739.     require_root
  2740.     if [ $? -ne 0 ]; then return 1; fi
  2741.  
  2742.     if [ -d /lib/modules ]; then
  2743.         mv /lib/modules /lib/modules.old
  2744.     fi
  2745.     rm -f /lib/modules
  2746.     (cd /lib; ln -s /target/lib/modules .)
  2747.  
  2748.     depmod -a
  2749.     modconf --run-shell cdromsymlink
  2750.  
  2751.     if [ ! -f /target/etc/modules ]; then
  2752.         mkdir /target/etc
  2753.         cp /etc/modules /etc/conf.modules /target/etc/
  2754.         rm -f /etc/modules /etc/conf.modules
  2755.         (cd /etc; ln -s /target/etc/modules .; \
  2756.             ln -s /target/etc/conf.modules . )
  2757.     fi
  2758.  
  2759.     return 0
  2760. }
  2761.  
  2762. release_notes () {
  2763.     if [ -f /release_notes ]; then
  2764.         textBox "Release Notes" < /release_notes
  2765.     fi
  2766.     return 0
  2767. }
  2768.  
  2769. echo "
  2770.  
  2771.  
  2772.  
  2773.  
  2774.  
  2775.  
  2776.  
  2777.  
  2778.  
  2779.  
  2780.  
  2781.  
  2782.  
  2783.  
  2784.  
  2785.  
  2786.  
  2787.  
  2788.  
  2789.  
  2790.  
  2791.  
  2792.  
  2793. "
  2794.  
  2795. color_or_monochrome
  2796. release_notes
  2797. is_root_a_floppy
  2798. main_menu
  2799.