#!/bin/sh # http://www.phys.ethz.ch/~franklin/Projects/dphys2/dbootstrap # - replaces /sbin/dbootstrap of install root floppy of Debian woody (3.0) # copyright ETH Zuerich Physics Departement, # use under either BSD or GPL license # author Neil Franklin, last modification 2004.02.13 # this script replaces the Debian /sbin/dbootstrap binary program # whose purpose is to install an basic Debian system # this replacement does so without asking lots of question - automatically # so that we can install 100s of machines without lots of work time usage # based on /derived from Debian boot-floppies-3.0.22 utilities/dbootstrap # ------ read in setup # this is shared by Makefile, makerescue, makeroot, dbootstrap . /etc/setup-dphys2 # ------ announce that we are running /bin/echo "============================================================" /bin/echo "*** dphys2 Debian 3.0 (woody) simple automated installer ***" /bin/echo "============================================================" /bin/echo if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # ------ host specific stuff, changes for each host - ask user at install # ensure that rescue floppy is re-inserted into drive, for fetching kernel /bin/echo "-> eject root floppy, so that later reboot from HD does not fail <-" /bin/echo # ask user for hostname and possibly IP address /bin/echo -n "enter hostname: " read CONF_HOSTNAME if [ x${CONF_DHCP} != xyes ] ; then /bin/echo -n "enter IP address: " read CONF_IPADDR fi /bin/echo "no further questions will be asked, now auto-installing ..." # ------ from here on code to do the actual actions, follows Debians menus # --- "Configure the Keyboard" menu # [all *.c and *() are relative to boot-floppies-3.0.22/utilities/dbootstrap] # replaces kbdconfig.c configure_keyboard() # set our standard keyboard /bin/echo "---------------------------------------------------" /bin/echo "*** Configure the Keyboard *** to ${CONF_KEYBD} ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi /bin/echo "KEYBD='${CONF_KEYBD}'" > /tmp/keybd_settings /bin/zcat /etc/keymaps.tgz | /bin/tar -xOf - ${CONF_KEYBD}.bmap | \ /sbin/loadkmap if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/cat /tmp/keybd_settings /bin/echo "--- end debug info ---" read dummy fi # --- auto-select disk drive type IDE vs SCSI we want to install on # replaces partition_config.c select_drive() # if user has set ${CONF_DISK} to /dev/??? use that, else auto-select if [ x${CONF_DISK} = x ] ; then /bin/echo "------------------------------------------------------" /bin/echo "*** Auto-Select Drive hda vs sda *** for CONF_DISK ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi if [ x`/bin/ls -1d /proc/ide/hd? | /bin/grep hda` != x ] ; then # we have got an bootable (hda) IDE disk in here CONF_DISK=/dev/hda else # else assume we have got an bootable (sda) SCSI disk in here CONF_DISK=/dev/sda fi # fixup setup, so /target/${SYS_ENDFIRSTRUN_ON_TARGET} can use ${CONF_DISK} /bin/echo >> /etc/setup-dphys2 /bin/echo >> /etc/setup-dphys2 /bin/echo "# ------ added by dbootstrap auto-select " >> /etc/setup-dphys2 /bin/echo >> /etc/setup-dphys2 /bin/echo "CONF_DISK=${CONF_DISK}" >> /etc/setup-dphys2 if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/echo "auto-selected ${CONF_DISK} for CONF_DISK" /bin/echo "--- end debug info ---" read dummy fi fi # --- set up IDE DMA so that installation is not slowed down # this is not part of the normal Debian installation prosess # use this to force IDE DMA usage on some stupid hd disk drives if [ x${CONF_DISK_IDEDMA} != x ] ; then /bin/echo "-----------------------------------------------------" /bin/echo "*** Force enabling of IDE DMA *** on ${CONF_DISK} ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi DRIVE=`/bin/echo ${CONF_DISK} | /usr/bin/cut -f 3 -d "/"` /bin/echo "using_dma:1" > /proc/ide/${DRIVE}/settings /bin/echo "io_32bit:1" > /proc/ide/${DRIVE}/settings if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/cat /proc/ide/${DRIVE}/settings /bin/echo "--- end debug info ---" read dummy fi fi # --- "Partition a Hard Disk" menu # replaces partition_config.c partition_disk() if [ x${CONF_SWAP_SIZE} = x -o x${CONF_SWAP_SIZE} = x0 ] ; then # no swap, use an very simple boot+root configuration /bin/echo "-----------------------------------------------------------" /bin/echo "*** Partition Hard Disk *** ${CONF_DISK} into boot+root ..." else # with swap, use an simple boot+swap+root configuration /bin/echo "----------------------------------------------------------------" /bin/echo "*** Partition Hard Disk *** ${CONF_DISK} into boot+swap+root ..." fi if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi if [ x${CONF_SWAP_SIZE} = x -o x${CONF_SWAP_SIZE} = x0 ] ; then # sfdisk is an command line driven fdisk, no menu, scriptable # our root disk builder adds it to the root file system # 16M Linux for /boot, no swap, rest Linux for / /sbin/sfdisk -uM ${CONF_DISK} << EOF ,16,L ,,L ; ; EOF else # 16M Linux for /boot, ${CONF_SWAP_SIZE} Swap for swap, rest Linux for / /sbin/sfdisk -uM ${CONF_DISK} << EOF ,16,L ,${CONF_SWAP_SIZE},S ,,L ; EOF fi # generate partition names if [ x${CONF_SWAP_SIZE} = x -o x${CONF_SWAP_SIZE} = x0 ] ; then PART_BOOT=${CONF_DISK}1 PART_ROOT=${CONF_DISK}2 else PART_BOOT=${CONF_DISK}1 PART_SWAP=${CONF_DISK}2 PART_ROOT=${CONF_DISK}3 fi # and number for "activate" PART_BOOT_NO=1 if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /sbin/fdisk -l ${CONF_DISK} /bin/echo "--- end debug info ---" read dummy fi # --- "Initialize and Activate a Swap Partition" menu # replaces partition_config.c init_swap() # if user wants no swap, nothing to do here if [ x${CONF_SWAP_SIZE} = x -o x${CONF_SWAP_SIZE} = x0 ] ; then # no usage of swap partition /bin/echo "------------------------------------------" /bin/echo "*** Skipping making Swap Partition *** ..." else # straightforward usage of our swap partition /bin/echo "---------------------------------------------------------------" /bin/echo "*** Initialize and Activate Swap Partition *** ${PART_SWAP} ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi /sbin/mkswap ${PART_SWAP} /sbin/swapon ${PART_SWAP} if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /usr/bin/free /bin/echo "--- end debug info ---" read dummy fi fi # --- "Initialize a Linux Partition" menu, twice # replaces partition_config.c init_linux() and init_ext() # first set up our root partition /bin/echo "---------------------------------------------------------------" /bin/echo "*** Initialize and Mount Partition *** root on ${PART_ROOT} ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi /sbin/mkfs.ext2 ${PART_ROOT} /bin/mount -t ext2 ${PART_ROOT} /target # second add our boot partition /bin/echo "*** Initialize and Mount Partition *** boot on ${PART_BOOT} ..." /bin/mkdir /target/boot /sbin/mkfs.ext2 ${PART_BOOT} /bin/mount -t ext2 ${PART_BOOT} /target/boot if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/mount /bin/echo "--- end debug info ---" read dummy fi # --- "Install Kernel and Driver Modules menu" # replaces extract_kernel.c extract_kernel_and_modules() and # choose_and_install() /bin/echo "--------------------------------------------------------------" /bin/echo "*** Install Kernel and Driver Modules menu *** from floppy ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # - subpart check_pending_config() # just duplicate Debian code effects, write config sofar exists to disk /bin/echo "* writing base config setting to disk ..." /bin/mkdir /target/root /bin/echo "BUILDTIME='2002.01.01-07:53+0000'" >/target/root/dbootstrap_settings /bin/cat /tmp/keybd_settings >> /target/root/dbootstrap_settings /bin/echo "LANG_INST='C'" >> /target/root/dbootstrap_settings /bin/echo "LANGUAGE_INST='en'" >> /target/root/dbootstrap_settings if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/cat /target/root/dbootstrap_settings /bin/echo "--- end debug info ---" read dummy fi ## - subpart extract_kernel.c install_floppy() # # install kernel, requires rescue floppy to be in drive after boot # *** do not do this here, wait until net working, then install from net *** # #/bin/echo "* installing kernel from rescue disk in /dev/fd0 ..." # ## -t auto gives warnings, -t msdos avoids them, but hangs with bf2.4 kernel #/bin/mount -r -t auto /dev/fd0 /floppy ## allow retries if it fails (say due to an wrong disk) #while [ ! -f /floppy/type.txt ] ; do # /bin/echo dbootstrap Error: no rescue floppy in /dev/fd0, insert proper # # give User chance for corrective action, possibly using 2nd console # read dummy #done #cd /floppy #./install.sh /target #cd / #/bin/umount /floppy # #if [ x${DEBUG_WAIT_STEP} = xyes ] ; then # /bin/echo "--- debug info ---" # /bin/ls -al /target /target/boot # /bin/echo "--- end debug info ---" # read dummy #fi # - subpart extract_kernel.c install_floppies() # install drivers, small selection instead of 4 disks, no disk jockey /bin/echo "* installing our small selection of drivers ..." /bin/mkdir /target/tmp; chown 0.3 /target/tmp; chmod 01777 /target/tmp /bin/mkdir /target/tmp/drivers; chown 0.3 /target/tmp/drivers; # here Debian fetches the 4 drivers archive disks to /target/drivers.tgz # we have already included an small drivers file on this root disk # because this is incomplete we will have to add all the rest later from net /bin/cp -p ${SYS_DRIVERSTGZ_ON_FLOPPY} /target/${SYS_DRIVERSTGZ_ON_TARGET} cd /target/tmp/drivers /bin/zcat /target/${SYS_DRIVERSTGZ_ON_TARGET} | /bin/tar -x ./install.sh /target cd / /bin/rm /target/${SYS_DRIVERSTGZ_ON_TARGET} if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -alR /target/lib/modules /bin/echo "--- end debug info ---" read dummy fi # - back from choose_and_install() do util.c frob_lib_modules() # from install system to use now installed modules /bin/echo "* using installed modules while install ..." /bin/rm -rf /lib/modules.old /bin/mv /lib/modules /lib/modules.old /bin/ln -s /target/lib/modules /lib/modules # - back from frob_lib_modules() /sbin/depmod -a if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -ald /lib/modules* /bin/echo "--- end debug info ---" read dummy fi # --- "Configure Device Driver Modules" menu # replaces baseconfig.c configure_drivers() # try to activate all our possible Ethernet drivers /bin/echo "-------------------------------------------------------------------" /bin/echo "*** Configure Device Driver Modules*** for our Ethernet drivers ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi /sbin/depmod -a /bin/echo /sbin/modprobe >/proc/sys/kernel/modprobe /usr/bin/test -f /target/etc/modules || /bin/cp -p /etc/modules /target/etc/ # here Debian uses GUI modconf to ask which drivers to install # we simply try through all our few pre-selected drivers # ***BUGFIX*** Debian only does this "cp" for s390, we need it also for x86 # perhaps this is a difference of modconf GUI vs --load-only mode /bin/cp -a /etc/modules.conf /target/etc/ for module in ${CONF_MODULESNET}; do modulebase=`/bin/echo $module | /usr/bin/cut -f 1 -d "."` /target/usr/sbin/modconf --target /target --libdir /tmp/drivers \ --load-only ${modulebase} done # then we add our driver line to /etc/modules /sbin/lsmod | /bin/grep -v ^Module | /bin/grep -v ^unix | \ /bin/grep -v ^af_packet | /usr/bin/cut -f 1 -d " " >> /target/etc/modules /bin/echo /bin/true >/proc/sys/kernel/modprobe if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/cat /target/etc/modules /sbin/lsmod /bin/echo "--- end debug info ---" read dummy fi # --- "Configure the Network" menu # replaces netconfig.c configure_network() # set network for system given up at top of script /bin/echo "--------------------------------------------------------" /bin/echo "*** Configure the Network *** for our network config ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # - subpart netconfig.c write_common_network() /bin/echo "* writing common net config files to disk ..." # this first part just sets up an network-less network config (only lo) /bin/mkdir /target/etc/network /bin/echo "${CONF_HOSTNAME}" > /target/etc/hostname /bin/echo "127.0.0.1 ${CONF_HOSTNAME}" > /target/etc/hosts /bin/echo "# /etc/network/interfaces --" \ "configuration file for ifup(8), ifdown(8)" \ > /target/etc/network/interfaces /bin/echo "" >> /target/etc/network/interfaces /bin/echo "# The loopback interface" >> /target/etc/network/interfaces /bin/echo "auto lo" >> /target/etc/network/interfaces /bin/echo "iface lo inet loopback" >> /target/etc/network/interfaces if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/cat /target/etc/hosts /bin/echo "---" /bin/cat /target/etc/network/interfaces if [ -f /target/etc/resolv.conf ] ; then /bin/echo "---" /bin/cat /target/etc/resolv.conf fi /bin/echo "--- end debug info ---" read dummy fi if [ x${CONF_DHCP} = xyes ] ; then # - subpart netconfig.c configure_network() /bin/echo "* getting network configuraton by DHCP ..." if [ -x /sbin/dhclient-2.2.x ] ; then /bin/echo "interface \"${CONF_IF}\" {" > /etc/dhclient.conf /bin/echo " send host-name \"${CONF_HOSTNAME}\";" >> /etc/dhclient.conf /bin/echo " }" >> /etc/dhclient.conf /sbin/dhclient-2.2.x -e -lf /tmp/dhcp.leases ${CONF_IF} else # Debian has this in their code, despite program not included :-) /sbin/pump -i ${CONF_IF} -h ${CONF_HOSTNAME} fi # - subpart netconfig.c write_dhcp_network() /bin/echo "* writing dynamic net config files to disk ..." # this adds config for ${CONF_IF}, using DHCP /bin/cp -p /etc/resolv.conf /target/etc/resolv.conf /bin/echo "# The first network card -" \ "this entry was created during the Debian/dphys2 installation" \ >> /target/etc/network/interfaces /bin/echo "auto ${CONF_IF}" >> /target/etc/network/interfaces /bin/echo "iface ${CONF_IF} inet dhcp" >> /target/etc/network/interfaces else # - subpart netconfig.c configure_static_network() and write_static_network() /bin/echo "* writing static net config files to disk ..." # this adds config for ${CONF_IF}, using static data /bin/echo "127.0.0.1 localhost" \ > /target/etc/hosts /bin/echo "${CONF_IPADDR} ${CONF_HOSTNAME}.${CONF_DOMAIN}" \ >> /target/etc/hosts /bin/echo "localnet ${CONF_NETWORK}" > /target/etc/networks /bin/echo "search ${CONF_DOMAIN}" > /target/etc/resolv.conf /bin/echo "nameserver ${CONF_NAMESERVER1}" >> /target/etc/resolv.conf if [ x${CONF_NAMESERVER2} != x ] ; then /bin/echo "nameserver ${CONF_NAMESERVER2}" >> /target/etc/resolv.conf fi if [ x${CONF_NAMESERVER3} != x ] ; then /bin/echo "nameserver ${CONF_NAMESERVER3}" >> /target/etc/resolv.conf fi if [ x${CONF_NAMESERVER4} != x ] ; then /bin/echo "nameserver ${CONF_NAMESERVER4}" >> /target/etc/resolv.conf fi /bin/echo "# The first network card -" \ "this entry was created during the Debian/dphys2 installation" \ >> /target/etc/network/interfaces /bin/echo "# (network, broadcast and gateway are optional)" >> /target/etc/network/interfaces /bin/echo "auto ${CONF_IF}" >> /target/etc/network/interfaces /bin/echo "iface ${CONF_IF} inet static" >> /target/etc/network/interfaces /bin/echo -e "\taddress ${CONF_IPADDR}" >> /target/etc/network/interfaces /bin/echo -e "\tnetmask ${CONF_NETMASK}" >> /target/etc/network/interfaces /bin/echo -e "\tnetwork ${CONF_NETWORK}" >> /target/etc/network/interfaces /bin/echo -e "\tbroadcast ${CONF_BROADCAST}" \ >> /target/etc/network/interfaces /bin/echo -e "\tgateway ${CONF_GATEWAY}" >> /target/etc/network/interfaces fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/cat /target/etc/hosts /bin/echo "---" /bin/cat /target/etc/network/interfaces if [ -f /target/etc/resolv.conf ] ; then /bin/echo "---" /bin/cat /target/etc/resolv.conf fi /bin/echo "--- end debug info ---" read dummy fi # - subpart netconfig.c activate_static_network() /bin/echo "* activating net config ..." /bin/rm /etc/resolv.conf /bin/ln -s /target/etc/resolv.conf /etc/resolv.conf /sbin/ifconfig lo 127.0.0.1 if [ x${CONF_DHCP} != xyes ] ; then # in case fo DHCP ${CONF_IF} already got configured above /sbin/ifconfig ${CONF_IF} down /sbin/ifconfig ${CONF_IF} ${CONF_IPADDR} netmask ${CONF_NETMASK} \ broadcast ${CONF_BROADCAST} /sbin/route add default gw ${CONF_GATEWAY} metric 1 fi if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /sbin/ifconfig /bin/echo "--- end debug info ---" read dummy fi # --- redo "Install Kernel and Driver Modules menu", now that net is running # this is not part of the normal Debian installation prosess /bin/echo "-----------------------------------------------------------" /bin/echo "*** Install Kernel and Driver Modules menu *** from net ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # - subpart extract_kernel.c install_floppy() # moved here from above, now that we have network, no rescue floppy needed # install kernel, requires network /bin/echo "* installing kernel from rescue floppy image from net ..." # fetch correct rescue floppy image file from the net, and "insert" it if [ x${CONF_KERNEL_OWN} != x ] ; then RESC="http://${CONF_OWNSERVER_KERNEL}/${CONF_OWNDIR_KERNEL}/${SYS_OWNRESCUE}" elif [ x${CONF_KERNEL_24} != x ] ; then RESC="http://${CONF_DEBSERVER}/${CONF_DEBDIR}/${SYS_DEBRESCUE_BF24}" else RESC="http://${CONF_DEBSERVER}/${CONF_DEBDIR}/${SYS_DEBRESCUE}" fi /usr/bin/wget -P /target ${RESC} # no /usr/bin/basename on root disk mini system, so emulate it here RESCBASE=${RESC} while [ x`echo ${RESCBASE} | grep '/'` != x ] ; do RESCBASE=`echo ${RESCBASE} | cut -f 2- -d '/'` done # -t auto gives warnings, -t msdos avoids them, but hangs with bf2.4 kernel /bin/mount -r -t auto -o loop /target/${RESCBASE} /floppy # allow retries if it fails (say due to an wrong disk) while [ ! -f /floppy/type.txt ] ; do /bin/echo dbootstrap Error: no rescue floppy in /dev/fd0, insert proper # give User chance for corrective action, possibly using 2nd console read dummy done cd /floppy ./install.sh /target cd / /bin/umount /floppy # "eject" rescue floppy image file rm /target/${RESCBASE} if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -al /target /target/boot /bin/echo "--- end debug info ---" read dummy fi # - subpart extract_kernel.c install_floppies() # redo install drivers, now full set of them, now that net is running /bin/echo "* installing drivers from drivers archive from net ..." # these directories still exit from first driver install #/bin/mkdir /target/tmp; chown 0.3 /target/tmp; chmod 01777 /target/tmp #/bin/mkdir /target/tmp/drivers; chown 0.3 /target/tmp/drivers; # here Debian fetches the 4 drivers disks to /target/drivers.tgz, but we # fetch the correct full drivers archive from the net if [ x${CONF_KERNEL_OWN} != x ] ; then DRV="http://${CONF_OWNSERVER_KERNEL}/${CONF_OWNDIR_KERNEL}/${SYS_OWNDRIVERS}" elif [ x${CONF_KERNEL_24} != x ] ; then DRV="http://${CONF_DEBSERVER}/${CONF_DEBDIR}/${SYS_DEBDRIVERS_BF24}" else DRV="http://${CONF_DEBSERVER}/${CONF_DEBDIR}/${SYS_DEBDRIVERS}" fi /usr/bin/wget -P /target ${DRV} # no /usr/bin/basename on root disk mini system, so emulate it here DRVBASE=${RESC} while [ x`echo ${DRVBASE} | grep '/'` != x ] ; do DRVBASE=`echo ${DRVBASE} | cut -f 2- -d '/'` done cd /target/tmp/drivers /bin/zcat /target/${DRVBASE} | /bin/tar -x ./install.sh /target cd / # get rid of drivers archive file /bin/rm /target/${DRVBASE} if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -al /target/lib/modules/* /bin/echo "--- end debug info ---" read dummy fi # - back from choose_and_install() do frob_lib_modules() # symlink is already set from first driver install #/bin/rm -rf /lib/modules.old #/bin/mv /lib/modules /lib/modules.old #/bin/ln -s /target/lib/modules /lib/modules # - back from frob_lib_modules() /sbin/depmod -a if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -ald /lib/modules* /bin/echo "--- end debug info ---" read dummy fi # --- "Install the Base System" menu # replaces main_menu.c main_menu_extract_base() and debootstrap_extract_base() # install base.tgz, fetching it from now running network, no floppies /bin/echo "------------------------------------------------" /bin/echo "*** Install the Base System *** from network ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # thankfully Debian put all this stuff into an separate program # so we can just run it unchanged # even more thankfully, as it is nearly unreadable code /bin/echo "* running debootstrap to install base.tzg ..." # test whether download works omitted: #/usr/bin/wget -q $SOURCE/dists/woody/Release # we get it via standard http, so no need to set up NFS to get it /usr/sbin/debootstrap --arch ${SYS_ARCH} woody /target \ http://${CONF_DEBSERVER}/${CONF_DEBDIR}/ /bin/echo "DEBIAN_MIRROR_HOSTNAME='${CONF_DEBSERVER}'" \ >> /target/root/dbootstrap_settings /bin/echo "DEBIAN_MIRROR_METHOD='http'" >> /target/root/dbootstrap_settings /bin/echo "DEBIAN_MIRROR_PATH='${CONF_DEBDIR}'" \ >> /target/root/dbootstrap_settings /bin/echo "DEBIAN_MIRROR_PORT='80'" >> /target/root/dbootstrap_settings /bin/echo "SUITE='testing'" >> /target/root/dbootstrap_settings /bin/mv /target/etc/inittab /target/etc/inittab.real /bin/cp -p /etc/inittab.install /target/etc/inittab if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/cat /target/root/dbootstrap_settings /bin/echo "--- end debug info ---" read dummy fi # - subpart baseconfig.c write_fstab() # surprising that they do this so late /bin/echo "* generating fstab ..." /bin/echo "# /etc/fstab: static file system information." > /target/etc/fstab /bin/echo "#" >> /target/etc/fstab /bin/echo -e \ "# \t\t\t\t\t\t\t" \ >> /target/etc/fstab # root /bin/echo -e "${PART_ROOT}\t/\t\text2\tdefaults,errors=remount-ro\t0\t1" \ >> /target/etc/fstab # swap, if user wants it if [ x${CONF_SWAP_SIZE} = x -o x${CONF_SWAP_SIZE} = x0 ] ; then /bin/echo -e "# no/zero swap partition selected" >> /target/etc/fstab else /bin/echo -e "${PART_SWAP}\tnone\t\tswap\tsw\t\t\t0\t0" >> /target/etc/fstab fi # proc /bin/echo -e "proc\t\t/proc\t\tproc\tdefaults\t\t\t0\t0" >> /target/etc/fstab # floppy and cdrom /bin/echo -e "/dev/fd0\t/floppy\t\tauto\tdefaults,user,noauto\t\t0\t0\n" \ >> /target/etc/fstab /bin/echo -e \ "/dev/cdrom\t/cdrom\t\tiso9660\tdefaults,ro,user,noauto\t\t0\t0\n" \ >> /target/etc/fstab # others, for us just /boot /bin/echo -e "${PART_BOOT}\t/boot\t\text2\tdefaults\t0\t2" >> /target/etc/fstab if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/cat /target/etc/fstab /bin/echo "--- end debug info ---" read dummy fi # - subpart baseconfig.c configure_base() # this is actually outdated code, but do it for safety /bin/echo "* tidying up unconfigured.sh ..." /bin/rm -f /target/sbin/unconfigured.sh if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -al /target /bin/echo "--- end debug info ---" read dummy fi # --- "Make System Bootable" menu # replaces bootconfig.c make_bootable() and run_lilo() # setup LILO to boot system /bin/echo "---------------------------------------------------------------" /bin/echo "*** Make System Bootable *** with LILO, mbr, boot partition ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # we are putting LILO in the MBR (unclean), because bug using mbr and in ROOT # the boot code does not get written (or written and then overwriten?) # and this is a single-OS system anyway, and its better for security anyway # lilo.conf is 1/4 size of this script, so don't generate it, use template file # replace template %PLACEHOLDER% place holders with entire actual lines if [ x${CONF_PASSWORD_LILO} != x ] ; then /bin/sed -e "s@%PART_BOOT%@boot=${CONF_DISK}@" \ -e "s@%PART_ROOT%@root=${PART_ROOT}@" \ -e "s@%PASSWORD%@password=${CONF_PASSWORD_LILO}@" \ -e "s@%RESTRICTED%@restricted@" \ ${SYS_LILOCONF_ON_FLOPPY} > /target/etc/lilo.conf else # user did not want an LILO password /bin/sed -e "s@%PART_BOOT%@boot=${CONF_DISK}@" \ -e "s@%PART_ROOT%@root=${PART_ROOT}@" \ -e "s@%PASSWORD%@# no password installed@" \ -e "s@%RESTRICTED%@# restricted if password were set@" \ ${SYS_LILOCONF_ON_FLOPPY} > /target/etc/lilo.conf fi # *** WARNING *** # this file must be chmod 600 because of LILO password in it /bin/chmod 600 /target/etc/lilo.conf /usr/sbin/chroot /target /sbin/lilo # activate boot partition export LD_LIBRARY_PATH=\"/target/lib:/target/usr/lib\"; \ /target/sbin/activate ${CONF_DISK} ${PART_BOOT_NO} if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /sbin/fdisk -l ${CONF_DISK} /bin/echo "--- end debug info ---" read dummy fi # --- fix up installed system so that 2nd boot stage has no dialogs # this is not part of the 1st stage Debian installation process # replaces the 2nd stage (after reboot) Debconf questions # fix up debconf database to prevent base-config dialogs /bin/echo "---------------------------------------------------------" /bin/echo "*** Fixing up debconf *** for no dialogs after reboot ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # debconf-preload is 1/2 size of this script, don't generate, use template file # replace template %PLACEHOLDER% place holders with actual content (no lines) /bin/sed -e "s@%SYS_DEBCONF_DB%@${SYS_DEBCONF_DB}@" \ -e "s@%CONF_TIMEZOME_AREA%@${CONF_TIMEZOME_AREA}@" \ -e "s@%CONF_TIMEZOME_PLACE%@${CONF_TIMEZOME_PLACE}@" \ -e "s@%CONF_PASSWORD_MD5%@${CONF_PASSWORD_MD5}@" \ -e "s@%CONF_PASSWORD_SHADOW%@${CONF_PASSWORD_SHADOW}@" \ -e "s@%CONF_PASSWORD_ROOT%@${CONF_PASSWORD_ROOT}@" \ -e "s@%CONF_PCMCIA_REMOVE%@${CONF_PCMCIA_REMOVE}@" \ -e "s@%CONF_DEBSERVER%@${CONF_DEBSERVER}@" \ -e "s@%CONF_DEBDIR%@${CONF_DEBDIR}@" \ -e "s@%CONF_PCMCIA_REMOVE%@${CONF_PCMCIA_REMOVE}@" \ -e "s@%CONF_USE_CONTRIB%@${CONF_USE_CONTRIB}@" \ -e "s@%CONF_USE_NON_FREE%@${CONF_USE_NON_FREE}@" \ -e "s@%CONF_USE_PROPOSED%@${CONF_USE_PROPOSED}@" \ -e "s@%CONF_DEBSERVER_NON_US%@${CONF_DEBSERVER_NON_US}@" \ -e "s@%CONF_DEBDIR_NON_US%@${CONF_DEBDIR_NON_US}@" \ -e "s@%SYS_DEBSUBDIR_NON_US%@${SYS_DEBSUBDIR_NON_US}@" \ -e "s@%CONF_DEBSERVER_SECURITY%@${CONF_DEBSERVER_SECURITY}@" \ -e "s@%CONF_DEBDIR_SECURITY%@${CONF_DEBDIR_SECURITY}@" \ -e "s@%SYS_DEBSUBDIR_SECURITY%@${SYS_DEBSUBDIR_SECURITY}@" \ -e "s@%CONF_DEBSERVER_LOCAL%@${CONF_DEBSERVER_LOCAL}@" \ -e "s@%CONF_DEBDIR_LOCAL%@${CONF_DEBDIR_LOCAL}@" \ -e "s@%SYS_DEBSUBDIR_LOCAL%@${SYS_DEBSUBDIR_LOCAL}@" \ ${SYS_PRELOAD_ON_FLOPPY} > /target/${SYS_PRELOAD_ON_TARGET} # *** WARNING *** # this file must be chmod 700 because of root password in it /bin/chmod 700 /target/${SYS_PRELOAD_ON_TARGET} /usr/sbin/chroot /target ${SYS_PRELOAD_ON_TARGET} if [ x${DEBUG_WAIT_DEL_PRELOAD} = xyes ] ; then /bin/echo "--- DEBUG: wait delete /target/${SYS_PRELOAD_ON_TARGET} ---" read dummy fi /bin/rm /target/${SYS_PRELOAD_ON_TARGET} if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -al /target/var/cache/debconf /bin/echo "--- end debug info ---" read dummy fi # --- silence debconf as far as possible, for automated installs # this is not part of the normal Debian installation process if [ x${CONF_SILENCE_DEBCONF} != x ] ; then # prevent questions while installing packages from woody-proposed-updates # this is also then active later when installing random stuff /bin/echo "--------------------------------------------------------------" /bin/echo "*** Silence Debconf *** for no questions while autoinstall ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi /usr/sbin/chroot /target << EOF # this script will run as part of second stage of install, from base-config # 01debconf, just after 00dbootstrap_settings, after Debian touched this SCRIPT_DEBCONF=/usr/lib/base-config/01debconf /bin/cat << EOF2 > \${SCRIPT_DEBCONF} #!/bin/sh -e # reconfigure debconf to not ask any questions # debconf access needs this, first action (may restart this script!) . /usr/share/debconf/confmodule # make base-config set up debconf to use defaults, without asking questions # get rid of as many dialogs and questions as possible # *NOTE* that we still need debconf-preload because base-config tricks us db_set debconf/priority critical db_set debconf/frontend noninteractive if [ x${DEBUG_LEAVE_BC_SCRIPTS} != xyes ] ; then /bin/rm \${SCRIPT_DEBCONF} fi exit 0 EOF2 /bin/chmod 755 \${SCRIPT_DEBCONF} if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -al \${SCRIPT_DEBCONF} /bin/echo "--- end debug info ---" read dummy fi EOF fi # --- "Initialize and Activate a Swap Partition" menu, the second time round # replaces partition_config.c init_swap() # if user wants an swapfile, use this, often instead of an swap partition # it is possible to use both partition and file if [ x${CONF_SWAP_FILE} != x ] ; then # straightforward usage of our dphys2-swapfile package /bin/echo "------------------------------------------------" /bin/echo "*** Get dphys2-swapfile ready to install *** ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi # copy the package file into the target system /bin/cp -p /${SYS_SWAPDEB_ON_FLOPPY}/dphys2-swapfile_*.deb \ /target/${SYS_SWAPDEB_ON_TARGET} /usr/sbin/chroot /target << EOF # this script will run as part of second stage of install, from base-config # 27swapfile, after 25pcmcia (base packages) and before 30pon (network) SCRIPT_SWAPFILE=/usr/lib/base-config/27swapfile /bin/cat << EOF2 > \${SCRIPT_SWAPFILE} #!/bin/sh -e # install dphys2-swapfile package /usr/bin/dpkg --install /${SYS_SWAPDEB_ON_TARGET}/dphys2-swapfile_*.deb # or should we archive this somewhere? but where? /bin/rm /${SYS_SWAPDEB_ON_TARGET}/dphys2-swapfile_*.deb if [ x${DEBUG_LEAVE_BC_SCRIPTS} != xyes ] ; then /bin/rm \${SCRIPT_SWAPFILE} fi exit 0 EOF2 /bin/chmod 755 \${SCRIPT_SWAPFILE} if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/ls -al \${SCRIPT_SWAPFILE} /bin/echo "--- end debug info ---" read dummy fi EOF fi # --- run user script at end of first install stage, for further automation # this is not part of the normal Debian installation process # give user chance to do further site specific automation if [ -f ${SYS_ENDFIRSTRUN_ON_FLOPPY} ] ; then /bin/echo "--------------------------------------------------" /bin/echo "*** Run user script *** for further automation ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi /bin/cp -p ${SYS_ENDFIRSTRUN_ON_FLOPPY} /target/${SYS_ENDFIRSTRUN_ON_TARGET} /bin/chmod a+x /target/${SYS_ENDFIRSTRUN_ON_TARGET} # so that ${SYS_ENDFIRSTRUN_ON_TARGET} can also be configured from same file /bin/cp -p /etc/setup-dphys2 /target/etc /usr/sbin/chroot /target ${SYS_ENDFIRSTRUN_ON_TARGET} if [ x${DEBUG_WAIT_DEL_EFR_SCRIPT} = xyes ] ; then /bin/echo "--- DEBUG: wait delete /target/${SYS_ENDFIRSTRUN_ON_TARGET} ---" read dummy fi /bin/rm /target/${SYS_ENDFIRSTRUN_ON_TARGET} /bin/rm /target/etc/setup-dphys2 if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" # not particularly sensible, should do something in endfirstrun script /bin/ls -al /target /bin/echo "--- end debug info ---" read dummy fi fi # --- "Reboot the System" menu # replaces reboot_system.c reboot_system() # reboot into 2nd stage of install /bin/echo "----------------------------------------------" /bin/echo "*** Reboot the System *** for second stage ..." if [ x${DEBUG_SLEEP} != x ] ; then /bin/sleep ${DEBUG_SLEEP} fi /bin/sync /bin/umount /instmnt /bin/cp -p /var/log/messages /target/var/log/installer.log if [ x${DEBUG_WAIT_STEP} = xyes ] ; then /bin/echo "--- debug info ---" /bin/df /usr/bin/free /bin/echo "--- end debug info ---" read dummy fi if [ x${DEBUG_WAIT_ENDFIRST} = xyes ] ; then /bin/echo "--- DEBUG: wait reboot ---" read dummy fi /sbin/reboot