From e207704e939cfb460cd0b3a5d3cc35bcdc356d89 Mon Sep 17 00:00:00 2001 From: Seth Grover Date: Wed, 20 Mar 2024 15:09:48 -0600 Subject: [PATCH] working on idaholab/Malcolm#266, Malcolm ISO should format bigger drives for index and artifact storage, NOT DONE YET --- malcolm-iso/build.sh | 2 ++ .../normal/0900-setup-rc-local.hook.chroot | 18 ++++++++++++++++++ .../includes.binary/install/preseed_base.cfg | 1 + .../autostart/capture-format-wait.desktop | 7 +++++++ 4 files changed, 28 insertions(+) create mode 100644 malcolm-iso/config/includes.chroot/etc/skel/.config/autostart/capture-format-wait.desktop diff --git a/malcolm-iso/build.sh b/malcolm-iso/build.sh index 684eacff7..838f72248 100755 --- a/malcolm-iso/build.sh +++ b/malcolm-iso/build.sh @@ -77,6 +77,8 @@ if [ -d "$WORKDIR" ]; then cp ./config/includes.binary/install/preseed_multipar.cfg ./config/includes.binary/install/preseed_multipar_crypto.cfg cp ./config/includes.binary/install/preseed_base.cfg ./config/includes.binary/install/preseed_minimal.cfg sed -i "s@\(partman-auto/method[[:space:]]*string[[:space:]]*\)lvm@\1crypto@g" ./config/includes.binary/install/preseed_multipar_crypto.cfg + sed -i "s@\(/etc/capture_storage_format\)@\1.crypt@g" ./config/includes.binary/install/preseed_multipar_crypto.cfg + sed -i "s@\(/etc/capture_storage_format\)@\1.none@g" ./config/includes.binary/install/preseed_minimal.cfg # make sure we install the firmwares, etc. for PKG in firmware-linux \ diff --git a/malcolm-iso/config/hooks/normal/0900-setup-rc-local.hook.chroot b/malcolm-iso/config/hooks/normal/0900-setup-rc-local.hook.chroot index 71916acf7..656322c55 100755 --- a/malcolm-iso/config/hooks/normal/0900-setup-rc-local.hook.chroot +++ b/malcolm-iso/config/hooks/normal/0900-setup-rc-local.hook.chroot @@ -1,10 +1,28 @@ #!/bin/bash +# Copyright (c) 2024 Battelle Energy Alliance, LLC. All rights reserved. + sed -i 's/^exit 0//' /etc/rc.local 2>/dev/null cat << 'EOF' >> /etc/rc.local +# if this is the initial boot, format and set up storage drive(s) +if [ -f /etc/capture_storage_format.crypt ]; then + CAPTURE_STORAGE_FORMAT_FILE="/etc/capture_storage_format.crypt" + CAPTURE_STORAGE_FORMAT_FLAG="-c" +else + CAPTURE_STORAGE_FORMAT_FILE="/etc/capture_storage_format" + CAPTURE_STORAGE_FORMAT_FLAG="" +fi +if [ -f "$CAPTURE_STORAGE_FORMAT_FILE" ]; then + logger "Initializing disk(s) to store captured artifacts" + date >>/var/log/os-disk-config.log 2>&1 + python3 /usr/local/bin/os-disk-config.py -m hedgehog -u $CAPTURE_STORAGE_FORMAT_FLAG >>/var/log/os-disk-config.log 2>&1 + rm -f "$CAPTURE_STORAGE_FORMAT_FILE" +fi + # other agg-specific initialization prior to starting up +echo "Running Malcolm initialization" > /dev/tty0 /usr/local/bin/agg-init.sh systemctl mask ctrl-alt-del.target diff --git a/malcolm-iso/config/includes.binary/install/preseed_base.cfg b/malcolm-iso/config/includes.binary/install/preseed_base.cfg index f25b47593..7f0ebecb8 100644 --- a/malcolm-iso/config/includes.binary/install/preseed_base.cfg +++ b/malcolm-iso/config/includes.binary/install/preseed_base.cfg @@ -35,6 +35,7 @@ d-i preseed/late_command string \ echo 'deb http://deb.debian.org/debian bookworm main contrib non-free non-free-firmware' > /target/etc/apt/sources.list; \ echo 'deb http://security.debian.org/debian-security bookworm-security main contrib non-free' >> /target/etc/apt/sources.list; \ echo 'deb http://deb.debian.org/debian bookworm-updates main contrib non-free' >> /target/etc/apt/sources.list; \ + in-target touch /etc/capture_storage_format; \ in-target bash /usr/local/bin/agg-init.sh; \ in-target bash -c "(virt-what | grep -q vmware) || apt-get purge -y open-vm-tools-desktop"; \ in-target bash -c "(virt-what | grep -q virtualbox) || apt-get purge -y virtualbox-guest*"; \ diff --git a/malcolm-iso/config/includes.chroot/etc/skel/.config/autostart/capture-format-wait.desktop b/malcolm-iso/config/includes.chroot/etc/skel/.config/autostart/capture-format-wait.desktop new file mode 100644 index 000000000..8bc2f95a8 --- /dev/null +++ b/malcolm-iso/config/includes.chroot/etc/skel/.config/autostart/capture-format-wait.desktop @@ -0,0 +1,7 @@ +[Desktop Entry] +Encoding=UTF-8 +Name=capture-format-wait +Comment=Format Data Storage +Exec=/usr/local/bin/capture-format-wait.sh +Terminal=false +Type=Application