#!/bin/sh # /usr/bin/dphys3preseed - # - build dphys3 replacement floppy images w preseed for Debian 3.1 (sarge) # author Neil Franklin, last modification 2005.11.10 # copyright ETH Zuerich Physics Departement, # use under either BSD or GPL license ### ------ configuration for this site # first CONF_* various site or subnet dependant user config variables # then DEBUG_* various debugging settings # last SYS_* various system internal values # some of these are overridable by command line options # --- CONF_* various site or subnet dependant user config variables # base URL from which all Debian stuff can be downloaded CONF_DEBSERVER=http://ftp.debian.org/debian # use this to use own dphys3kernel custom kernel floppy images, set to "yes" CONF_OWN_KERNEL="" # server where we upload our compiled floppy images and driver archives to CONF_INST_SERVER=not-configured-server # user as which we login to above server CONF_USER=not-configured-user # make sure multiple users (group of them) can install files on package server # if this is set, chgrp directories and files to this group and chmod g+w CONF_GROUP="" # base directory on server where we put our stuff for download # this is the base directory for adding dists/.../*.deb and pool/.../*.deb # paralleling Debians use [dist|spool]/.../*.deb on their servers # and so should appear in the http:// space of the server # the -u options upload everything relative to this CONF_INST_BASE=/not/configured/directory # this is the directory to use, within the dists/.../disks-i386 directory # vary this for multiple sets of files (say multiple kernels or configs) # naming schemes maybe by subnets, or by kernel options, or by compiling user CONF_DISKSVERSION=custom # base URL from which our generated stuff can be downloaded # used for generating the URLs, to access our packages web server # the end result should parallel the scp login@server:/basedir above CONF_OWNSERVER=http://not-configured-server/not/configured/directory # what net drivers we want included in our install root floppy # net is needed to install from, to load files from # this can be left empty if needed drivers are compiled into kernel CONF_MODULESNET="" # prevent unnecessary questions while installing packages # install everything with maintainers defaults, then fix up with own scripts CONF_SILENCE_DEBCONF=yes # what keyboard layout you use, just name without path or .kmap.gz ending CONF_KEYBD=us # force use of this network interface, set it to eth0 eth1 etc # this defaults to auto which uses the first usable one # but sometimes the kernel choses an broken but existing driver CONF_IF=auto # amount of disk to use for the swap partition, if wanted, in MBytes # set to 0 or "", will make no partition and disable its use # this defaults to off, because we use swap files around here # as they are more flexible, auto-resizable, and not relevantly slower # to autogenerate/mount/umount swapfiles install the dphys-swapfile package: # http://www.phys.ethz.ch/~franklin/Projects/dphys-swapfile/ CONF_SWAP_SIZE=0 # what time zone we have here, local time settings CONF_TIMEZONE_AREA=not-configured-area CONF_TIMEZONE_PLACE=not-configured-place # set root password, this may be only temporary, overwrite later CONF_PASSWORD_ROOT="" # apt config what stuff we use, this is just minimal stuff, extend later CONF_USE_NON_FREE=no CONF_USE_CONTRIB=no CONF_USE_SECURITY=no # automagically run this script (or binary) at end of first install stage # to include script on image, use filename like this: # CONF_END1STAGE=end1stage # to download script at install time, use URL like this: # CONF_END1STAGE=http://our-admin-server/install-stuff/end1stage # we use this to install our custom production kernels before the reboot # to prevent having to make debian installer compatible loading stuff CONF_END1STAGE="" # automagically run this script (or binary) at end of second install stage # use with script filename like this: CONF_END2STAGE=end2stage # we use this to install our automatic package installer/updater/remover: # http://www.phys.ethz.ch/~franklin/Projects/dphys-admin/ CONF_END2STAGE="" # --- DEBUG_*, various debugging settings # these can be set to "yes" by -D option, followed by name without DEBUG_ # such as like this: dphys3preseed -D PRINT_STEP -D LEAVE_TEMPFILES -g # set this to sleep after displaying each steps header, number is in seconds #DEBUG_SLEEP=2 # set this to output debug state info after each step #DEBUG_PRINT_STEP=yes # set this to wait after each debug state info #DEBUG_WAIT_STEP=yes # set this to have old initrd backupped #DEBUG_BACKUP_INITRD=yes # set this to have an copy of the generated preseed file in current directory #DEBUG_DUMP_PRESEED=yes # set this to not delete temporary files (workdir) after -g #DEBUG_LEAVE_TEMPFILES=yes # set this to leave temporary directories undeleted after -u #DEBUG_LEAVE_TEMPDIRS=yes # --- SYS_*, various system internal values # where we want to do all the unpack/modify/pack stuff # this must be a directory that root can access (not a root-squash NFS mount) # and there should be about 50MByte free space in its filesystem SYS_WORKDIR=/var/tmp/dphys3preseed-$$-work # where we want to put together stuff for upload # not ./upload as this may collide with something user already has SYS_UPLOADDIR=/var/tmp/dphys3preseed-$$-upload # note: this program has only been designed for and tested with i386 # others at own risk, I expect them to fail badly SYS_ARCH=i386 # version of the kernel on Debian [boot|root|net-drivers].img floppies # used for extracting additional drivers from .udeb on net-drivers.img # will need replacing by the correct one for custom kernels SYS_KERN_VERSION=2.4.27-2-386 ### ------ actual implementation from here on # no user settings any more below this point # --- tidy up some commands, make systematic # stuff that goes wrong, not expected by user, not in data output, use >&2 # so also with $0 in case this script was called by an other script # something within the system that user does not expect, give up CMD_FATAL="/bin/echo $0: FATAL:" # something from users input, user will correct this and continue CMD_ERROR="/bin/echo $0: ERROR:" # something we can continue with, but may be wrong, and user may not suspect it CMD_WARNING="/bin/echo $0: WARNING:" # something most likely not wrong, but tell user for the odd case it is wrong CMD_NOTE="/bin/echo $0: NOTE:" # normal stuff users expect, so to stdout as normal output, no $0, no marking CMD_INFO="/bin/echo" # stuff users asked for, so add to stdout as normal output, no $0, but mark it CMD_DEBUG="/bin/echo DEBUG:" # control output CMD_INFO_PRINT=${CMD_INFO} CMD_VERBOSE_PRINT=/bin/true # --- config file stuff # what we are NAME=dphys3preseed PNAME=dphys3 # check user config file(s), let user override settings # same config files used in dphys3[kernel|preseed|boot|root|cd|pxe] if [ -f /etc/${PNAME} ] ; then . /etc/${PNAME} fi if [ -f ~/.${PNAME} ] ; then . ~/.${PNAME} fi if [ -f ./${PNAME} ] ; then . ./${PNAME} fi # --- parse command line # so long next parameter is a set of options (= begins with an - character) while [ x`/bin/echo $1 | /usr/bin/cut -c 1` = x- ] ; do # extract options from parameter (cut off the "-") OPTS=`/bin/echo $1 | /usr/bin/cut -c 2-` shift 1 # so long still unprocessed option characters while [ x${OPTS} != x ] ; do # first option to process OPT=`/bin/echo ${OPTS} | /usr/bin/cut -c 1` # and rest of options for later OPTS=`/bin/echo ${OPTS} | /usr/bin/cut -c 2-` case ${OPT} in d) # download: download orignal Debian files from distribution server DO_DOWN=yes COMMAND_OPTION=yes ;; g) # generate: generate our own files DO_GEN=yes COMMAND_OPTION=yes ;; u) # upload: upload generated files to local install server DO_UPLOAD=yes COMMAND_OPTION=yes ;; b) # base: upload generated package files to base directory CONF_INST_BASE=$1 shift 1 ;; r) # remove: remove Debian and own files, after installing DO_REMOVE=yes COMMAND_OPTION=yes ;; q) # quiet: don't inform user what we are doing CMD_INFO_PRINT=/bin/true ;; v) # verbose: detailed inform user what we are doing CMD_VERBOSE_PRINT=${CMD_INFO} ;; D) # Debug: set an debug option to yes eval DEBUG_$1=yes shift 1 ;; h) # help: give out help how this script can be used /bin/cat << END-HELP-TEXT Usage is: $0 [options] options: -d download: download orignal Debian files from distribution server -g generate: generate our own files -u upload: upload generated files to local install server for usage by -f before install -b baseaddr base: upload generated files relative to this base directory -r remove: remove Debian and own files, after installing -q quiet: don't give user an running report of what we are doing -v verbose: give user detailed running report -D Debug: activate an debug option -h help: give out help how this script can be used If multiple of -d -g -u or -r are used, they are processed in the order they appear here in the help section, not the order they are typed on the command line. Other options modify behaviour. END-HELP-TEXT exit 0 ;; *) # not one of our recognized options ${CMD_ERROR} unknown option: ${OPT} >&2 ${CMD_INFO} >&2 # call self with -h to display help $0 -h exit 1 ;; esac done done if [ x${COMMAND_OPTION} = x ] ; then ${CMD_WARNING} no command option selected, doing nothing ... >&2 fi # --- set debugging behaviour CMD_DEBUG_SLEEP=/bin/true if [ x${DEBUG_SLEEP} != x ] ; then CMD_DEBUG_SLEEP="/bin/sleep ${DEBUG_SLEEP}" fi CMD_DEBUG_PRINT=/bin/true if [ x${DEBUG_PRINT_STEP} = xyes ] ; then CMD_DEBUG_PRINT=${CMD_DEBUG} fi CMD_DEBUG_WAIT=/bin/true if [ x${DEBUG_WAIT_STEP} = xyes ] ; then CMD_DEBUG_WAIT="read -p ---DEBUG-wait-after-step--- dummy" fi ${CMD_DEBUG_PRINT} options are: \ DO_DOWN: ${DO_DOWN}, DO_GEN: ${DO_GEN}, \ DO_UPLOAD: ${DO_UPLOAD}, DO_REMOVE: ${DO_REMOVE} ${CMD_DEBUG_WAIT} # --- test if we can work # this script is intended to be run as root, it will fail if run as user! if [ ! `/usr/bin/whoami` = root ] ; then ${CMD_ERROR} sorry, you need to run this script as root - aborting ... >&2 exit 1 fi # --- compute paths on disk image server # path for Debian directory we download from server DEBINST=dists/sarge/main/installer-${SYS_ARCH}/current # path for our directory we upload to and download from server OWNINST=dists/sarge/local/main/installer-${SYS_ARCH}/${CONF_DISKSVERSION} # actual files inside all of these BOOTIMG=images/floppy/boot.img ROOTIMG=images/floppy/root.img DRIVIMG=images/floppy/net-drivers.img # --- download own or Debian boot disk image to work on # determine the correct boot floppy image file # used by -d and -g and others, so once here outside of -d if [ x${CONF_OWN_KERNEL} != x ] ; then BOOT_URL=${CONF_OWNSERVER}/${OWNINST}/${BOOTIMG} else BOOT_URL=${CONF_DEBSERVER}/${DEBINST}/${BOOTIMG} fi # in current dir, not workdir, as user wants to see this BOOT=`/usr/bin/basename ${BOOT_URL}` if [ x${DO_DOWN} != x ] ; then ${CMD_INFO_PRINT} downloading boot disk image ... ${CMD_DEBUG_SLEEP} # -N so only newer is got, save waisting bandwidth if already here # if user wants to force download, use an make clean before # downloaded and to-upload files should end in current directory # this is also most likely where config and kernel archive will be # everything else in work directory and then deleted at the end /usr/bin/wget -q -N ${BOOT_URL} -O ${BOOT} ${CMD_DEBUG_PRINT} `/bin/ls -al ${BOOT}` ${CMD_DEBUG_WAIT} fi # --- download own or Debian root disk image to work on # determine the correct root floppy image file # used by -d and -g and others, so once here outside of -d if [ x${CONF_OWN_KERNEL} != x ] ; then ROOT_URL=${CONF_OWNSERVER}/${OWNINST}/${ROOTIMG} else ROOT_URL=${CONF_DEBSERVER}/${DEBINST}/${ROOTIMG} fi ROOT=`/usr/bin/basename ${ROOT_URL}` if [ x${DO_DOWN} != x ] ; then ${CMD_INFO_PRINT} downloading root disk image ... ${CMD_DEBUG_SLEEP} # -N so only newer is got, save waisting bandwidth if already here # if user wants to force download, use an make clean before /usr/bin/wget -q -N ${ROOT_URL} -O ${ROOT} ${CMD_DEBUG_PRINT} `/bin/ls -al ${ROOT}` ${CMD_DEBUG_WAIT} fi # --- download own or Debian drivers disk image to work on # determine the correct full drivers archive if [ x${CONF_OWN_KERNEL} != x ] ; then DRV_URL=${CONF_OWNSERVER}/${OWNINST}/${DRIVIMG} else DRV_URL=${CONF_DEBSERVER}/${DEBINST}/${DRIVIMG} fi DRV=`/usr/bin/basename ${DRV_URL}` if [ x${DO_DOWN} != x ] ; then ${CMD_INFO_PRINT} downloading drivers disk image ... ${CMD_DEBUG_SLEEP} # -N so only newer is got, save waisting bandwidth if already here # if user wants to force download, use an make clean before /usr/bin/wget -q -N ${DRV_URL} -O ${DRV} ${CMD_DEBUG_PRINT} `/bin/ls -al ${DRV}` ${CMD_DEBUG_WAIT} fi # --- space to work in if [ x${DO_GEN} != x ] ; then /bin/mkdir -p ${SYS_WORKDIR} fi # --- set syslinux timeout and eliminate ram disk size limit on boot floppy if [ x${DO_GEN} != x ] ; then ${CMD_INFO_PRINT} modifying syslinux on boot disk ... ${CMD_DEBUG_SLEEP} # mount boot file system from floppy image BOOTFLOPPY=${SYS_WORKDIR}/boot /bin/mkdir -p ${BOOTFLOPPY} /bin/mount -o loop ${BOOT} ${BOOTFLOPPY} # set timeout to autostart after 1/10sec, as we don't need prompt # don't do this with .tmp on floppy, may run out of space /bin/sed -e '/timeout/s/0/10/' ${BOOTFLOPPY}/syslinux.cfg > \ ${SYS_WORKDIR}/syslinux.cfg.tmp /bin/mv ${SYS_WORKDIR}/syslinux.cfg.tmp ${BOOTFLOPPY}/syslinux.cfg # eliminate ram disk size limit # else CD boot2.88 with larger root initrd crashes /bin/sed -e '/append/s/ramdisk_size=1838 //' ${BOOTFLOPPY}/syslinux.cfg > \ ${SYS_WORKDIR}/syslinux.cfg.tmp /bin/mv ${SYS_WORKDIR}/syslinux.cfg.tmp ${BOOTFLOPPY}/syslinux.cfg ${CMD_DEBUG_PRINT} +++ begin syslinux.cfg +++ if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/cat ${BOOTFLOPPY}/syslinux.cfg fi ${CMD_DEBUG_PRINT} +++ end syslinux.cfg +++ ${CMD_DEBUG_WAIT} # before closing, to see inside floppy ${CMD_DEBUG_PRINT} +++ begin bootfloppy listing +++ if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/ls -al ${BOOTFLOPPY} fi ${CMD_DEBUG_PRINT} +++ end bootfloppy listing +++ ${CMD_DEBUG_WAIT} /bin/umount ${BOOTFLOPPY} # modifying via -o loop fails to set changed time, mark this /usr/bin/touch ${BOOT} ${CMD_DEBUG_PRINT} `/bin/ls -al ${BOOT}` ${CMD_DEBUG_WAIT} fi # --- unpack and mount root initrd if [ x${DO_GEN} != x ] ; then ${CMD_INFO_PRINT} unpacking root image into ${SYS_WORKDIR} ... ${CMD_DEBUG_SLEEP} # unpack initrd file system from root floppy image ROOTFLOPPY=${SYS_WORKDIR}/root /bin/mkdir -p ${ROOTFLOPPY} /bin/mount -o loop ${ROOT} ${ROOTFLOPPY} # copy so that we have enough space to gunzip ROOTINITRD_IMG=${SYS_WORKDIR}/root-initrd.img /bin/gunzip -c ${ROOTFLOPPY}/initrd.gz > ${ROOTINITRD_IMG} if [ x${DEBUG_BACKUP_INITRD} != x ] ; then # save the unmodified initrd for comparing stuff /bin/cp -p ${ROOTINITRD_IMG} ${ROOTINITRD_IMG}.bak fi ROOTINITRD=${SYS_WORKDIR}/root-initrd /bin/mkdir -p ${ROOTINITRD} /bin/mount -o loop ${ROOTINITRD_IMG} ${ROOTINITRD} ${CMD_DEBUG_PRINT} +++ begin directory overview +++ if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/ls -al ${SYS_WORKDIR} ${ROOTFLOPPY} ${ROOTINITRD} fi ${CMD_DEBUG_PRINT} +++ end directory overview +++ ${CMD_DEBUG_WAIT} fi # --- insert network drivers if we want additional ones, to avoid driver disk if [ x${DO_GEN} != x -a \ x`/bin/echo ${CONF_MODULESNET} | /usr/bin/cut -f 1 -d " "` != x ] ; then ${CMD_INFO_PRINT} adding facultative net drivers that we need/want ... ${CMD_DEBUG_SLEEP} # the network hardware may need one of these # non-modular kernels (users may want to make such) may not want any # open net-drivers floppy image DRVFLOPPY=${SYS_WORKDIR}/drv MODULES=nic-extra-modules-${SYS_KERN_VERSION}-di MODULEDIR=./lib/modules/${SYS_KERN_VERSION}/kernel/drivers/net /bin/mkdir -p ${DRVFLOPPY} /bin/mount -o loop ${DRV} ${DRVFLOPPY} /bin/cp -p ${DRVFLOPPY}/${MODULES}.udeb ${SYS_WORKDIR} /bin/umount ${DRVFLOPPY} # get the actual stuff out of the .udeb /usr/bin/dpkg-deb --fsys-tarfile ${SYS_WORKDIR}/${MODULES}.udeb > \ ${SYS_WORKDIR}/${MODULES}.tar /bin/rm ${SYS_WORKDIR}/${MODULES}.udeb # and fetch the desired additional modules for MODULE in ${CONF_MODULESNET}; do /bin/tar xf ${SYS_WORKDIR}/${MODULES}.tar -C ${ROOTINITRD} \ ${MODULEDIR}/${MODULE} done /bin/rm -r ${SYS_WORKDIR}/${MODULES}.tar ${CMD_DEBUG_PRINT} +++ begin net modules listing +++ if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/ls -al ${ROOTINITRD}/${MODULEDIR} fi ${CMD_DEBUG_PRINT} +++ end net modules listing +++ ${CMD_DEBUG_WAIT} fi # --- install the .udeb files for doing the entire preseed thing if [ x${DO_GEN} != x ] ; then ${CMD_INFO_PRINT} packing in preseed .udebs onto root initrd ... ${CMD_DEBUG_SLEEP} # the sarge root image has no modern 1.02 preseeding stuff on it # according to Joey Hess (Bug#299059) no preseed on floppys, fix post-sarge # according to Joey Hess 1.02 and initrd-preseed are also post-sarge # so we fix this here, by installing their .udeb files to our floppy image if [ ! -f ${ROOTINITRD}/lib/debian-installer-startup.d/S35preseed ] ; then UDEB_LIB=/usr/lib/dphys3/udeb UDEB_PRESEED=preseed-common_1.10_all.udeb UDEB_INITRD=initrd-preseed_1.10_all.udeb /bin/cp -p ${UDEB_LIB}/${UDEB_PRESEED} ${ROOTINITRD} /bin/cp -p ${UDEB_LIB}/${UDEB_INITRD} ${ROOTINITRD} /usr/sbin/chroot ${ROOTINITRD} \ /usr/bin/udpkg -i /${UDEB_PRESEED} > /dev/null /usr/sbin/chroot ${ROOTINITRD} \ /usr/bin/udpkg -i /${UDEB_INITRD} > /dev/null /bin/rm ${ROOTINITRD}/${UDEB_PRESEED} /bin/rm ${ROOTINITRD}/${UDEB_INITRD} fi ${CMD_DEBUG_PRINT} +++ begin startup script listing +++ if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/ls -al ${ROOTINITRD}/lib/debian-installer-startup.d fi ${CMD_DEBUG_PRINT} +++ end startup script listing +++ ${CMD_DEBUG_WAIT} fi # --- add preseed file for setting up debconf if [ x${DO_GEN} != x ] ; then ${CMD_INFO_PRINT} packing preseed file onto root initrd ... ${CMD_DEBUG_SLEEP} # this location is hardwired into the initrd-preseed packages script PS=${ROOTINITRD}/preseed.cfg if [ -f ${PS} ] ; then /bin/echo >>${PS} /bin/echo >>${PS} fi /bin/echo >>${PS} "### --- from here on generated by dphys3pressed" /bin/echo >>${PS} # - instead of syslinux.cfg settings preseed these here, less trouble # syslinux.cfg can only set max 8 kernel parameters and 5 already taken # get rid of all questions that are avoidable, in all packages /bin/echo >>${PS} "d-i debconf/priority select critical" # set our language and where we are /bin/echo >>${PS} "d-i languagechooser/language-name select English" /bin/echo >>${PS} "d-i countrychooser/shortlist select Switzerland" # select type of keyboard and keymap to use /bin/echo >>${PS} "d-i console-tools/archs select" \ "PC-style (AT or PS-2 connector) keyboard" /bin/echo >>${PS} "d-i console-keymaps-at/keymap select ${CONF_KEYBD}" # - do not load additional drivers from floppy, get rid of question # note that this only works with the floppy loader patching below /bin/echo >>${PS} "d-i retriever/floppy/loadnow boolean false" # - network configuration # set the interface, we default to auto, use first /bin/echo >>${PS} "d-i netcfg/choose_interface select ${CONF_IF}" # just set dummy hostname and domain names # as dhcp takes precedence over these, but this still prevents questions /bin/echo >>${PS} "d-i netcfg/get_hostname string dummy-hostname" /bin/echo >>${PS} "d-i netcfg/get_domain string dummy-domain" # - mirror settings # MIRROR_DIR with leading / MIRROR_HOST=`/bin/echo ${CONF_DEBSERVER} | /usr/bin/cut -f 3 -d "/"` MIRROR_DIR=/`/bin/echo ${CONF_DEBSERVER} | /usr/bin/cut -f 4- -d "/"` /bin/echo >>${PS} "d-i mirror/country string" \ "enter information manually" /bin/echo >>${PS} "d-i mirror/http/hostname string ${MIRROR_HOST}" /bin/echo >>${PS} "d-i mirror/http/directory string ${MIRROR_DIR}" /bin/echo >>${PS} "d-i mirror/suite string sarge" /bin/echo >>${PS} "d-i mirror/http/proxy string" # - partitioning # devfs device name automatically selects hda or sda, cool /bin/echo >>${PS} "d-i partman-auto/disk string /dev/discs/disc0/disc" if [ x${CONF_SWAP_SIZE} = x -o x${CONF_SWAP_SIZE} = x0 ] ; then # we just want an single big partition, so use own recipe # we also need /boot partition because some BIOSes are still too stupid # size numbers: minimal factor maximal, whatever factor is supposed to be /bin/echo >>${PS} "d-i partman-auto/expert_recipe string" \ "boot-and-root ::" \ "30 10000 30 ext3" \ "\$primary{ } \$bootable{ } method{ format } format{ }" \ "use_filesystem{ } filesystem{ ext3 } mountpoint{ /boot } ." \ "500 10000 1000000 ext3" \ "method{ format } format{ }" \ "use_filesystem{ } filesystem{ ext3 } mountpoint{ / } ." else # or some people may want an swap partition as well, so also use own recipe /bin/echo >>${PS} "d-i partman-auto/expert_recipe string" \ "boot-and-swap-and-root ::" \ "30 10000 30 ext3" \ "\$primary{ } \$bootable{ } method{ format } format{ }" \ "use_filesystem{ } filesystem{ ext3 } mountpoint{ /boot } ." \ "${CONF_SWAP_SIZE} 10000 ${CONF_SWAP_SIZE} linux-swap" \ "format{ } ." "500 10000 1000000 ext3" \ "method{ format } format{ }" \ "use_filesystem{ } filesystem{ ext3 } mountpoint{ / } ." fi # and yes we want above, all 3 dialogs long, yes, yes really, yes totally! /bin/echo >>${PS} "d-i partman/confirm_write_new_label boolean true" /bin/echo >>${PS} "d-i partman/choose_partition select" \ "Finish partitioning and write changes to disk" /bin/echo >>${PS} "d-i partman/confirm boolean true" # - boot loader installation # use the standard well tested grub in MBR method # fix using other bootloader or other config later, if wanted /bin/echo >>${PS} "d-i grub-installer/only_debian boolean true" # - get rid of gratuitous dialogs telling us was is happening # avoid that last message about the install being complete /bin/echo >>${PS} "d-i prebaseconfig/reboot_in_progress note" # avoid the introductory message after rebooting /bin/echo >>${PS} "base-config base-config/intro note" # avoid the final message before login appears /bin/echo >>${PS} "base-config base-config/login note" # - time zone setup # we always use GMT clocks around here /bin/echo >>${PS} "base-config tzconfig/gmt boolean true" # set up our time zone, in 2 parts /bin/echo >>${PS} "base-config tzconfig/geographic_area" \ "select ${CONF_TIMEZONE_AREA}" /bin/echo >>${PS} "base-config tzconfig/select_zone/${CONF_TIMEZONE_AREA}" \ "select ${CONF_TIMEZONE_PLACE}" # - account setup # set an temporary root password, will be later corrected by admin stuff /bin/echo >>${PS} "passwd passwd/root-password password" \ "${CONF_PASSWORD_ROOT}" /bin/echo >>${PS} "passwd passwd/root-password-again password" \ "${CONF_PASSWORD_ROOT}" # and we don't want any local users, LDAP and NFS rule around here /bin/echo >>${PS} "passwd passwd/make-user boolean false" # - apt setup # we load our packages via http /bin/echo >>${PS} "base-config apt-setup/uri_type select http" # mirror settings, for the second time /bin/echo >>${PS} "base-config apt-setup/country select" \ "enter information manually" /bin/echo >>${PS} "base-config apt-setup/hostname string ${MIRROR_HOST}" /bin/echo >>${PS} "base-config apt-setup/directory string ${MIRROR_DIR}" # only one mirror, rest will be later corrected by local admin stuff /bin/echo >>${PS} "base-config apt-setup/another boolean false" # some people use non-free and contrib software, some hate them if [ x${CONF_USE_NON_FREE} = xyes -o x${CONF_USE_NON_FREE} = xtrue ] ; then /bin/echo >>${PS} "base-config apt-setup/non-free boolean true" else /bin/echo >>${PS} "base-config apt-setup/non-free boolean false" fi if [ x${CONF_USE_CONTRIB} = xyes -o x${CONF_USE_CONTRIB} = xtrue ] ; then /bin/echo >>${PS} "base-config apt-setup/contrib boolean true" else /bin/echo >>${PS} "base-config apt-setup/contrib boolean false" fi # some people want security updates, some prefer to set this later if [ x${CONF_USE_SECURITY} = xyes -o x${CONF_USE_SECURITY} = xtrue ] ; then /bin/echo >>${PS} "base-config apt-setup/security-updates boolean true" else /bin/echo >>${PS} "base-config apt-setup/security-updates boolean false" fi # - package selection # just minimal installation, as rest is done by our own admin tools /bin/echo >>${PS} "tasksel tasksel/first multiselect" # - mailer configuration # simply get exim to be quiet as fast as possible, will be replaced later /bin/echo >>${PS} "exim4-config exim4/dc_eximconfig_configtype select" \ "local delivery only; not on a network" /bin/echo >>${PS} "exim4-config exim4/dc_postmaster string root" if [ x${DEBUG_DUMP_PRESEED} = xyes ] ; then /bin/cp -p ${PS} . fi ${CMD_DEBUG_PRINT} `/bin/ls -al ${PS}` ${CMD_DEBUG_WAIT} fi # --- fix floppy loader so it does not ask, despite preseeding if [ x${DO_GEN} != x ] ; then ${CMD_INFO_PRINT} fixing floppy loader on root initrd ... ${CMD_DEBUG_SLEEP} # remove the db_set command that kills the preseeded value LOADER=${ROOTINITRD}/var/lib/dpkg/info/load-floppy.postinst /bin/sed -e '/db_set/d' ${LOADER} > ${LOADER}.tmp /bin/mv ${LOADER}.tmp ${LOADER} /bin/chmod 755 ${LOADER} ${CMD_DEBUG_PRINT} `/bin/ls -al ${LOADER}` ${CMD_DEBUG_WAIT} fi # --- fix silly anna test, so it does not ask if [ x${DO_GEN} != x ] ; then ${CMD_INFO_PRINT} fixing anna kernel modules test ... ${CMD_DEBUG_SLEEP} # this stops the test being done, according to mail answer from Joey Hess # else install waits at dialog, when module-less custom kernel is used /bin/echo >>${PS} "d-i anna/no_kernel_modules boolean true" ${CMD_DEBUG_PRINT} `/bin/ls -al ${PS}` ${CMD_DEBUG_WAIT} fi # --- run user scripts at end of install stages, further automation if [ x${DO_GEN} != x -a x${CONF_END1STAGE}${CONF_END2STAGE} != x ] ; then ${CMD_INFO_PRINT} including user scripts for further automation ... ${CMD_DEBUG_SLEEP} # is there a script to include to run after the first install stage? # but before reboot into second stage if [ x${CONF_END1STAGE} != x ] ; then # if set to http:// or ftp:// value, then fetch from server at install time if `/bin/echo ${CONF_END1STAGE} | \ /bin/grep '^[a-z]*://' > /dev/null` ; then # this is allways the first but, if present, so no "; " stuff END1STAGE_CMD="/usr/bin/wget -O /e1s ${CONF_END1STAGE}" elif [ -f ${CONF_END1STAGE} ] ; then # we use an fixed name (/e1s) on target, to avoid name clashes /bin/cp -p ${CONF_END1STAGE} ${ROOTINITRD}/e1s else ${CMD_ERROR} CONF_END1STAGE feature enabled in setup, non-URL mode, \ but file ${CONF_END1STAGE} is missing >&2 exit 1 fi if [ x`/bin/echo ${END1STAGE_CMD} | /usr/bin/cut -c 1` != x ] ; then # command separator if already begun (wget above) END1STAGE_CMD="${END1STAGE_CMD}; " fi # put chown and chmod here, before run, to guarantee it allways gets done END1STAGE_CMD="${END1STAGE_CMD}\ /bin/chown root.root /e1s; /bin/chmod 755 /e1s; /e1s" fi # is there a script to include to run after the second install stage? # but before the user is given login if [ x${CONF_END2STAGE} != x ] ; then if `/bin/echo ${CONF_END1STAGE} | \ /bin/grep '^[a-z]*://' > /dev/null` ; then # extend with second wget, after running end1stage script if [ x`/bin/echo ${END1STAGE_CMD} | /usr/bin/cut -c 1` != x ] ; then END1STAGE_CMD="${END1STAGE_CMD}; " fi END1STAGE_CMD="${END1STAGE_CMD}/usr/bin/wget -O /e2s ${CONF_END2STAGE}" elif [ -f ${CONF_END2STAGE} ] ; then /bin/cp -p ${CONF_END2STAGE} ${ROOTINITRD}/e2s else ${CMD_ERROR} CONF_END2STAGE feature enabled in setup, non-URL mode, \ but file ${CONF_END2STAGE} is missing >&2 exit 1 fi # extend with copying second script, which was originally on / if [ x`/bin/echo ${END1STAGE_CMD} | /usr/bin/cut -c 1` != x ] ; then END1STAGE_CMD="${END1STAGE_CMD}; " fi # this still runs on / = install and /target = final system END1STAGE_CMD="${END1STAGE_CMD}/bin/cp -p /e2s /target" # this now runs after reboot, with / = final system END2STAGE_CMD="/bin/chown root.root /e2s; /bin/chmod 755 /e2s; /e2s" fi # add running of the commands, at end of both install stages to preseed file # this just before reboot, if anything got set # runs with install system as / and final system as /target, more flexible if [ x`/bin/echo ${END1STAGE_CMD} | /usr/bin/cut -c 1` != x ] ; then /bin/echo >>${PS} "d-i preseed/late_command \ string ${END1STAGE_CMD}" fi # this just before login appears, if anything got set if [ x`/bin/echo ${END2STAGE_CMD} | /usr/bin/cut -c 1` != x ] ; then /bin/echo >>${PS} "base-config base-config/late_command \ string ${END2STAGE_CMD}" fi if [ x${DEBUG_DUMP_PRESEED} = xyes ] ; then /bin/cp -p ${PS} . fi if [ -f ${ROOTINITRD}/e1se ] ; then ${CMD_DEBUG_PRINT} `/bin/ls -al ${ROOTINITRD}/e1s` fi if [ -f ${ROOTINITRD}/e2s ] ; then ${CMD_DEBUG_PRINT} `/bin/ls -al ${ROOTINITRD}/e2s` fi if [ x`/bin/echo ${END1STAGE_CMD} | /usr/bin/cut -c 1` != x ] ; then ${CMD_DEBUG_PRINT} ${END1STAGE_CMD} fi if [ x`/bin/echo ${END2STAGE_CMD} | /usr/bin/cut -c 1` != x ] ; then ${CMD_DEBUG_PRINT} ${END2STAGE_CMD} fi ${CMD_DEBUG_PRINT} `/bin/ls -al ${PS}` ${CMD_DEBUG_WAIT} fi # --- unmount and pack root initrd if [ x${DO_GEN} != x ] ; then ${CMD_INFO_PRINT} unmounting and packing root image from ${SYS_WORKDIR} ... ${CMD_DEBUG_SLEEP} # before closing, to see inside initrd ${CMD_DEBUG_PRINT} +++ begin rootfloppy initrd listing +++ if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/ls -al ${ROOTINITRD} fi ${CMD_DEBUG_PRINT} +++ end rootfloppy initrd listing +++ ${CMD_DEBUG_WAIT} /bin/umount ${ROOTINITRD} /bin/gzip -9 -c ${ROOTINITRD_IMG} > ${ROOTFLOPPY}/initrd.gz if [ $? != 0 ] ; then /bin/umount ${ROOTFLOPPY} ${CMD_FATAL} not enough space for initrd.gz on ${ROOTFLOPPY} >&2 exit 1 fi # before closing, to see inside floppy ${CMD_DEBUG_PRINT} +++ begin rootfloppy image listing +++ if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/ls -al ${ROOTFLOPPY} fi ${CMD_DEBUG_PRINT} +++ end rootfloppy image listing +++ ${CMD_DEBUG_WAIT} /bin/umount ${ROOTFLOPPY} # writing to loop mounted image file does not seem to update its access time /usr/bin/touch ${ROOT} ${CMD_DEBUG_PRINT} `/bin/ls -al ${ROOT}` ${CMD_DEBUG_WAIT} fi # --- tidy up after working if [ x${DO_GEN} != x ] ; then ${CMD_INFO_PRINT} tidying up from working ... ${CMD_DEBUG_SLEEP} ${CMD_DEBUG_PRINT} +++ begin workdirectory listing +++ if [ x${DEBUG_PRINT_STEP} = xyes ] ; then /bin/ls -al ${SYS_WORKDIR} fi ${CMD_DEBUG_PRINT} +++ end workdirectory listing +++ ${CMD_DEBUG_WAIT} # remove all temporary directories and their contents, to save space # must be after debug printout if [ x${DEBUG_LEAVE_TEMPFILES} != xyes ] ; then # but offer to leave them to investigate bugs /bin/rm -rf ${SYS_WORKDIR} fi fi # --- upload generated floppy images if [ x${DO_UPLOAD} != x ] ; then ${CMD_INFO_PRINT} uploading images to ${CONF_INST_SERVER} ... ${CMD_DEBUG_SLEEP} # put together stuff to upload, needs an temp dir BOOT_DIR=${SYS_UPLOADDIR}/`/usr/bin/dirname ${OWNINST}/${BOOTIMG}` ROOT_DIR=${SYS_UPLOADDIR}/`/usr/bin/dirname ${OWNINST}/${ROOTIMG}` /bin/mkdir -p ${BOOT_DIR} ${ROOT_DIR} if [ x${CONF_GROUP} != x ] ; then /bin/chgrp -R ${CONF_GROUP} ${SYS_UPLOADDIR} /bin/chmod -R 2775 ${SYS_UPLOADDIR} fi if [ -f ${BOOT} ] ; then /bin/cp -p ${BOOT} ${BOOT_DIR} if [ x${CONF_GROUP} != x ] ; then /bin/chgrp ${CONF_GROUP} ${BOOT_DIR}/* /bin/chmod 664 ${BOOT_DIR}/* fi fi if [ -f ${ROOT} ] ; then /bin/cp -p ${ROOT} ${ROOT_DIR} if [ x${CONF_GROUP} != x ] ; then /bin/chgrp ${CONF_GROUP} ${ROOT_DIR}/* /bin/chmod 664 ${ROOT_DIR}/* fi fi # include directory tree, duplicating tree to server, in case server has none # may be none if new package is in an previously unused section # this is a bit site dependant, you need ssh on your local package server # 2> needed to get rid of error message, because scp can not change dir modes # this loses us the progress bar, because scp tests also 2> for tty or not # if user has given us somewhere to upload to, else dphys2cp|pxe get screwed if [ x${CONF_INST_SERVER} != x ] ; then /usr/bin/scp -pr ${SYS_UPLOADDIR}/* \ ${CONF_USER}@${CONF_INST_SERVER}:${CONF_INST_BASE} 2> /dev/null else ${CMD_FATAL} no server to upload root floppy image to >&2 exit 1 fi ${CMD_DEBUG_PRINT} `/bin/ls -al ${SYS_UPLOADDIR}/${OWNINST}/${BOOTIMG}` ${CMD_DEBUG_PRINT} `/bin/ls -al ${SYS_UPLOADDIR}/${OWNINST}/${ROOTIMG}` ${CMD_DEBUG_WAIT} # remove temporary directory and its contents, to save space # must be after debug printout if [ x${DEBUG_LEAVE_TEMPDIRS} != xyes ] ; then # but offer to leave this to investigate bugs /bin/rm -rf ${SYS_UPLOADDIR} fi fi # --- remove disk images if [ x${DO_REMOVE} != x ] ; then ${CMD_INFO_PRINT} removing disk images ... ${CMD_DEBUG_PRINT} `/bin/ls -al ${BOOT} 2> /dev/null` ${CMD_DEBUG_PRINT} `/bin/ls -al ${ROOT} 2> /dev/null` ${CMD_DEBUG_PRINT} `/bin/ls -al ${DRV} 2> /dev/null` ${CMD_DEBUG_WAIT} /bin/rm -f ${BOOT} ${ROOT} ${DRV} fi exit 0