Index | Thread | Search

From:
obsd@mulh.net
Subject:
Re: Allow autoinstall response file to select default answer
To:
tech@openbsd.org
Date:
Mon, 5 Oct 2026 07:26:07 -0400

Download raw body.

Thread
  • obsd@mulh.net:

    Allow autoinstall response file to select default answer

Updated diff to add missing semicolon.
Added comment about selecting default answer

I would like to propose a change to install.sub to
allow an autoinstall response file to be able to
select the default answer to a question.

The use case is for when using multiple sets locations.

Example:
First sets location is the CD image (or HTTP mirror).
The default "Pathname to the sets" varies by OpenBSD version.
Second sets location is a local path with the site*.tgz files.

Problem:
Need to install the main OpenBSD sets "before" the local site sets.
So how do you accept defaults for the main sets but then specify
specifics for local files?

Currently:
If I want to specify a path for the local site* files
I must also specify the CD's sets path (and update the response
file when using a different installation ISO).
  or
Create multiple local paths matching the CD's default paths and
put the site* files (or links) there. (and no location lines
in the response file)
  or
Create many slightly different response files and update dhcpd.conf
to select the version I'm needing.

Solution:
install.sub currently ignores "key=" (no value part) lines in the
response file.  Make it so a blank value selects the default answer,
similar to how you select the default in an interactive install.

This would allow for example:
  Location of sets = cd
  Pathname to the sets =
  Set name(s) =
  Directory does not contain = yes
  Location of sets = nfs
  Server IP address = local.example.org
  Filesystem on server = share
  Pathname to the sets = path/to/site/files
  Set name(s) = site*.tgz
  Directory does not contain = yes


Index: install.sub
===================================================================
RCS file: /cvs/src/distrib/miniroot/install.sub,v
diff -u -p -r1.1292 install.sub
--- install.sub	19 Sep 2026 19:52:10 -0000	1.1292
+++ install.sub	5 Oct 2026 10:54:31 -0000
@@ -731,6 +731,7 @@ get_responsefile() {
 # 2) split question (_key) and answer (_val) at leftmost =
 # 3) strip leading/trailing blanks
 # 4) compare questions case insensitive (typeset -l)
+# 5) a blank (_val) returns (_def) if set
 #
 _autorespond() {
 	typeset -l _q=$1 _key
@@ -740,11 +741,16 @@ _autorespond() {
 
 	mv /tmp/ai/ai.conf /tmp/ai/ai.conf.tmp
 	while IFS=' 	' read -r _l; do
-		[[ $_l == [!#=]*=?* ]] || continue
+		[[ $_l == [!#=]*=* ]] || continue
 		_key=${_l%%*([[:blank:]])=*}
 		_val=${_l##*([!=])=*([[:blank:]])}
 		[[ $_q == @(|*[[:blank:]])"$_key"@([[:blank:]?]*|) ]] &&
-			resp=$_val && cat && return
+			resp=$_val && cat &&
+				if [[ -n $resp ]]; then
+					return
+				else
+					break
+				fi
 		print -r " $_l"
 	done </tmp/ai/ai.conf.tmp >/tmp/ai/ai.conf
 	[[ -n $_def ]] && resp=$_def && return