summaryrefslogtreecommitdiff
path: root/roles/installer/debian/preseed/templates/partman_early-command.sh.j2
diff options
context:
space:
mode:
Diffstat (limited to 'roles/installer/debian/preseed/templates/partman_early-command.sh.j2')
-rw-r--r--roles/installer/debian/preseed/templates/partman_early-command.sh.j233
1 files changed, 33 insertions, 0 deletions
diff --git a/roles/installer/debian/preseed/templates/partman_early-command.sh.j2 b/roles/installer/debian/preseed/templates/partman_early-command.sh.j2
new file mode 100644
index 00000000..9c720e92
--- /dev/null
+++ b/roles/installer/debian/preseed/templates/partman_early-command.sh.j2
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+umount -l /media || true
+
+
+{% if hostvars[install_hostname].install_cooked.disks.primary == "software-raid" %}
+disks="{% for disk in hostvars[install_hostname].install_cooked.disks.raid.members %}$(readlink -f {{ disk }}) {% endfor %}"
+
+raid_members_boot=""
+raid_members_lvm=""
+for disk in $disks; do
+ [ -n "$raid_members_boot" ] && raid_members_boot="$raid_members_boot#"
+ [ -n "$raid_members_lvm" ] && raid_members_lvm="$raid_members_lvm#"
+ if echo "$disk" | grep -Eq "/dev/(s|v)d[a-z]"; then
+ raid_members_boot="$raid_members_boot$disk"1
+ raid_members_lvm="$raid_members_lvm$disk"2
+ else
+ raid_members_boot="$raid_members_boot$disk"p1
+ raid_members_lvm="$raid_members_lvm$disk"p2
+ fi
+done
+raid_config="{{ hostvars[install_hostname].install_cooked.disks.raid.level }} {{ hostvars[install_hostname].install_cooked.disks.raid.members | length }} 0"
+
+debconf-set partman-auto-raid/recipe "$raid_config ext4 /boot $raid_members_boot . $raid_config lvm - $raid_members_lvm ."
+{% else %}
+disks="$(readlink -f {{ hostvars[install_hostname].install_cooked.disks.primary }})"
+{% endif %}
+debconf-set partman-auto/disk "$disks"
+debconf-set grub-installer/bootdev "$disks"
+
+## https://unix.stackexchange.com/questions/510445/install-grub-bootloader-dynamically-to-multiple-disks
+. /usr/share/debconf/confmodule
+db_fset grub-installer/bootdev seen true