[pve-devel] [RFC installer 3/6] add answer file fetch script

Aaron Lauterer a.lauterer at proxmox.com
Tue Sep 5 15:28:29 CEST 2023


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 at 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






More information about the pve-devel mailing list