diff options
author | Robert Peichaer <rpe@cvs.openbsd.org> | 2013-11-18 21:31:40 +0000 |
---|---|---|
committer | Robert Peichaer <rpe@cvs.openbsd.org> | 2013-11-18 21:31:40 +0000 |
commit | 2ee71438e413e1c90dba9d2bb674f2dd38bfeee0 (patch) | |
tree | 29a2227ff0d1b13d9f0c31cf9b1d201ffec81f96 /distrib/miniroot/install.sub | |
parent | 75be7807a411e6207dbddd94d0cbf7c832fe3c25 (diff) |
Extract the information whether to install or upgrade in unattended
mode from DHCP attribute "filename", which has to be "auto_install"
or "auto_upgrade". For archs that use this attribute for the boot
program create a symbolic link to auto_install and/or auto_install.
Change the naming scheme for response files on the http server to
<mac-addres>-<install|upgrade>.conf where <mac-address> is the
lladdr of the netboot interface of to be installed/upgraded hosts,
e.g. 52:54:00:12:34:56-install.conf. This allows different response
files for multiple hosts.
ok krw@ deraadt@
Diffstat (limited to 'distrib/miniroot/install.sub')
-rw-r--r-- | distrib/miniroot/install.sub | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub index 0e0365d95b4..8ea98c96077 100644 --- a/distrib/miniroot/install.sub +++ b/distrib/miniroot/install.sub @@ -1,4 +1,4 @@ -# $OpenBSD: install.sub,v 1.695 2013/11/13 19:17:22 rpe Exp $ +# $OpenBSD: install.sub,v 1.696 2013/11/18 21:31:39 rpe Exp $ # $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $ # # Copyright (c) 1997-2009 Todd Miller, Theo de Raadt, Ken Westerback @@ -2098,7 +2098,7 @@ done # Fetch a response file from the "netboot" interface. get_responsefile() { - local _bootdev _rf=$1 _server + local _bootdev _mac _mode _server # Fetching the response file requires DHCP, even if the # machine was booted via RARP and TFTP. [[ -x /sbin/dhclient ]] || return @@ -2115,32 +2115,37 @@ get_responsefile() { # background, so it doesn't matter how long the timeout is. dhclient $_bootdev - # Get the "next-server" address? + # Extract next-server IP and the installer mode from attributes + # in the dhcp lease file. Use this together with the MAC from the + # netboot interface to assemble the URL. _server=$(sed "/next-server/s/^.* \([^ ]*\);$/\1/p;d" \ /var/db/dhclient.leases.$_bootdev 2>/dev/null) - [[ -n $_server ]] || return - - ftp -o "$_rf" "http://$_server/install.conf" - [[ -s $1 ]] + _mode=$(sed -E '/filename/s/^.*auto_(install|upgrade).*$/\1/p;d' \ + /var/db/dhclient.leases.$_bootdev 2>/dev/null) + _mac=$(ifconfig $_bootdev | sed 's/.*lladdr \(.*\)/\1/p;d') + + ftp -o "/$_mode.conf" "http://$_server/$_mac-$_mode.conf" + [[ -s /$_mode.conf ]] && action=$_mode } # Fully automatic installation? if $auto && [[ -z $RESPONSEFILE ]]; then - responsefile=/install.conf - if ! get_responsefile $responsefile; then + action= + get_responsefile + if [[ -z $action ]]; then echo "No response file found; automatic installation aborted." exit 1 fi - echo -n "Performing non-interactive installation..." - RESPONSEFILE=$responsefile $0 auto >>/install.log 2>&1 <&- + echo -n "Performing non-interactive $action..." + RESPONSEFILE=/$action.conf /$action auto >>/$action.log 2>&1 <&- # XXX: Isn't the installer's exit code reliable? - if grep -q CONGRATULATIONS /install.log; then + if grep -q CONGRATULATIONS /$action.log; then echo "done." - cp /install.log /mnt/install.log + cp /$action.log /mnt/$action.log exec reboot else - echo "failed; check /install.log" + echo "failed; check /$action.log" exit 1 fi fi |