embankment.git

ref: master

./install-in-chroot.sh


 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
#!/bin/sh

set -ex

partition="$1"
disk="$2"

{
  printf 'GRUB_TIMEOUT=0\n'
  printf 'GRUB_ENABLE_CRYPTODISK=y\n'
  printf 'GRUB_DISABLE_SUBMENU=y\n'
  printf 'GRUB_DISABLE_RECOVERY=true\n'
  printf 'GRUB_PRELOAD_MODULES="luks cryptodisk part_gpt lvm"\n'
  printf 'GRUB_CMDLINE_LINUX_DEFAULT="modules=sd-mod,usb-storage,btrfs cryptroot=UUID=%s cryptdm=mycroft cryptkey quiet rootfstype=btrfs"\n' "$(blkid -s UUID -o value "$partition")"
} > /etc/default/grub
dd bs=12 count=4 if=/dev/random of=/crypto_keyfile.bin
chmod 000 /crypto_keyfile.bin
cryptsetup luksAddKey "$partition" /crypto_keyfile.bin
sed -i 's/features="/features="cryptkey /' /etc/mkinitfs/mkinitfs.conf
# shellcheck disable=SC2010
kernel=$(basename "$(ls /lib/modules | grep -v firmware | sort -V | head -n1)")
mkinitfs -c /etc/mkinitfs/mkinitfs.conf "$kernel"

grub-install --boot-directory=/boot "$disk" #--target=x86_64-efi --efi-directory=/boot/efi
grub-mkconfig -o /boot/grub/grub.cfg

{
  printf 'UUID=%s swap swap defaults 0 0\n' "$(blkid -s UUID -o value /dev/mycroft/swap)"
} >>/etc/fstab
rc-update add swap boot

cat >/tmp/init-git.sh <<END
cd /
git init
git remote add origin https://git.apiote.xyz/git/embankment.git
git fetch
git checkout origin/master -ft
END
su - infra -c 'sh /tmp/init-git.sh'
apk update
apk fix