summaryrefslogtreecommitdiff
path: root/roles/installer/debian/preseed/templates/partman_early-command.sh.j2
blob: 08d3806dc3ffb0945a26787f2e85d7f38b1970c8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/bin/sh

umount -l /media || true


{% if hostvars[install_hostname].install_cooked.disks.primary == "software-raid" %}
raid_disks="$(readlink -f {{ install_cooked.disks.raid.members | join(' ') }} | xargs)"
raid_config="{{ install_cooked.disks.raid.level }} {{ install_cooked.disks.raid.members | length }} 0"

raid_members_boot=""
raid_members_lvm=""
for disk in $raid_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"1
  else
    raid_members_boot="$raid_members_boot$disk"p1
    raid_members_lvm="$raid_members_lvm$disk"p1
  fi
done

debconf-set partman-auto-raid/recipe "$raid_config ext4 /boot $raid_members_boot . $raid_config lvm - $raid_members_lvm ."
debconf-set partman-auto/disk "$raid_disks"
debconf-set grub-installer/bootdev "$raid_disks"
{% else %}
debconf-set partman-auto/disk "$(readlink -f {{ hostvars[install_hostname].install_cooked.disks.primary }})"
debconf-set grub-installer/bootdev "$(readlink -f {{ hostvars[install_hostname].install_cooked.disks.primary }})"
{% endif %}

## https://unix.stackexchange.com/questions/510445/install-grub-bootloader-dynamically-to-multiple-disks
. /usr/share/debconf/confmodule
db_fset grub-installer/bootdev seen true