public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Aaron Lauterer <a.lauterer@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [RFC installer 3/6] add answer file fetch script
Date: Tue,  5 Sep 2023 15:28:29 +0200	[thread overview]
Message-ID: <20230905132832.3179097-4-a.lauterer@proxmox.com> (raw)
In-Reply-To: <20230905132832.3179097-1-a.lauterer@proxmox.com>

With the auto installer present, the crucial question is how we get the
answer file. This script implements the way of a local disk/partition
present, labelled 'proxmoxinst', lower or upper case, with the
'answer.toml' file in the root directory.

We either want to use it directly and call it from 'unconfigured.sh' or
see it as a first approach to showcase how it could be done.

Signed-off-by: Aaron Lauterer <a.lauterer@proxmox.com>
---
 start_autoinstall.sh | 50 ++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 50 insertions(+)
 create mode 100755 start_autoinstall.sh

diff --git a/start_autoinstall.sh b/start_autoinstall.sh
new file mode 100755
index 0000000..081b865
--- /dev/null
+++ b/start_autoinstall.sh
@@ -0,0 +1,50 @@
+#!/bin/bash
+
+answer_file=answer.toml;
+answer_mp=/tmp/answer;
+answer_location="";
+mount_source="";
+label="proxmoxinst";
+
+mount_answer() {
+    echo "mounting answer filesystem"
+    mkdir -p $answer_mp
+    mount "$mount_source" "$answer_mp"
+}
+
+find_fs() {
+    search_path="/dev/disk/by-label/";
+    if [[ -e ${search_path}/${label,,} ]]; then
+	mount_source="${search_path}/${label,,}";
+    elif [[ -e ${search_path}/${label^^} ]]; then
+	mount_source="${search_path}/${label^^}";
+    else
+	echo "No partition for answer file found!";
+	return 1;
+    fi
+    mount_answer;
+}
+
+find_answer_file() {
+    if [ -e $answer_mp/$answer_file ]; then
+	cp $answer_mp/$answer_file /run/proxmox-installer/answer.toml
+	answer_location=/run/proxmox-installer/answer.toml
+	umount $answer_mp;
+    else
+	return 1;
+    fi
+}
+
+start_installation() {
+    echo "calling 'proxmox-auto-installer'";
+    proxmox-auto-installer < $answer_location;
+}
+
+
+if find_fs && find_answer_file; then
+    echo "found answer file on local device";
+    start_installation;
+else
+    echo "Could not retrieve answer file. Aborting installation!"
+    exit 1;
+fi
-- 
2.39.2





  parent reply	other threads:[~2023-09-05 13:29 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-05 13:28 [pve-devel] [RFC installer 0/6] add automated installation Aaron Lauterer
2023-09-05 13:28 ` [pve-devel] [RFC installer 1/6] low level: sys: fetch udev properties Aaron Lauterer
2023-09-05 13:28 ` [pve-devel] [RFC installer 2/6] add proxmox-auto-installer Aaron Lauterer
2023-09-21 11:16   ` Christoph Heiss
2023-09-21 11:30     ` Thomas Lamprecht
2023-09-21 11:39       ` Christoph Heiss
2023-09-05 13:28 ` Aaron Lauterer [this message]
2023-09-20  9:52   ` [pve-devel] [RFC installer 3/6] add answer file fetch script Christoph Heiss
2023-09-05 13:28 ` [pve-devel] [PATCH installer 4/6] makefile: fix handling of multiple usr_bin files Aaron Lauterer
2023-09-05 13:28 ` [pve-devel] [RFC installer 5/6] makefile: add auto installer Aaron Lauterer
2023-09-05 13:28 ` [pve-devel] [RFC docs 6/6] installation: add unattended documentation Aaron Lauterer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230905132832.3179097-4-a.lauterer@proxmox.com \
    --to=a.lauterer@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal