pika-installer-gtk4/data/scripts/automatic-partition-install.sh

131 lines
6.3 KiB
Bash
Raw Normal View History

2024-01-22 18:14:41 +01:00
#! /bin/bash
2024-01-22 20:09:13 +01:00
set -e
2024-01-22 18:14:41 +01:00
DISK="$(cat "/tmp/pika-installer-gtk4-target-auto.txt")"
LOCALE="$(cat "/tmp/pika-installer-gtk4-lang.txt")"
2024-01-22 19:01:27 +01:00
KEYBOARD="$(cat "/tmp/pika-installer-gtk4-target-auto.txt")"
TIMEZONE="$(cat "/tmp/pika-installer-gtk4-timezone.txt")"
2024-01-22 18:14:41 +01:00
2024-01-23 15:19:10 +01:00
touch "/tmp/pika-installer-gtk4-status-parting.txt"
2024-01-22 18:14:41 +01:00
2024-01-22 18:57:18 +01:00
if [[ ! -f "/tmp/pika-installer-gtk4-target-automatic-luks.txt" ]]
2024-01-22 18:14:41 +01:00
then
2024-01-22 20:09:13 +01:00
wipefs -a /dev/${DISK}
2024-01-22 18:57:18 +01:00
# Partition the drives
2024-01-22 18:14:41 +01:00
parted -s -a optimal /dev/${DISK} mklabel gpt \
2024-01-22 18:57:18 +01:00
mkpart "linux-efi" 1MiB 513Mib \
mkpart "linux-boot" 513Mib 1537Mib \
mkpart "linux-root" 1537Mib 42497Mib \
mkpart "linux-home" 42497Mib 100% \
2024-01-22 18:14:41 +01:00
print
2024-01-22 18:57:18 +01:00
# add p to partition if it's nvme
2024-01-22 18:14:41 +01:00
if echo ${DISK} | grep -i "nvme"
then
2024-01-23 15:19:10 +01:00
#
while [[ ! -d /dev/${DISK}p1 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}p2 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}p3 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}p4 ]]; do sleep 2; done
2024-01-22 18:57:18 +01:00
# Add filesystems
2024-01-22 20:09:13 +01:00
yes | mkfs -t vfat -F 32 /dev/${DISK}p1
yes | mkfs -t ext4 /dev/${DISK}p2
yes | mkfs.btrfs -f /dev/${DISK}p3
yes | mkfs.btrfs -f /dev/${DISK}p4
2024-01-23 15:19:10 +01:00
sleep 2
2024-01-22 18:57:18 +01:00
# Begin Mounting
2024-01-22 18:14:41 +01:00
mkdir -p /media/pika-install-mount
mount /dev/${DISK}p3 /media/pika-install-mount/
mkdir -p /media/pika-install-mount/home
mount /dev/${DISK}p4 /media/pika-install-mount/home
mkdir -p /media/pika-install-mount/boot
mount /dev/${DISK}p2 /media/pika-install-mount/boot
mkdir -p /media/pika-install-mount/boot/efi
mount /dev/${DISK}p1 /media/pika-install-mount/boot/efi
pikainstall -r /media/pika-install-mount/ -b /media/pika-install-mount/boot -e /media/pika-install-mount/boot/efi -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt
else
2024-01-23 15:19:10 +01:00
while [[ ! -d /dev/${DISK}1 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}2 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}3 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}4 ]]; do sleep 2; done
2024-01-22 18:57:18 +01:00
# Add filesystems
2024-01-22 20:09:13 +01:00
yes | mkfs -t vfat -F 32 /dev/${DISK}1
yes | mkfs -t ext4 /dev/${DISK}2
yes | mkfs.btrfs -f /dev/${DISK}3
yes | mkfs.btrfs -f /dev/${DISK}4
2024-01-23 15:19:10 +01:00
sleep 2
2024-01-22 18:57:18 +01:00
# Begin Mounting
2024-01-22 18:14:41 +01:00
mkdir -p /media/pika-install-mount
mount /dev/${DISK}3 /media/pika-install-mount/
mkdir -p /media/pika-install-mount/home
mount /dev/${DISK}4 /media/pika-install-mount/home
mkdir -p /media/pika-install-mount/boot
mount /dev/${DISK}2 /media/pika-install-mount/boot
mkdir -p /media/pika-install-mount/boot/efi
mount /dev/${DISK}1 /media/pika-install-mount/boot/efi
pikainstall -r /media/pika-install-mount/ -b /media/pika-install-mount/boot -e /media/pika-install-mount/boot/efi -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt
fi
else
LUKS_KEY="$(cat "/tmp/pika-installer-gtk4-target-automatic-luks.txt")"
2024-01-22 20:32:48 +01:00
wipefs -a /dev/${DISK}
# Partition the drives
parted -s -a optimal /dev/${DISK} mklabel gpt \
mkpart "linux-efi" 1MiB 513Mib \
mkpart "linux-boot" 513Mib 1537Mib \
mkpart "linux-root" 1537Mib 42497Mib \
mkpart "linux-home" 42497Mib 100% \
print
# add p to partition if it's nvme
if echo ${DISK} | grep -i "nvme"
then
2024-01-23 15:19:10 +01:00
while [[ ! -d /dev/${DISK}p1 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}p2 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}p3 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}p4 ]]; do sleep 2; done
2024-01-22 20:32:48 +01:00
# Add filesystems
yes | mkfs -t vfat -F 32 /dev/${DISK}p1
yes | mkfs -t ext4 /dev/${DISK}p2
printf ${LUKS_KEY} | cryptsetup -q -v --type luks2 luksFormat /dev/${DISK}p3
printf ${LUKS_KEY} | cryptsetup -q -v --type luks2 luksFormat /dev/${DISK}p4
printf ${LUKS_KEY} | cryptsetup -q -v luksOpen /dev/${DISK}p3 crypt_root
printf ${LUKS_KEY} | cryptsetup -q -v luksOpen /dev/${DISK}p4 crypt_home
yes | mkfs.btrfs -f /dev/mapper/crypt_root
yes | mkfs.btrfs -f /dev/mapper/crypt_home
2024-01-23 15:19:10 +01:00
sleep 2
2024-01-22 20:32:48 +01:00
# Begin Mounting
mkdir -p /media/pika-install-mount
mount /dev/mapper/crypt_root /media/pika-install-mount/
mkdir -p /media/pika-install-mount/home
mount /dev/mapper/crypt_home /media/pika-install-mount/home
mkdir -p /media/pika-install-mount/boot
mount /dev/${DISK}p2 /media/pika-install-mount/boot
mkdir -p /media/pika-install-mount/boot/efi
mount /dev/${DISK}p1 /media/pika-install-mount/boot/efi
pikainstall -r /media/pika-install-mount/ -b /media/pika-install-mount/boot -e /media/pika-install-mount/boot/efi -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt
else
2024-01-23 15:19:10 +01:00
while [[ ! -d /dev/${DISK}1 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}2 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}3 ]]; do sleep 2; done
while [[ ! -d /dev/${DISK}4 ]]; do sleep 2; done
2024-01-22 20:32:48 +01:00
# Add filesystems
yes | mkfs -t vfat -F 32 /dev/${DISK}1
yes | mkfs -t ext4 /dev/${DISK}2
printf ${LUKS_KEY} | cryptsetup -q -v --type luks2 luksFormat /dev/${DISK}3
printf ${LUKS_KEY} | cryptsetup -q -v --type luks2 luksFormat /dev/${DISK}4
printf ${LUKS_KEY} | cryptsetup -q -v luksOpen /dev/${DISK}3 crypt_root
printf ${LUKS_KEY} | cryptsetup -q -v luksOpen /dev/${DISK}4 crypt_home
yes | mkfs.btrfs -f /dev/mapper/crypt_root
yes | mkfs.btrfs -f /dev/mapper/crypt_home
2024-01-23 15:19:10 +01:00
sleep 2
2024-01-22 20:32:48 +01:00
# Begin Mounting
mkdir -p /media/pika-install-mount
mount /dev/mapper/crypt_root /media/pika-install-mount/
mkdir -p /media/pika-install-mount/home
mount /dev/mapper/crypt_home /media/pika-install-mount/home
mkdir -p /media/pika-install-mount/boot
mount /dev/${DISK}2 /media/pika-install-mount/boot
mkdir -p /media/pika-install-mount/boot/efi
mount /dev/${DISK}1 /media/pika-install-mount/boot/efi
pikainstall -r /media/pika-install-mount/ -b /media/pika-install-mount/boot -e /media/pika-install-mount/boot/efi -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt
fi
2024-01-22 18:14:41 +01:00
fi