summaryrefslogtreecommitdiff
path: root/distrib/miniroot/install.sub
diff options
context:
space:
mode:
authorRobert Peichaer <rpe@cvs.openbsd.org>2017-05-25 12:10:05 +0000
committerRobert Peichaer <rpe@cvs.openbsd.org>2017-05-25 12:10:05 +0000
commitee99eb01f8f7d5a65b3520981c4db878baa9eea1 (patch)
tree79f1fec3af94f15f56641a4b77e5f7ea9f0ad95e /distrib/miniroot/install.sub
parent4fb0f7200ea5c0cfe325d4c7cfd23d79de752e65 (diff)
Move the code that runs the installer script in non-interactive
mode into a dedicated do_autoinstall() function. OK halex@, krw@
Diffstat (limited to 'distrib/miniroot/install.sub')
-rw-r--r--distrib/miniroot/install.sub29
1 files changed, 17 insertions, 12 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 07eab021e53..1678995e2c9 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,5 +1,5 @@
#!/bin/ksh
-# $OpenBSD: install.sub,v 1.1008 2017/05/25 08:25:00 rpe Exp $
+# $OpenBSD: install.sub,v 1.1009 2017/05/25 12:10:04 rpe Exp $
#
# Copyright (c) 1997-2015 Todd Miller, Theo de Raadt, Ken Westerback
# Copyright (c) 2015, Robert Peichaer <rpe@openbsd.org>
@@ -2662,6 +2662,21 @@ __EOT
$AUTO && >/tmp/ai/ai.done
}
+do_autoinstall() {
+ rm -f /tmp/ai/ai.done
+
+ echo "Performing non-interactive $AI_MODE..."
+ /$AI_MODE -af /tmp/ai/ai.$AI_MODE.conf 2>&1 </dev/null |
+ sed "s/^.*$(echo '\r')//;w/tmp/ai/ai.log"
+
+ [[ -f /tmp/ai/ai.done ]] || err_exit "failed; check /tmp/ai/ai.log"
+
+ # Email autoinstall protocol to root on next boot.
+ prep_root_mail /tmp/ai/ai.log "$(hostname) $AI_MODE log"
+
+ exec reboot
+}
+
do_install(){
local _rootkey _rootpass
@@ -3130,17 +3145,7 @@ elif [[ -z $RESPFILE ]]; then
get_responsefile ||
err_exit "No response file found; non-interactive mode aborted."
- rm -f /tmp/ai/ai.done
- echo "Performing non-interactive $AI_MODE..."
- /$AI_MODE -af /tmp/ai/ai.$AI_MODE.conf 2>&1 </dev/null |
- sed "s/^.*$(echo '\r')//;w/tmp/ai/ai.log"
- if [[ -f /tmp/ai/ai.done ]]; then
- # Email /tmp/ai/ai.log to root on next boot.
- prep_root_mail /tmp/ai/ai.log "$(hostname) $AI_MODE log"
- exec reboot
- else
- err_exit "failed; check /tmp/ai/ai.log"
- fi
+ do_autoinstall
else
cp $RESPFILE /tmp/ai/ai.conf || exit
fi