Index: distrib/sgi/ramdisk/install.md =================================================================== --- distrib/sgi/ramdisk/install.md (revision 15) +++ distrib/sgi/ramdisk/install.md (revision 19) @@ -84,7 +84,8 @@ with a new Volume Header suitable for installing OpenBSD. Doing this will of course delete all data currently on the disk. __EOT - ask "Do you want to overwrite the current header?" y + ask "Do you want to overwrite the current header?" y \ + $(unattended_val u_disk "$_disk" volumeheaderoverwrite) case "$resp" in y*|Y*) /usr/mdec/sgivol -qi $_disk @@ -98,12 +99,14 @@ use the 'a' partition on the disk for the install and any data in that partition will be lost. __EOT - ask "Are you sure you want to try to keep the old header?" y + ask "Are you sure you want to try to keep the old header?" y \ + $(unattended_val u_disk "$_disk" volumeheaderkeepold) case "$resp" in y*|Y*) ;; n*|N*) - ask "Do you want to overwrite the old header instead?" n + ask "Do you want to overwrite the old header instead?" n \ + $(unattended_val u_disk "$_disk" volumeheaderoverwriteold) case "$resp" in y*|Y*) /usr/mdec/sgivol -qi $_disk @@ -120,7 +123,8 @@ 1) echo echo "Your disk seems to be unaccessible. It was not possible" echo "determine if there is a proper Volume Header or not." - ask "Do you want to continue anyway?" n + ask "Do you want to continue anyway?" n \ + $(unattended_val u_disk "$_disk" ignoreunaccessibledisk) case "$resp" in y*|Y*) ;; @@ -131,7 +135,8 @@ 2) echo echo "There is no Volume Header found on the disk. A Volume" echo "header is required to be able to boot from the disk." - ask "Do you want to install a Volume Header?" y + ask "Do you want to install a Volume Header?" y \ + $(unattended_val u_disk "$_disk" ignoremissingheader) case "$resp" in y*|Y*) /usr/mdec/sgivol -qi $_disk @@ -172,7 +177,13 @@ esac disklabel -W $_disk - disklabel -c -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -c -f /tmp/fstab.$_disk -E $_disk + else + disklabel -c -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/sgi/ramdisk/list =================================================================== --- distrib/sgi/ramdisk/list (revision 15) +++ distrib/sgi/ramdisk/list (revision 19) @@ -78,3 +78,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/sparc64/common/install.md =================================================================== --- distrib/sparc64/common/install.md (revision 15) +++ distrib/sparc64/common/install.md (revision 19) @@ -100,7 +100,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/sparc64/ramdisk/list =================================================================== --- distrib/sparc64/ramdisk/list (revision 15) +++ distrib/sparc64/ramdisk/list (revision 19) @@ -75,3 +75,5 @@ SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/sparc64/ramdiskB/list =================================================================== --- distrib/sparc64/ramdiskB/list (revision 15) +++ distrib/sparc64/ramdiskB/list (revision 19) @@ -73,3 +73,5 @@ SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/sparc64/bsd.rd/list =================================================================== --- distrib/sparc64/bsd.rd/list (revision 15) +++ distrib/sparc64/bsd.rd/list (revision 19) @@ -76,3 +76,5 @@ SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/alpha/common/install.md =================================================================== --- distrib/alpha/common/install.md (revision 15) +++ distrib/alpha/common/install.md (revision 19) @@ -83,7 +83,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/alpha/common/list =================================================================== --- distrib/alpha/common/list (revision 15) +++ distrib/alpha/common/list (revision 19) @@ -69,3 +69,5 @@ SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../common/install.md install.md SPECIAL chmod 755 install upgrade + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/hppa/install.md =================================================================== --- distrib/hppa/install.md (revision 15) +++ distrib/hppa/install.md (revision 19) @@ -39,7 +39,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/hppa/list =================================================================== --- distrib/hppa/list (revision 15) +++ distrib/hppa/list (revision 19) @@ -63,3 +63,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../miniroot/unattended.conf unattended.conf Index: distrib/mac68k/ramdisk/install.md =================================================================== --- distrib/mac68k/ramdisk/install.md (revision 15) +++ distrib/mac68k/ramdisk/install.md (revision 19) @@ -108,7 +108,13 @@ esac disklabel $_wflag $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/mac68k/ramdisk/list =================================================================== --- distrib/mac68k/ramdisk/list (revision 15) +++ distrib/mac68k/ramdisk/list (revision 19) @@ -73,3 +73,5 @@ SCRIPT ${CURDIR}/../../miniroot/upgrade.sh upgrade SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/i386/common/install.md =================================================================== --- distrib/i386/common/install.md (revision 15) +++ distrib/i386/common/install.md (revision 19) @@ -49,11 +49,13 @@ md_set_term() { local _tables - ask_yn "Do you wish to select a keyboard encoding table?" + ask_yn "Do you wish to select a keyboard encoding table?" "" \ + $u_installer_setkbdencoding [[ $resp == n ]] && return while : ; do - ask "Select your keyboard type: (P)C-AT/XT, (U)SB or 'done'" P + ask "Select your keyboard type: (P)C-AT/XT, (U)SB or 'done'" P \ + $u_installer_kbdtype case $resp in P*|p*) _tables="be br de dk es fr it jp lt no pt ru sf sg sv ua uk us" ;; @@ -77,7 +79,7 @@ ${_tables} __EOT - ask "Table name? (or 'done')" us + ask "Table name? (or 'done')" us $u_installer_kbdencoding case $resp in done) ;; *) if kbd $resp ; then @@ -118,7 +120,8 @@ md_prep_fdisk() { local _disk=$1 - ask_yn "Do you want to use *all* of $_disk for OpenBSD?" + ask_yn "Do you want to use *all* of $_disk for OpenBSD?" "" \ + $(unattended_val u_disk "$_disk" usealldisk) if [[ $resp == y ]]; then echo -n "Putting all of $_disk into an active OpenBSD MBR partition (type 'A6')..." fdisk -e ${_disk} << __EOT > /dev/null @@ -142,7 +145,13 @@ $(fdisk ${_disk}) __EOT - fdisk -e ${_disk} + if [[ -n $(unattended_val u_disk "$_disk" fdisk) ]]; then + echo "$(unattended_val u_disk "$_disk" fdisk)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | fdisk -e ${_disk} + else + fdisk -e ${_disk} + fi cat << __EOT Here is the partition information you chose: @@ -174,7 +183,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/i386/common/list =================================================================== --- distrib/i386/common/list (revision 15) +++ distrib/i386/common/list (revision 19) @@ -83,3 +83,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/ramdisk/list =================================================================== --- distrib/ramdisk/list (revision 15) +++ distrib/ramdisk/list (revision 19) @@ -63,3 +63,5 @@ SCRIPT ${CURDIR}/../miniroot/install.sh install SCRIPT ${CURDIR}/../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../miniroot/unattended.conf unattended.conf Index: distrib/hp300/ramdisk/install.md =================================================================== --- distrib/hp300/ramdisk/install.md (revision 15) +++ distrib/hp300/ramdisk/install.md (revision 19) @@ -78,7 +78,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/hp300/ramdisk/list =================================================================== --- distrib/hp300/ramdisk/list (revision 15) +++ distrib/hp300/ramdisk/list (revision 19) @@ -77,5 +77,7 @@ SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf + # so DNS can work SYMLINK /tmp/resolv.conf.shadow etc/resolv.conf Index: distrib/cats/ramdisk/install.md =================================================================== --- distrib/cats/ramdisk/install.md (revision 15) +++ distrib/cats/ramdisk/install.md (revision 19) @@ -63,7 +63,8 @@ __EOT while : ; do - ask "Use BSD or MBR partition table?" BSD + ask "Use BSD or MBR partition table?" BSD \ + $(unattended_val u_disk "$_disk" partitiontabletype) _resp=$resp case $_resp in m|mbr) export disklabeltype=MBR @@ -88,11 +89,13 @@ partitions and BSD partition table. __EOT - ask_yn "Are you *sure* you want an MBR partition table on $_disk?" + ask_yn "Are you *sure* you want an MBR partition table on $_disk?" "" \ + $(unattended_val u_disk "$_disk" partitiontableconfirm) [[ $resp == n ]] && exit fi - ask_yn "Use *all* of $_disk for OpenBSD?" + ask_yn "Use *all* of $_disk for OpenBSD?" "" \ + $(unattended_val u_disk "$_disk" usealldisk) if [[ $resp == y ]]; then echo -n "Creating Master Boot Record (MBR)..." fdisk -e $_disk >/dev/null 2>&1 << __EOT @@ -127,7 +130,13 @@ __EOT - fdisk -e $_disk + if [[ -n $(unattended_val u_disk "$_disk" fdisk) ]]; then + echo "$(unattended_val u_disk "$_disk" fdisk)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | fdisk -e ${_disk} + else + fdisk -e ${_disk} + fi cat << __EOT Here is the MBR configuration you chose: @@ -181,7 +190,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -c -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -c -f /tmp/fstab.$_disk -E $_disk + else + disklabel -c -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/cats/ramdisk/list =================================================================== --- distrib/cats/ramdisk/list (revision 15) +++ distrib/cats/ramdisk/list (revision 19) @@ -82,3 +82,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/luna88k/ramdisk/install.md =================================================================== --- distrib/luna88k/ramdisk/install.md (revision 15) +++ distrib/luna88k/ramdisk/install.md (revision 19) @@ -72,7 +72,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/luna88k/ramdisk/list =================================================================== --- distrib/luna88k/ramdisk/list (revision 15) +++ distrib/luna88k/ramdisk/list (revision 19) @@ -74,3 +74,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/mvme68k/ramdisk/install.md =================================================================== --- distrib/mvme68k/ramdisk/install.md (revision 15) +++ distrib/mvme68k/ramdisk/install.md (revision 19) @@ -74,7 +74,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/mvme68k/ramdisk/list =================================================================== --- distrib/mvme68k/ramdisk/list (revision 15) +++ distrib/mvme68k/ramdisk/list (revision 19) @@ -80,3 +80,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/vax/install.md =================================================================== --- distrib/vax/install.md (revision 15) +++ distrib/vax/install.md (revision 19) @@ -78,7 +78,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/mvme88k/ramdisk/install.md =================================================================== --- distrib/mvme88k/ramdisk/install.md (revision 15) +++ distrib/mvme88k/ramdisk/install.md (revision 19) @@ -74,7 +74,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/mvme88k/ramdisk/list =================================================================== --- distrib/mvme88k/ramdisk/list (revision 15) +++ distrib/mvme88k/ramdisk/list (revision 19) @@ -80,3 +80,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/miniroot/install.sh =================================================================== --- distrib/miniroot/install.sh (revision 15) +++ distrib/miniroot/install.sh (revision 19) @@ -72,6 +72,7 @@ # install.sub needs to know the MODE MODE=install +SUBMODE="$1" # include common subroutines and initialization code . install.sub @@ -100,11 +101,13 @@ else # Force the user to think and type in a disk name by # making 'done' the default choice. - ask_which "disk" "do you wish to initialize" "$_DKDEVS" done "No more disks to initialize" + # XXX: we rely on ask_which to discard extra arguments + ask_which "disk" "do you wish to initialize" "$_DKDEVS" done "No more disks to initialize" $u_disks [[ $resp == done ]] && break fi DISK=$resp + u_disks=$(rmel "${u_disks%% *}" $u_disks) # Deal with disklabels, including editing the root disklabel # and labeling additional disks. This is machine-dependent since @@ -168,7 +171,10 @@ _mp=${_mount_points[$_i]} # Get the mount point from the user - ask "Mount point for ${_pp} (size=${_ps}k)? (or 'none' or 'done')" "$_mp" + # Possibly skip verification for unattended installs + resp=$(unattended_val u_disk "$DISK" verifymountpoints) + [[ $resp == no ]] && resp=done || resp= + ask "Mount point for ${_pp} (size=${_ps}k)? (or 'none' or 'done')" "$_mp" $resp case $resp in "") ;; none) _mp= @@ -223,9 +229,8 @@ The next step *DESTROYS* all existing data on these partitions! __EOT - ask_yn "Are you really sure that you're ready to proceed?" + ask_yn "Are you really sure that you're ready to proceed?" "" $u_disks_autoformat [[ $resp == n ]] && { echo "Ok, try again later." ; exit ; } - # Read $FILESYSTEMS, creating a new filesystem on each listed # partition and saving the partition and mount point information # for subsequent sorting by mount point. @@ -317,7 +322,7 @@ # # Only apply the new value if the new short form name differs from the existing # one. This preserves any existing domain information in the hostname. -ask_until "\nSystem hostname? (short form, e.g. 'foo')" "$(hostname -s)" +ask_until "\nSystem hostname? (short form, e.g. 'foo')" "$(hostname -s)" $u_net_hostname [[ ${resp%%.*} != $(hostname -s) ]] && hostname $resp # Remove existing network configuration files in /tmp to ensure they don't leak @@ -334,17 +339,17 @@ 127.0.0.1 $(hostname -s) __EOT -ask_yn "Configure the network?" yes +ask_yn "Configure the network?" yes $u_net_configure [[ $resp == y ]] && donetconfig _oifs=$IFS IFS= resp= while [[ -z $resp ]]; do - askpass "Password for root account? (will not echo)" + askpass "Password for root account? (will not echo)" "$u_system_rootpassword" _password=$resp - askpass "Password for root account? (again)" + askpass "Password for root account? (again)" "$u_system_rootpassword" if [ "$_password" != "$resp" ]; then echo "Passwords do not match, try again." resp= @@ -352,7 +357,10 @@ done IFS=$_oifs -install_sets +# Use defined sets for unattended installs, or force a single empty argument +for u_cursetdef in ${u_setdefinitions:-""}; do + install_sets +done # Remount all filesystems in /etc/fstab with the options from /etc/fstab, i.e. # without any options such as async which may have been used in the first Index: distrib/miniroot/unattended.conf =================================================================== --- distrib/miniroot/unattended.conf (revision 0) +++ distrib/miniroot/unattended.conf (revision 19) @@ -0,0 +1,276 @@ +# TODO: answer questions about mount points (/Mount point for/ install.sh) + +# +# The following variables set by the installer can be useful below. +# The example values are based on OpenBSD 3.6 for i386. +# NOTE: if you use other variables, please don't clash with the installer or +# other variables for the unattended installer. If in doubt, prefix +# variables with "u_priv_". +# +# variable example value +# -------- ------------- +# VERSION 36 +# VNAME 3.6 +# ARCH i386 +# SETDIR 3.6/i386 +# FTPDIR pub/OpenBSD/3.6 +# MDSETS (unset for i386, but set for other ARCHS) +# THESETS bsd bsd.rd bsd.mp $MDSETS \ +# base36.tgz etc36.tgz misc36.tgz comp36.tgz man36.tgz \ +# game36.tgz xbase36.tgz xetc36.tgz xshare36.tgz \ +# xfont36.tgz xserv36.tgz site36.tgz +# DEFAULTSETS bsd bsd.rd base36.tgz \ +# etc36.tgz misc36.tgz comp36.tgz man36.tgz game36.tgz +# MDTERM (default TERM value - unset for i386, but set for other ARCHs) +# IFDEVS (machine dependent - can be used to distinguish machines) +# u_MACS (machine dependent - list of MAC addresses) +# + +# +# General settings for the installer. +# +u_installer_acceptdefaults=no # If yes, accept most default values +u_installer_autorun=yes # Do automatic install (say yes) +u_installer_autoreboot=yes # Automatically reboot when finished + +u_installer_terminal=vt220 +u_installer_setkbdencoding=no # amd64, i386 +u_installer_kbdtype=PC-AT/XT # amd64, i386 +u_installer_kbdencoding=es # amd64, i386 + +# +# System Configuration +# +u_system_rootpassword=snoevsen # XXX: change me immediately. +u_system_startsshd=yes +u_system_runX=no +u_system_changedefcon=yes +u_system_conspeed=9600 +u_system_timezone=GMT +#u_system_subtimezone= + +# +# Disk handling +# +u_disks=wd0 # first one is the root disk +u_disk_verifymountpoints=no +u_disks_autoformat=yes + +u_disk_usealldisk=no # amd64, cats(MBR), i386, macppc(MBR) +u_disk_fdisk="quit" # amd64, cats(MBR), i386, macppc(MBR) +u_disk_pdisk="q" # macppc(HFS) + +#u_disk_partitiontabletype=XXX # cats (BSD/MBR), macppc (HFS/MBR) +#u_disk_partitiontableconfirm=yes # cats(MBR), macppc (MBR) + +#u_disk_volumeheaderoverwrite=yes # sgi (yes skips next two questions) +#u_disk_volumeheaderkeepold=yes # sgi (yes skips next question) +#u_disk_volumeheaderoverwriteold=no # sgi +#u_disk_ignoreunaccessibledisk=no # sgi +#u_disk_ignoremissingheader=yes # sgi + +u_disk_wd0_label=" + d a + d b + d d + d f + a a \n \n 300M \n 4.2BSD \n / + a b \n \n 100M \n swap \n + a d \n \n 100M \n 4.2BSD \n /tmp + a f \n \n \n 4.2BSD \n /usr + p m + w + q" + +# +# Network configuration +# +u_net_hostname=fiddler +u_net_configure=yes +u_net_fqdn=p.wielders.org +u_net_dns=192.168.1.1 +u_net_usedns=yes # use DNS during installation +u_net_defaultipv4route=dhcp +u_net_edithosts=no +u_net_manualconfig=no + +u_netifs="default" + +u_netif_changemedia=no +#u_netif_media="media autoselect" +u_netif_symname=symname +u_netif_ip4addr=dhcp +#u_net_ipv4netmask=255.255.255.0 + +# +# Sets to install +# +# Set definition names should not clash with individual options. +# If in doubt, use CAPS. +# +u_setdefinitions="default" + +# default values (as an example, some variables use _default_, some don't) +u_install_method=ftp # cdrom, disk, ftp, http, mounted, nfs, tape +u_install_default_proxy=none # ftp, http +u_install_default_listmirrors=no # ftp, http +u_install_default_server=sitemgr # ftp, http, nfs +u_install_default_dir=$FTPDIR/$ARCH # cdrom, disk, ftp, http, mounted, nfs +u_install_default_passiveftp=yes # ftp +u_install_user=anonymous # ftp +u_install_device=default # cdrom, disk, mounted, nfs +u_install_partition=default # cdrom, disk +u_install_fstype=default # cdrom, disk +u_install_exportpath=/exports/OpenBSD # nfs +u_install_nfsovertcp=no # nfs +u_install_fileno=1 # tape +u_install_tapefiletype=1 # tape (1 is tar.gz, 2 is tar files) +u_install_autoinstall=yes + +# default definition - default settings only +u_install_sets="$DEFAULTSETS site$VERSION.tgz" + +# +# MORE COMPLEX EXAMPLES +# + +# Find the host name by MAC address +if false; then : sort the elifs with sort -t= -k2 +elif isin 00:03:93:6a:9e:b2 $u_MACS; then u_priv_host=crowley +elif isin 08:00:20:7d:f7:70 $u_MACS; then u_priv_host=famine +elif isin 00:00:24:c2:ec:7c $u_MACS; then u_priv_host=fiddler +elif isin 00:50:bf:e0:d8:b3 $u_MACS; then u_priv_host=hastur +elif isin 08:00:20:78:0d:3f $u_MACS; then u_priv_host=war +fi + +# We could use u_net_hostname, but then we interfere with the basic example. +if [[ -n $u_priv_host ]]; then + u_net_hostname=$u_priv_host +fi + +echo +echo "===" +echo "=== Unattended installation of $u_net_fqdn" +echo "===" +echo "=== We give you three seconds to interrupt this procedure." +echo "===" +sleep 3 + +case $u_priv_host in +crowley) + u_disks=wd0 + u_disk_partitiontabletype=HFS + u_disk_pdisk="p \n q" + u_disk_wd0_label=" + b \n 88099616 \n 12565504 + d a \n d b \n d d \n d e \n d f \n d h + a a \n \n 256M \n 4.2BSD \n / + a b \n \n 512M \n swap \n + a d \n \n 256M \n 4.2BSD \n /tmp + a e \n \n 256M \n 4.2BSD \n /var + a f \n \n 3G \n 4.2BSD \n /usr + a h \n \n \n 4.2BSD \n /home + p m \n w \n q" + + u_netifs="gem0" + + u_install_sets="bsd base$VERSION.tgz etc$VERSION.tgz comp$VERSION.tgz site$VERSION.tgz" + + u_system_timezone=CET + ;; + +famine) + u_disks=sd0 + u_disk_sd0_label=" + d a \n d b + a a \n \n 1.8G \n 4.2BSD \n / + a b \n \n \n swap \n + p m \n w \n q" + + u_install_sets="bsd base$VERSION.tgz etc$VERSION.tgz site$VERSION.tgz" + ;; + +fiddler) + u_disk_wd0_label=" + d a \n d b \n d d \n d f + a a \n \n 300M \n 4.2BSD \n / + a b \n \n 100M \n swap \n + a d \n \n 100M \n 4.2BSD \n /tmp + a f \n \n \n 4.2BSD \n /usr + p m \n w \n q" + + u_netifs="sis0 sis1" + u_netif_sis1_symname=testing + u_netif_sis1_changemedia=yes + u_netif_sis1_media="media 100baseTX mediaopt full-duplex" + u_netif_sis1_ip4addr=192.168.4.1 + u_netif_sis1_ip4netmask=255.255.255.0 + + u_install_sets="bsd base$VERSION.tgz etc$VERSION.tgz comp$VERSION.tgz site$VERSION.tgz" + ;; + +hastur) + u_disk_wd0_label=" + d a \n d b \n d d \n d f + a a \n \n 300M \n 4.2BSD \n / + a b \n \n 100M \n swap \n + a d \n \n 100M \n 4.2BSD \n /tmp + a f \n \n \n 4.2BSD \n /usr + p m \n w \n q" + + # Cannot test NFS and TAPE here + u_setdefinitions="default CDROM DISK FTP FTP1 FTP2 HTTP MOUNTED" + + u_install_sets="bsd base$VERSION.tgz etc$VERSION.tgz" + + u_install_CDROM_sets="bsd.rd" + u_install_CDROM_method=cdrom + u_install_CDROM_fstype=cd9660 + u_install_CDROM_dir="$SETDIR" + + u_install_DISK_sets="comp$VERSION.tgz" + u_install_DISK_method=disk + u_install_DISK_dir=OpenBSD/$SETDIR + u_install_DISK_device=wd0 + u_install_DISK_partition=k + + u_install_FTP_sets="site$VERSION.tgz" + u_install_FTP_method=ftp + u_install_FTP_user=anonymous + u_install_FTP_passiveftp=no + + u_install_FTP1_sets="man$VERSION.tgz" + u_install_FTP1_method=ftp + u_install_FTP1_user=ftp + u_install_FTP1_password=peppe@wielders.org + + u_install_FTP2_sets="bsd.mp" + u_install_FTP2_method=ftp + u_install_FTP2_listmirrors=yes + u_install_FTP2_server=50 + u_install_FTP2_user=anonymous + + u_install_HTTP_sets="game$VERSION.tgz" + u_install_HTTP_method=http + u_install_HTTP_listmirrors=yes + u_install_HTTP_server=19 + + u_install_MOUNTED_sets="misc$VERSION.tgz" + u_install_MOUNTED_method=mounted + u_install_MOUNTED_dir=var/tmp + ;; + +war) + u_disks=sd0 + u_disk_sd0_label=" + d a \n d b + a a \n \n 1.8G \n 4.2BSD \n / + a b \n \n \n swap \n + p m \n w \n q" + + u_install_sets="bsd base$VERSION.tgz etc$VERSION.tgz comp$VERSION.tgz site$VERSION.tgz" + ;; + +esac + +# EOF Index: distrib/miniroot/dot.profile =================================================================== --- distrib/miniroot/dot.profile (revision 15) +++ distrib/miniroot/dot.profile (revision 19) @@ -55,15 +55,22 @@ # Installing or upgrading? _forceloop="" while [ "X$_forceloop" = X"" ]; do - echo -n '(I)nstall' - [ -f upgrade ] && echo -n ', (U)pgrade' - echo -n ' or (S)hell? ' - read _forceloop + # Run unattended right away, if possible + if [ -f unattended.conf ]; then + _forceloop=n + else + echo -n '(I)nstall' + [ -f upgrade ] && echo -n ', (U)pgrade' + echo -n ' or (S)hell? ' + read _forceloop + fi case "$_forceloop" in i*|I*) /install ;; u*|U*) /upgrade ;; + n*|N*) /install unattended + ;; s*|S*) ;; *) _forceloop="" ;; Index: distrib/miniroot/list =================================================================== --- distrib/miniroot/list (revision 15) +++ distrib/miniroot/list (revision 19) @@ -59,4 +59,6 @@ SCRIPT ${CURDIR}/upgrade.sh upgrade SCRIPT ${CURDIR}/install.sh install SCRIPT ${CURDIR}/install.sub install.sub -SPECIAL chmod 755 install upgrade +SPECIAL chmod 755 install upgrade + +COPY ${CURDIR}/unattended.conf unattended.conf Index: distrib/miniroot/install.sub =================================================================== --- distrib/miniroot/install.sub (revision 15) +++ distrib/miniroot/install.sub (revision 19) @@ -79,9 +79,24 @@ # MDXAPERTURE - if not empty, set machdep.allowaperture=value in sysctl.conf . install.md +# $1 - base for set +# $2 - optional device +# $3 - option +# Return the value of either $1_$2_$3, $1_default_$3 or $1_$3, in order. +unattended_val() { + local _var _val + for _var in "${1}_${2}_${3}" "${1}_default_${3}" "${1}_${3}"; do + eval _val=\"\$"$_var"\" + if [[ -n "$_val" ]]; then + echo "$_val" + break + fi + done +} + set_term() { [[ -n $TERM ]] && return - ask "Terminal type?" ${MDTERM:-vt220} + ask "Terminal type?" ${MDTERM:-vt220} $u_installer_terminal TERM=$resp export TERM @@ -144,7 +159,7 @@ ;; esac - ask_yn "$_q" + ask_yn "$_q" "" $u_installer_autorun if [[ $resp == n ]]; then cat << __EOT @@ -189,12 +204,21 @@ # Ask for a password, saving the input in $resp. # Display $1 as the prompt. +# Take $2 as password supplied by unattended installer # *Don't* allow the '!' options that ask does. # *Don't* echo input. askpass() { + local _unattended=$2 + + set -o noglob stty -echo - read resp?"$1 " + if [[ -n $_unattended ]]; then + echo "$1" + resp=$_unattended + else + read resp?"$1 " + fi stty echo set +o noglob echo @@ -204,18 +228,28 @@ # # $1 = the question to ask the user # $2 = the default answer +# $3 = answer supplied by unattended installer # # Save the user input (or the default) in $resp. # # Allow the user to escape to shells ('!') or execute commands # ('!foo') before entering the input. ask() { - local _question=$1 _default=$2 + local _question=$1 _default=$2 _unattended=$3 set -o noglob while : ; do echo -n "$_question " [[ -z $_default ]] || echo -n "[$_default] " + # If unattended, use the answer given in the answer file. + # Do NOT return here - just break the loop - or noglob is set. + if [[ -n $_unattended ]]; then + echo $_unattended && resp=$_unattended && break + elif [[ $u_installer_acceptdefaults == yes ]] \ + || [[ $u_installer_acceptdefaults == y ]]; then + # when no answer is given, assume the default is ok. + [[ -n $_default ]] && resp=$_default && break + fi read resp case $resp in !) echo "Type 'exit' to return to install." @@ -235,12 +269,13 @@ # # $1 = the question to ask the user # $2 = the default answer +# $3 = answer provided by unattended installer # # Save the user input (or the default) in $resp. ask_until() { resp= while [[ -z $resp ]] ; do - ask "$1" "$2" + ask "$1" "$2" "$3" done } @@ -248,14 +283,15 @@ # # $1 = the question to ask the user # $2 = the default answer (assumed to be 'n' if empty). +# $3 = the answer provided by the unattended installer # # Return 'y' or 'n' in $resp. ask_yn() { - local _q=$1 _a=${2:-no} _resp + local _q=$1 _a=${2:-no} _resp _unattended=$3 typeset -l _resp while : ; do - ask "$_q" "$_a" + ask "$_q" "$_a" "$_unattended" _resp=$resp case $_resp in y|yes) resp=y ; return ;; @@ -272,10 +308,11 @@ # $3 = list of devices from /var/run/dmesg.boot scan # $4 = default device. If it is not specified, use the first device in $3 # $5 = error message if no devices in $3, defaults to 'No $1s found.' +# $6 = value supplied by the unattended installer # # $resp holds device selected at exit, or 'done' ask_which() { - local _name=$1 _query=$2 _devs=$3 _defdev=$4 _err=$5 + local _name=$1 _query=$2 _devs=$3 _defdev=$4 _err=$5 _unattended=$6 set -- $_devs if [[ $# -lt 1 ]]; then @@ -292,8 +329,9 @@ # Put both lines in ask prompt, rather than use a # separate 'echo' to ensure the entire question is # re-ask'ed after a '!' or '!foo' shell escape. - ask "Available ${_name}s are: ${_devs}.\nWhich one ${_query}? (or 'done')" "$_defdev" + ask "Available ${_name}s are: ${_devs}.\nWhich one ${_query}? (or 'done')" "$_defdev" $_unattended [[ $resp == done ]] && break + [[ $resp == default ]] && resp=$_defdev # Quote $resp to prevent user from confusing isin() by # entering something like 'a a'. @@ -379,16 +417,17 @@ # # $1 == file in /tmp to edit edit_tmp_file() { - local _file=$1 + local _file=$1 _unattended=$2 - ask_yn "Edit $_file with $EDITOR?" + ask_yn "Edit $_file with $EDITOR?" "" "$_unattended" [[ $resp == y ]] && $EDITOR /tmp/$_file } # Offer to shell out for manual network configuration, and do so if # the user accepts the offer. manual_net_cfg() { - ask_yn "Do you want to do any manual network configuration?" + ask_yn "Do you want to do any manual network configuration?" "" \ + $u_net_manualconfig [[ $resp == y ]] && { echo "Type 'exit' to return to $MODE." ; sh ; } } @@ -449,11 +488,14 @@ # # $1 = available sets # $2 = already selected sets +# $3 = list of sets supplied by unattended installer # # Set $resp to list of selected sets. select_sets() { - local _avail=$1 _selected=$2 _next _f _action + local _avail=$1 _selected=$2 _next _f _action _unattended=$3 + [[ -n $_unattended ]] && _selected=$_unattended + while : ; do _action= cat << __EOT @@ -474,7 +516,11 @@ done : ${_next:=done} - ask "\nFile name? (or 'done')" "$_next" + if [[ -n $_unattended ]]; then + ask "\nFile name? (or 'done')" "$_next" 'done' + else + ask "\nFile name? (or 'done')" "$_next" + fi case $resp in done) break ;; -*) _action=rmel ;; @@ -504,16 +550,20 @@ configure_ifs() { local _IFDEVS=$IFDEVS _ifs _name _media _hn + [[ -n $u_netifs ]] && u_netifs="$u_netifs done" + while : ; do + # XXX: we rely on ask_which to discard extra arguments ask_which "interface" "do you wish to initialize" "$_IFDEVS" \ - "" "No more interfaces to initialize" + "" "No more interfaces to initialize" $u_netifs [[ $resp == done ]] && break _ifs=$resp _hn=/tmp/hostname.$_ifs # Get symbolic name - will be used in DHCP requests. - ask "Symbolic (host) name for $_ifs?" "$(hostname -s)" + ask "Symbolic (host) name for $_ifs?" "$(hostname -s)" \ + "$(unattended_val u_netif "$_ifs" symname)" _name=$resp # Get and apply media options. @@ -523,13 +573,15 @@ The media options for $_ifs are currently $(ifconfig -m $_ifs | sed -n '/supported/D;/media:/p') __EOT - ask_yn "Do you want to change the media options?" + ask_yn "Do you want to change the media options?" "" \ + "$(unattended_val u_netif "$_ifs" changemedia)" case $resp in y) cat << __EOT Supported media options for $_ifs are: $_media __EOT - ask "Media options for $_ifs?" + ask "Media options for $_ifs?" "" \ + "$(unattended_val u_netif "$_ifs" media)" _media=$resp ifconfig $_ifs $_media || return 1 ;; @@ -539,9 +591,14 @@ fi rm -f $_hn - v4_config "$_ifs" "$_media" "$_name" "$_hn" + v4_config "$_ifs" "$_media" "$_name" "$_hn" \ + $(unattended_val u_netif "$_ifs" ip4addr) \ + $(unattended_val u_netif "$_ifs" ip4netmask) - [[ -f $_hn ]] && _IFDEVS=$(rmel "$_ifs" $_IFDEVS) + if [[ -f $_hn ]]; then + _IFDEVS=$(rmel "$_ifs" $_IFDEVS) + u_netifs=$(rmel "${u_netifs%% *}" $u_netifs) + fi done } @@ -606,7 +663,7 @@ } v4_config() { - local _ifs=$1 _media=$2 _name=$3 _hn=$4 _prompt + local _ifs=$1 _media=$2 _name=$3 _hn=$4 _defaddr=$5 _defmask=$6 _prompt set -- $(v4_info $_ifs) if [[ -n $2 ]]; then @@ -617,7 +674,7 @@ [[ -x /sbin/dhclient ]] && _prompt=" or 'dhcp'" _prompt="IPv4 address for $_ifs? (or 'none'$_prompt)" - ask_until "$_prompt" "$_addr" + ask_until "$_prompt" "$_addr" "$_defaddr" case $resp in none) ;; dhcp) if [[ ! -x /sbin/dhclient ]]; then @@ -628,7 +685,7 @@ fi ;; *) _addr=$resp - ask_until "Netmask?" "${_mask:=255.255.255.0}" + ask_until "Netmask?" "${_mask:=255.255.255.0}" "$_defmask" if ifconfig $_ifs inet $_addr netmask $resp up ; then addhostent "$_addr" "$_name" echo "inet $_addr $resp NONE $_media" > $_hn @@ -647,7 +704,7 @@ [[ -f /tmp/dhclient.conf ]] && _dr=dhcp while : ; do - ask_until "$_prompt" "$_dr" + ask_until "$_prompt" "$_dr" "$u_net_defaultipv4route" case $resp in none|dhcp) break ;; esac @@ -831,13 +888,13 @@ __EOT return fi + + select_sets "$_sets" "$_get_sets" "$(unattended_val u_install "$u_cursetdef" sets)" - select_sets "$_sets" "$_get_sets" - [[ -n $resp ]] || return _get_sets=$resp - ask_yn "Ready to $MODE sets?" yes + ask_yn "Ready to $MODE sets?" yes "$u_install_autoinstall" [[ $resp = n ]] && return for _f in $THESETS ; do @@ -927,12 +984,13 @@ local _url_type=$1 _file_list _url_base _oifs _prompt _passwd ask "HTTP/FTP proxy URL? (e.g. 'http://proxy:8080', or 'none')" \ - "${ftp_proxy:-none}" + "${ftp_proxy:-none}" "$(unattended_val u_install "$u_cursetdef" proxy)" unset ftp_proxy http_proxy [[ $resp == none ]] || export ftp_proxy=$resp http_proxy=$resp rm -f $SERVERLIST - ask_yn "Display the list of known $_url_type servers?" "${_get_server_list:-yes}" + ask_yn "Display the list of known $_url_type servers?" "${_get_server_list:-yes}" \ + "$(unattended_val u_install "$u_cursetdef" listmirrors)" _get_server_list=$resp if [[ $_get_server_list == y ]]; then # ftp.openbsd.org == 129.128.5.191 and will remain at @@ -944,7 +1002,11 @@ if [[ -s $SERVERLIST ]]; then echo "done." _prompt="Server? (IP address, hostname, list#, 'done' or '?')" - cat -n $SERVERLIST | less -XE + if [[ $SUBMODE == unattended ]]; then + cat -n $SERVERLIST + else + cat -n $SERVERLIST | less -XE + fi else echo "FAILED." cat /tmp/ftplisterr @@ -955,7 +1017,8 @@ : ${_prompt:="Server? (IP address, hostname or 'done')"} while : ; do eval resp=\$_${_url_type}_server_ip - ask_until "$_prompt" "$resp" + ask_until "$_prompt" "$resp" \ + "$(unattended_val u_install "$u_cursetdef" server)" case $resp in done) return ;; "?") [[ -s $SERVERLIST ]] || continue @@ -971,6 +1034,8 @@ eval _${_url_type}_server_ip=${1%%/*} eval _${_url_type}_server_dir=${1#*/}/$SETDIR # Repeat loop to get user to confirm server address. + # Unless this is unattended, of course. + [[ -n "$(unattended_val u_install "$u_cursetdef" server)" ]] && break ;; *) eval _${_url_type}_server_ip=$resp break @@ -988,13 +1053,15 @@ esac unset _ftp_active - ask_yn "Does the server support passive mode ftp?" $resp + ask_yn "Does the server support passive mode ftp?" $resp \ + "$(unattended_val u_install "$u_cursetdef" passiveftp)" [[ $resp == n ]] && _ftp_active=-A fi # Get server directory eval resp=\$_${_url_type}_server_dir - ask_until "Server directory?" "${resp:-pub/OpenBSD/$SETDIR}" + ask_until "Server directory?" "${resp:-pub/OpenBSD/$SETDIR}" \ + "$(unattended_val u_install "$u_cursetdef" dir)" eval _${_url_type}_server_dir=$resp if [[ $_url_type == ftp ]]; then @@ -1002,7 +1069,8 @@ # embedded blanks are preserved! _oifs=$IFS IFS= - ask_until "Login?" "${_ftp_server_login:=anonymous}" + ask_until "Login?" "${_ftp_server_login:=anonymous}" \ + "$(unattended_val u_install "$u_cursetdef" user)" _ftp_server_login=$resp # Get password unless anonymous @@ -1010,7 +1078,8 @@ if [[ $_ftp_server_login != anonymous ]]; then resp= while [[ -z $resp ]] ; do - askpass "Password? (will not echo)" + askpass "Password? (will not echo)" \ + "$(unattended_val u_install "$u_cursetdef" password)" done _passwd=$resp fi @@ -1040,11 +1109,12 @@ # $1 - mount point directory is relative to # $2 - default directory +# $3 - allows for preset path for unattended installations install_mounted_fs() { - local _mp=$1 _dir=$2 + local _mp=$1 _dir=$2 _unattended=$3 while : ; do - ask_until "Pathname to the sets? (or 'done')" "$_dir" + ask_until "Pathname to the sets? (or 'done')" "$_dir" "$_unattended" case $resp in done) return ;; @@ -1065,7 +1135,8 @@ install_cdrom() { local _drive _part _fstype _directory _n - ask_which "CD-ROM" "contains the ${MODE} media" "$CDDEVS" + ask_which "CD-ROM" "contains the ${MODE} media" "$CDDEVS" "" "" \ + "$(unattended_val u_install "$u_cursetdef" device)" [[ $resp == done ]] && return _drive=$resp @@ -1096,7 +1167,8 @@ # Get partition from user resp= while [ -z "$resp" ] ; do - ask "CD-ROM partition to mount? (normally 'c')" c + ask "CD-ROM partition to mount? (normally 'c')" c \ + "$(unattended_val u_install "$u_cursetdef" partition)" case $resp in [a-p]) _part=$resp @@ -1118,7 +1190,8 @@ __EOT resp= while [ -z "$resp" ] ; do - ask "Which filesystem type?" cd9660 + ask "Which filesystem type?" cd9660 \ + "$(unattended_val u_install "$u_cursetdef" fstype)" case $resp in cd9660|ffs) _fstype=$resp @@ -1139,7 +1212,8 @@ return fi - install_mounted_fs /mnt2 "$SETDIR" + install_mounted_fs /mnt2 "$SETDIR" \ + "$(unattended_val u_install "$u_cursetdef" dir)" umount -f /mnt2 > /dev/null 2>&1 } @@ -1150,7 +1224,8 @@ local _drive _def_partition _partition_range _partition local _fstype _fsopts - ask_which "disk" "contains the ${MODE} sets" "$DKDEVS" + ask_which "disk" "contains the ${MODE} sets" "$DKDEVS" "" "" \ + "$(unattended_val u_install "$u_cursetdef" device)" [[ $resp == done ]] && return 1 _drive=$resp @@ -1183,7 +1258,8 @@ resp= while [ -z "$resp" ]; do - ask "Partition?" "$_def_partition" + ask "Partition?" "$_def_partition" \ + "$(unattended_val u_install "$u_cursetdef" partition)" case $resp in $_partition_range) _partition=$resp @@ -1206,7 +1282,8 @@ resp= while [ -z "$resp" ]; do - ask "Which filesystem type?" default + ask "Which filesystem type?" default \ + "$(unattended_val u_install "$u_cursetdef" fstype)" case $resp in default) ;; @@ -1235,7 +1312,8 @@ install_disk() { if mount_a_disk; then - install_mounted_fs /mnt2 + install_mounted_fs /mnt2 "" \ + "$(unattended_val u_install "$u_cursetdef" dir)" umount -f /mnt2 > /dev/null 2>&1 fi } @@ -1248,16 +1326,19 @@ fi # Get the IP address of the server - ask_until "Server IP address or hostname?" "$_nfs_server_ip" + ask_until "Server IP address or hostname?" "$_nfs_server_ip" \ + "$(unattended_val u_install "$u_cursetdef" server)" _nfs_server_ip=$resp # Get server path to mount - ask_until "Filesystem on server to mount?" "$_nfs_server_path" + ask_until "Filesystem on server to mount?" "$_nfs_server_path" \ + "$(unattended_val u_install "$u_cursetdef" exportpath)" _nfs_server_path=$resp # Determine use of TCP _nfs_tcp= - ask_yn "Use TCP transport? (only works with capable NFS server)" + ask_yn "Use TCP transport? (only works with capable NFS server)" "" \ + "$(unattended_val u_install "$u_cursetdef" nfsovertcp)" [[ $resp == y ]] && _nfs_tcp=-T # Mount the server @@ -1266,7 +1347,8 @@ return fi - install_mounted_fs /mnt2 + install_mounted_fs /mnt2 "" \ + "$(unattended_val u_install "$u_cursetdef" dir)" umount -f /mnt2 > /dev/null 2>&1 } @@ -1280,7 +1362,8 @@ sure you use a "no rewind on close" device. __EOT - ask_until "Name of tape device?" "${TAPE##*/}" + ask_until "Name of tape device?" "${TAPE##*/}" \ + "$(unattended_val u_install "$u_cursetdef" device)" TAPE=/dev/${resp##*/} if [ ! -c $TAPE ]; then echo "$TAPE does not exist or is not a character special file." @@ -1299,7 +1382,8 @@ # Get the file number resp= while [ -z "$resp" ]; do - ask "File number?" + ask "File number?" "" \ + "$(unattended_val u_install "$u_cursetdef" fileno)" case $resp in [1-9]*) _nskip=$(( $resp - 1 )) ;; @@ -1331,7 +1415,8 @@ resp= while [ -z "$resp" ]; do - ask "Which way is it?" 1 + ask "Which way is it?" 1 \ + "$(unattended_val u_install "$u_cursetdef" tapefiletype)" case $resp in 1) _xcmd="tar zxvphf -" ;; @@ -1365,7 +1450,7 @@ while : ; do _zonepath=$_zoneroot - ask "What timezone are you in? ('?' for list)" "$TZ" + ask "What timezone are you in? ('?' for list)" "$TZ" "$u_system_timezone" if [[ $resp == ? ]]; then ls -F ${_zonepath} @@ -1375,7 +1460,7 @@ _zonepath=${_zonepath}${resp} while [[ -d $_zonepath ]]; do - ask "What sub-timezone of '${_zonepath#$_zoneroot}' are you in? ('?' for list)" + ask "What sub-timezone of '${_zonepath#$_zoneroot}' are you in? ('?' for list)" "" "$u_system_subtimezone" case $resp in "") ;; ?) ls -F $_zonepath ;; @@ -1462,7 +1547,8 @@ device; or a (f)tp, (n)fs or (h)ttp server. __EOT [[ -z $DEFAULTSETS ]] && _d=done - ask "Where are the $MODE sets? (or 'done')" "$_d" + ask "Where are the $MODE sets? (or 'done')" "$_d" \ + $(unattended_val u_install "$u_cursetdef" method) case $resp in done) sane_install && return ;; @@ -1470,11 +1556,14 @@ d*|D*) install_disk ;; f*|F*) install_url ftp ;; h*|H*) install_url http ;; - m*|M*) install_mounted_fs /mnt ;; + m*|M*) install_mounted_fs /mnt "" \ + "$(unattended_val u_install "$u_cursetdef" dir)" ;; n*|N*) install_nfs ;; t*|T*) install_tape ;; *) ;; esac + + [[ -n $(unattended_val u_install "$u_cursetdef" method) ]] && return done } @@ -1617,24 +1706,24 @@ fi # Get & apply fully qualified domain name to hostname. - ask "DNS domain name? (e.g. 'bar.com')" "${_dn:=$(get_fqdn)}" + ask "DNS domain name? (e.g. 'bar.com')" "${_dn:=$(get_fqdn)}" "$u_net_fqdn" hostname "$(hostname -s).$resp" # Get/Confirm nameservers, and construct appropriate resolv.conf. - ask "DNS nameserver? (IP address or 'none')" "${_ns:=none}" + ask "DNS nameserver? (IP address or 'none')" "${_ns:=none}" "$u_net_dns" if [[ $resp != none ]]; then echo "lookup file bind" > /tmp/resolv.conf for _ns in $resp; do echo "nameserver $_ns" >> /tmp/resolv.conf done - ask_yn "Use the nameserver now?" yes + ask_yn "Use the nameserver now?" yes "$u_net_usedns" [[ $resp == y ]] && cp /tmp/resolv.conf /tmp/resolv.conf.shadow fi # Get/Confirm an IPv4 default route if an IPv4 address was configured. [[ -n $(ifconfig -a | sed -ne '/[ ]inet .* broadcast /p') ]] && v4_defroute - edit_tmp_file hosts + edit_tmp_file hosts "$u_net_edithosts" manual_net_cfg } @@ -1647,14 +1736,14 @@ questions() { local _bd _td - ask_yn "Start sshd(8) by default?" yes + ask_yn "Start sshd(8) by default?" yes "$u_system_startsshd" if [[ $resp == n ]]; then echo "sshd_flags=NO # disabled during install" \ > /mnt/etc/rc.conf.local fi if [[ -n $MDXAPERTURE ]]; then - ask_yn "Do you expect to run the X Window System?" yes + ask_yn "Do you expect to run the X Window System?" yes "$u_system_runX" if [[ $resp == y ]]; then sed -e "/^#\(machdep\.allowaperture=${MDXAPERTURE}\)/s//\1 /" \ /mnt/etc/sysctl.conf > /tmp/sysctl.conf @@ -1665,9 +1754,10 @@ set -- $SERIALDEV _bd=$1 _td=$2 - ask_yn "Change the default console to $_bd?" + ask_yn "Change the default console to $_bd?" "" "$u_system_changedefcon" [[ $resp == n ]] && return - ask_which "speed" "should $_bd use" "9600 19200 38400 57600 115200" + ask_which "speed" "should $_bd use" "9600 19200 38400 57600 115200" \ + "" "" $u_system_conspeed [[ $resp == done ]] && return echo "set tty $_bd\nstty $_bd $resp" >>/mnt/etc/boot.conf sed -e "/^${_td}/s/std.9600/std.${resp}/" \ @@ -1718,8 +1808,20 @@ __EOT md_congrats + + # Reboot if the user asked us to. Let's hope the system doesn't + # boot from a media which offers unattended.conf + [[ $u_installer_autoreboot == yes ]] && reboot } +get_unattended() { + + # no local config available; configure network + donetconfig + # download config + download_config +} + # ####################################################################### # # Initial actions common to both installs and upgrades. @@ -1770,6 +1872,19 @@ DEFAULTSETS="$DEFAULTSETS ${_set}${VERSION}.tgz" done +# If 'install' was called with the 'unattended' argument, and +# there is no local answer file, ask user where to get it. +# If available, pick up answers for unattended install +# We only source this just before actively installing to allow the +# configuration file to use variables set so far. +if [[ $SUBMODE == unattended ]]; then + u_MACS=$(for _ifs in $IFDEVS; do + ifconfig $_ifs | sed -ne '/address: /s/.* //p'; + done) + [[ -f unattended.conf ]] || get_unattended + [[ -f unattended.conf ]] && . unattended.conf +fi + # decide upon an editor if [ -z "$EDITOR" ] ; then EDITOR=ed @@ -1798,7 +1913,8 @@ set -- $DKDEVS [[ $# -gt 1 ]] && _defdsk=done -ask_which "disk" "is the root disk" "$DKDEVS" "$_defdsk" +# XXX: we rely on ask_which to discard extra arguments +ask_which "disk" "is the root disk" "$DKDEVS" "$_defdsk" "" $u_disks [[ $resp == done ]] && exit ROOTDISK=$resp Index: distrib/macppc/ramdisk/install.md =================================================================== --- distrib/macppc/ramdisk/install.md (revision 15) +++ distrib/macppc/ramdisk/install.md (revision 19) @@ -81,7 +81,8 @@ __EOT while : ; do - ask "Use HFS or MBR partition table?" HFS + ask "Use HFS or MBR partition table?" HFS \ + $(unattended_val u_disk "$_disk" partitiontabletype) _resp=$resp case $_resp in m|mbr) export disklabeltype=MBR @@ -106,11 +107,13 @@ partitions and HFS partition table. __EOT - ask_yn "Are you *sure* you want an MBR partition table on $_disk?" + ask_yn "Are you *sure* you want an MBR partition table on $_disk?" "" \ + $(unattended_val u_disk "$_disk" partitiontableconfirm) [[ $resp == n ]] && exit fi - ask_yn "Use *all* of $_disk for OpenBSD?" + ask_yn "Use *all* of $_disk for OpenBSD?" "" \ + $(unattended_val u_disk "$_disk" usealldisk) if [[ $resp == y ]]; then echo -n "Creating Master Boot Record (MBR)..." fdisk -e $_disk >/dev/null 2>&1 << __EOT @@ -152,7 +155,13 @@ __EOT - fdisk -e $_disk + if [[ -n $(unattended_val u_disk "$_disk" fdisk) ]]; then + echo "$(unattended_val u_disk "$_disk" fdisk)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | fdisk -e ${_disk} + else + fdisk -e ${_disk} + fi cat << __EOT Here is the MBR configuration you chose: @@ -177,7 +186,13 @@ __EOT - pdisk /dev/${_disk}c + if [[ -n $(unattended_val u_disk "$_disk" fdisk) ]]; then + echo "$(unattended_val u_disk "$_disk" pdisk)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | pdisk /dev/${_disk}c + else + pdisk /dev/${_disk}c + fi } md_prep_disklabel() { @@ -202,7 +217,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -c -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -c -f /tmp/fstab.$_disk -E $_disk + else + disklabel -c -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/macppc/ramdisk/list =================================================================== --- distrib/macppc/ramdisk/list (revision 15) +++ distrib/macppc/ramdisk/list (revision 19) @@ -85,3 +85,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/mvmeppc/ramdisk/list =================================================================== --- distrib/mvmeppc/ramdisk/list (revision 15) +++ distrib/mvmeppc/ramdisk/list (revision 19) @@ -85,3 +85,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade sbin/dhclient-script + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: distrib/sparc/install.md =================================================================== --- distrib/sparc/install.md (revision 15) +++ distrib/sparc/install.md (revision 19) @@ -90,7 +90,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/amd64/common/install.md =================================================================== --- distrib/amd64/common/install.md (revision 15) +++ distrib/amd64/common/install.md (revision 19) @@ -48,11 +48,13 @@ md_set_term() { local _tables - ask_yn "Do you wish to select a keyboard encoding table?" + ask_yn "Do you wish to select a keyboard encoding table?" "" \ + $u_installer_setkbdencoding [[ $resp == n ]] && return while : ; do - ask "Select your keyboard type: (P)C-AT/XT, (U)SB or 'done'" P + ask "Select your keyboard type: (P)C-AT/XT, (U)SB or 'done'" P \ + $u_installer_kbdtype case $resp in P*|p*) _tables="be br de dk es fr it jp lt no pt ru sf sg sv ua uk us" ;; @@ -76,7 +78,7 @@ ${_tables} __EOT - ask "Table name? (or 'done')" us + ask "Table name? (or 'done')" us $u_installer_kbdencoding case $resp in done) ;; *) if kbd $resp ; then @@ -115,7 +117,8 @@ md_prep_fdisk() { local _disk=$1 - ask_yn "Do you want to use *all* of $_disk for OpenBSD?" + ask_yn "Do you want to use *all* of $_disk for OpenBSD?" "" \ + $(unattended_val u_disk "$_disk" usealldisk) if [[ $resp == y ]]; then echo -n "Putting all of $_disk into an active OpenBSD MBR partition (type 'A6')..." fdisk -e ${_disk} << __EOT > /dev/null @@ -139,7 +142,13 @@ $(fdisk ${_disk}) __EOT - fdisk -e ${_disk} + if [[ -n $(unattended_val u_disk "$_disk" fdisk) ]]; then + echo "$(unattended_val u_disk "$_disk" fdisk)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | fdisk -e ${_disk} + else + fdisk -e ${_disk} + fi cat << __EOT Here is the partition information you chose: @@ -171,7 +180,13 @@ esac disklabel -W $_disk >/dev/null 2>&1 - disklabel -f /tmp/fstab.$_disk -E $_disk + if [[ -n $(unattended_val u_disk "$_disk" label) ]]; then + echo "$(unattended_val u_disk "$_disk" label)" \ + | sed -e 'y/ / /;s/^ *//;s/ *\\n */\\n/g;s/ *$//' \ + | disklabel -f /tmp/fstab.$_disk -E $_disk + else + disklabel -f /tmp/fstab.$_disk -E $_disk + fi } md_congrats() { Index: distrib/amd64/common/list =================================================================== --- distrib/amd64/common/list (revision 15) +++ distrib/amd64/common/list (revision 19) @@ -79,3 +79,5 @@ SCRIPT ${CURDIR}/../../miniroot/install.sh install SCRIPT ${CURDIR}/../../miniroot/install.sub install.sub SPECIAL chmod 755 install upgrade + +COPY ${CURDIR}/../../miniroot/unattended.conf unattended.conf Index: share/man/man8/unattended.8 =================================================================== --- share/man/man8/unattended.8 (revision 0) +++ share/man/man8/unattended.8 (revision 19) @@ -0,0 +1,63 @@ +.\" -*- nroff -*- +.\" +.\" Copyright (c) 2004 Alex Holst & Preben Guldberg. All rights reserved. +.\" +.\" Redistribution and use in source and binary forms, with or without +.\" modification, are permitted provided that the following conditions +.\" are met: +.\" 1. Redistributions of source code must retain the above copyright +.\" notice, this list of conditions and the following disclaimer. +.\" 2. Redistributions in binary form must reproduce the above copyright +.\" notice, this list of conditions and the following disclaimer in the +.\" documentation and/or other materials provided with the distribution. +.\" +.\" THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR +.\" IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES +.\" OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. +.\" IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, +.\" INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT +.\" NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +.\" DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +.\" THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +.\" (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF +.\" THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +.\" +.\" $OpenBSD$ +.Dd October 31, 2004 +.Dt UNATTENDED 5 +.Os +.Sh NAME +.Nm unattended +.Nd install OpenBSD using predefined responses +.Sh DESCRIPTION +The OpenBSD installer has the ability to read answers from a +configuration file, +.Pa unattended.conf , +instead of interactively prompting the user. This allows for building +large numbers of identical systems as well as making it very easy for +administrators of single machines to upgrade to the latest version. +Unattended installation support is the foundation of a good disaster +recovery plan. +.Pp +The configuration file may be present on the install +media (as is the case when using customized media) or can be loaded +from another source (as may be the case when using official media). If +.Pa unattended.conf +is present on the media, the installer will immediately begin network +configuration, wiping the system's disks and downloading the specified +install sets. +.Pp +During an attended installation, the installer provides defaults for +certain questions. This feature has been preserved when running in +unattended mode. Questions which have acceptable defaults need not +have answers specified in the configuration file. Questions which do +not have defaults at all are required in the configuration file if +a fully unattended install is to be achieved. This can be used as a +safety guard. Leaving out the response to the question "Do you want to +proceed with the install?" will cause the installer to stop and wait for +an interactive response. +.Pp +The possible +configuration keywords and their meanings are as follows (note that +keywords are case-insensitive and arguments are case-sensitive): +.Bl -tag -width Ds