summaryrefslogtreecommitdiff
path: root/distrib/miniroot/install.sub
diff options
context:
space:
mode:
authorRobert Peichaer <rpe@cvs.openbsd.org>2015-05-14 10:58:56 +0000
committerRobert Peichaer <rpe@cvs.openbsd.org>2015-05-14 10:58:56 +0000
commitc9c99a2e152363ea4c36e8bc4a17ddf58b9885b1 (patch)
tree652a5af15b7eab1afc1ba65ef7cf914d5efcf5e4 /distrib/miniroot/install.sub
parent39183c26046b1e01300888fb5f730083e8c4936e (diff)
Extend autoinstall(8) to allow for <hostname>-<mode>.conf response files
and to put response files in a subdir of the webserver's document root. Based on diffs from Nathanael Rensen, thanks! While here fix a buglet introduced by the $_server -> $AI_SERVER change. OK krw, halex
Diffstat (limited to 'distrib/miniroot/install.sub')
-rw-r--r--distrib/miniroot/install.sub23
1 files changed, 13 insertions, 10 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 2d14bbdcfa2..9965d59bf49 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.836 2015/05/04 19:55:26 rpe Exp $
+# $OpenBSD: install.sub,v 1.837 2015/05/14 10:58:55 rpe Exp $
#
# Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback
# Copyright (c) 2015, Robert Peichaer <rpe@openbsd.org>
@@ -304,7 +304,7 @@ retrap() {
# Fetch response file for autoinstall.
get_responsefile() {
- local _rf _ifdev _mac _mode _lf
+ local _rf _ifdev _mac _mode _lf _hn _path
action=
[[ -f /auto_upgrade.conf ]] && _rf=/auto_upgrade.conf _mode=upgrade
@@ -313,8 +313,8 @@ get_responsefile() {
# Select a network interface for initial dhcp request.
# Ask if multiple were found and system was not netbooted.
- # Extract server ip address and installer mode from lease file.
- # Prime hostname with host-name option.
+ # Extract server ip address, installer mode and response file path
+ # from lease file. Prime hostname with host-name option.
for _ifdev in ''; do
[[ -x /sbin/dhclient ]] || break
set -- $(get_ifdevs netboot)
@@ -328,16 +328,19 @@ get_responsefile() {
[[ -n $_ifdev ]] && dhclient $_ifdev || break
_lf=/var/db/dhclient.leases.$_ifdev
export AI_SERVER=$(sed "/^ *next-server /!d;s///;s/;$//;q" $_lf)
- _mode=$(sed -E '/^ *filename "auto_(install|upgrade)";$/!d;s//\1/;q' $_lf)
- hostname "$(sed -E '/^ *option host-name "(.*)";$/!d;s//\1/;q' $_lf)"
+ _mode=$(sed -E '/^ *filename "(.*\/)?auto_(install|upgrade)";$/!d;s//\2/;q' $_lf)
+ _path=$(sed -E '/^ *filename "(.*\/)[^/]+";$/!d;s//\1/;q' $_lf)
+ _hn=$(sed -E '/^ *option host-name "(.*)";$/!d;s//\1/;q' $_lf)
+ hostname "$_hn"
done
# Fetch response file if server and mode are known, otherwise tell which
- # one was missing. First try to fetch mac-mode.conf, then mode.conf.
+ # one was missing. Try to fetch mac-mode.conf, then hostname-mode.conf,
+ # and finally mode.conf.
if [[ -n $AI_SERVER && -n $_mode ]]; then
_mac=$(ifconfig $_ifdev | sed 's/.*lladdr \(.*\)/\1/p;d')
- for _rf in {$_mac-,}$_mode; do
- _url="http://$AI_SERVER/$_rf.conf?path=$HTTP_SETDIR"
+ for _rf in {$_mac-,${_hn:+$_hn-,}}$_mode; do
+ _url="http://$AI_SERVER/$_path$_rf.conf?path=$HTTP_SETDIR"
echo "Fetching $_url"
if ftp -Vo "/ai.$_mode.conf" "$_url" 2>/dev/null; then
action=$_mode
@@ -354,7 +357,7 @@ get_responsefile() {
# server was found in lease file.
while :; do
ask "Response file location?" \
- "${AI_SERVER:+http://$_server/install.conf}"
+ "${AI_SERVER:+http://$AI_SERVER/install.conf}"
[[ -n $resp ]] && _rf=$resp && break
done