From 1c60f71446cc017121121482e78ec077f285b9e8 Mon Sep 17 00:00:00 2001 From: Dominik Roth Date: Sun, 17 Aug 2025 23:36:37 +0200 Subject: [PATCH] auto detect drive names --- install.conf | 4 ++-- install.sh | 24 ++++++++++++++++++++++-- 2 files changed, 24 insertions(+), 4 deletions(-) diff --git a/install.conf b/install.conf index b18f5dc..a174213 100644 --- a/install.conf +++ b/install.conf @@ -1,5 +1,5 @@ -DRIVE1 /dev/sda -DRIVE2 /dev/sdb +DRIVE1 /dev/nvme0n1 +DRIVE2 /dev/nvme1n1 HOSTNAME nullpoint BOOTLOADER grub SWRAID 1 diff --git a/install.sh b/install.sh index 810416b..6fe0b3c 100644 --- a/install.sh +++ b/install.sh @@ -95,7 +95,28 @@ fi # Update install.conf echo "[+] Configuring installation..." cd /tmp/nullpoint -# Update install.conf with proper escaping + +# Auto-detect drives +echo "[+] Detecting drives..." +DRIVES=($(lsblk -dno NAME,TYPE | grep disk | awk '{print "/dev/"$1}' | sort)) +if [ ${#DRIVES[@]} -lt 2 ]; then + echo "ERROR: Need at least 2 drives for RAID1, found ${#DRIVES[@]}" + exit 1 +fi +DRIVE1="${DRIVES[0]}" +DRIVE2="${DRIVES[1]}" +echo " Found drives: $DRIVE1 and $DRIVE2" +# Update install.conf with detected drives +if ! sed -i "s|^DRIVE1 .*|DRIVE1 $DRIVE1|" install.conf; then + echo "ERROR: Failed to update DRIVE1 in install.conf" + exit 1 +fi +if ! sed -i "s|^DRIVE2 .*|DRIVE2 $DRIVE2|" install.conf; then + echo "ERROR: Failed to update DRIVE2 in install.conf" + exit 1 +fi + +# Update hostname if ! sed -i "s/^HOSTNAME .*/HOSTNAME $HOSTNAME/" install.conf; then echo "ERROR: Failed to update HOSTNAME in install.conf" exit 1 @@ -224,7 +245,6 @@ echo "The installer will now run. Follow any prompts if needed." echo "" if ! $INSTALLIMAGE_CMD -a -c /root/install.conf -s /root/post-install.sh; then echo -e "\nERROR: Installation failed!" - echo "Please check the error messages above." exit 1 fi