-# $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>
# 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
# 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)
[[ -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
# 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
-.\" $OpenBSD: autoinstall.8,v 1.14 2015/05/05 07:20:42 jmc Exp $
+.\" $OpenBSD: autoinstall.8,v 1.15 2015/05/14 10:58:55 rpe Exp $
.\"
.\" Copyright (c) 2013 Robert Peichaer <rpe@openbsd.org>
.\"
.\" ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
.\" OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
.\"
-.Dd $Mdocdate: May 5 2015 $
+.Dd $Mdocdate: May 14 2015 $
.Dt AUTOINSTALL 8
.Os
.Sh NAME
.Pp
.Nm
uses HTTP to fetch one of the files
-.Pa install.conf
-or
+.Pa install.conf ,
.Ar MAC_address Ns - Ns Pa install.conf
-for install answers, or one of
-.Pa upgrade.conf
or
+.Ar hostname Ns - Ns Pa install.conf
+for install answers, or one of
+.Pa upgrade.conf ,
.Ar MAC_address Ns - Ns Pa upgrade.conf
+or
+.Ar hostname Ns - Ns Pa upgrade.conf
for upgrade answers.
The URL used to fetch the file is constructed from information provided in
the
.Sm off
.Bd -unfilled -offset indent
.No http:// Ar next-server No / Ar MAC_address No -install.conf
+.No http:// Ar next-server No / Ar hostname No -install.conf
.No http:// Ar next-server No /install.conf
.Ed
.Sm on
.Ar MAC_address
is a string of six hex octets separated by colons
representing the MAC
-address of the interface being used to fetch the files.
+address of the interface being used to fetch the files,
+and
+.Ar hostname
+is the hostname assigned to the system by DHCP.
.Pp
If
.Ar filename
.Sm off
.Bd -unfilled -offset indent
.No http:// Ar next-server No / Ar MAC_address No -upgrade.conf
+.No http:// Ar next-server No / Ar hostname No -upgrade.conf
.No http:// Ar next-server No /upgrade.conf
.Ed
.Sm on
or
.Cm auto_upgrade .
.Pp
+To use a subdirectory as response file location on the HTTP server, the same
+directory structure containig the symbolic links has to exist in the tftproot
+directory.
+The value of
+.Ic filename
+has to be the full path to these symbolic links.
+.Pp
Note that in these cases, the HTTP server and TFTP server must
be on the same machine.
.Pp