summaryrefslogtreecommitdiff
path: root/roles/installer/debian/preseed/templates/partman_early-command.sh.j2
blob: 4e8215c2071e506096f88ef7fbc63f9d24d1ed44 (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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh

umount -l /media || true


{% if install.disks.primary == "software-raid" %}
disks="{% for disk in install.disks.raid.members %}$(readlink -f {{ disk }}) {% endfor %}"

{% if (install.efi | default(false)) %}
idx=1
{% else %}
idx=0
{% endif %}
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"$((idx + 1))
    raid_members_lvm="$raid_members_lvm$disk"$((idx + 2))
  else
    raid_members_boot="$raid_members_boot$disk"p$((idx + 1))
    raid_members_lvm="$raid_members_lvm$disk"p$((idx + 2))
  fi
done
raid_config="{{ install.disks.raid.level }} {{ install.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 {{ install.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

mkdir -p /lib/partman/not-enough-space.d/
cat <<EOF > /lib/partman/not-enough-space.d/00-ansible
#!/bin/sh

. /usr/share/debconf/confmodule
db_input critical partman-auto/no_recipe || true
db_go || true

exit 1
EOF
chmod +x /lib/partman/not-enough-space.d/00-ansible