ref: master
./install.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 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 |
#!/bin/sh set -ex if [ -z "$1" ] then echo 'disk not given' exit 1 fi printf "auto lo\niface lo inet loopback\n\nauto eth0\niface eth0 inet dhcp\n" >/etc/network/interfaces /etc/init.d/networking restart { printf 'http://alpine.sakamoto.pl/alpine/edge/main\n' printf 'http://alpine.sakamoto.pl/alpine/edge/community\n' printf 'http://alpine.sakamoto.pl/alpine/edge/testing\n' } >/etc/apk/repositories while ! ip a | grep 192 do sleep 2 done apk update apk add sfdisk cryptsetup btrfs-progs e2fsprogs grub lvm2 mkinitfs util-linux man-pages docs font-terminus git dosfstools grub-efi efibootmgr grub-bios apk upgrade modprobe btrfs disk=$1 existing=$2 efi_partition="${disk}1" lvm_partition="${disk}2" setup-devd -C udev if [ -z "$existing" ] then printf 'This will destroy all data. Continue [y/N]: ' read -r confirmation if [ "$confirmation" != 'Y' ] && [ "$confirmation" != 'y' ] then printf 'Aborting\n' exit 0 fi printf "label: dos\nsize=512M,bootable,type=U\nsize=+" | sfdisk "$disk" # NOTE LUSK2 https://savannah.gnu.org/bugs/?55093 cryptsetup --verbose --verify-passphrase --cipher aes-xts-plain64 --iter-time 5000 --use-random luksFormat --type luks1 "$lvm_partition" cryptsetup open "$lvm_partition" bimba pvcreate /dev/mapper/bimba vgcreate bimba /dev/mapper/bimba lvcreate -L 2G bimba -n swap lvcreate -L 2G bimba -n boot lvcreate -l 100%FREE bimba -n root mkswap -L swap /dev/bimba/swap elif [ "$existing" = 'true' ] then printf 'Using existing disk structure\n' cryptsetup open "$lvm_partition" bimba /etc/init.d/lvm start fi mkfs.fat -F32 "$efi_partition" mkfs.ext4 /dev/bimba/boot mkfs.btrfs -f -L root /dev/bimba/root swapon /dev/bimba/swap setup-timezone Europe/Warsaw setup-hostname bimba setup-keymap pl pl grep 'adam' /etc/passwd || setup-user -a -f Adam adam passwd adam mkdir -p /home/adam chown adam:users /home/adam grep 'infra' /etc/passwd || setup-user infra rc-update add networking boot rc-update add seedrng boot rc-update add crond default rc-update add acpid default openrc boot openrc default setup-ntp chrony mount -t btrfs /dev/bimba/root /mnt mkdir -p /mnt/boot mount -t ext4 /dev/bimba/boot /mnt/boot # mkdir -p /mnt/boot/efi # mount -t vfat "$efi_partition" /mnt/boot/efi setup-disk -m sys /mnt mount -t proc /proc /mnt/proc mount --rbind /dev /mnt/dev mount --make-rslave /mnt/dev mount --rbind /sys /mnt/sys # mount --rbind /sys/firmware/efi/efiwars /mnt/sys/firmware/efi/efivars cp install-in-chroot.sh /mnt/ chroot /mnt /install-in-chroot.sh "$lvm_partition" "$disk" rm /mnt/install-in-chroot.sh cd umount -l /mnt/dev umount -l /mnt/proc # umount -l /mnt/sys/firmware/efi/efivars umount -l /mnt/sys # umount /mnt/boot/efi umount /mnt/boot swapoff /dev/bimba/swap umount /mnt vgchange -a n cryptsetup luksClose lvmcrypt |