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

62 lines
2.5 KiB
Bash
Raw Normal View History

2024-01-23 19:46:00 +01:00
#! /bin/bash
set -e
LOCALE="$(cat "/tmp/pika-installer-gtk4-lang.txt")"
2024-01-24 19:14:59 +01:00
KEYBOARD="$(cat "/tmp/pika-installer-gtk4-keyboard.txt")"
2024-01-23 19:46:00 +01:00
TIMEZONE="$(cat "/tmp/pika-installer-gtk4-timezone.txt")"
touch "/tmp/pika-installer-gtk4-status-parting.txt"
rm -rf /tmp/pika-installer-gtk4-swaplist || true
if ls /tmp/pika-installer-gtk4-target-manual-luks-p*.json
2024-01-23 19:46:00 +01:00
then
rm -rf /tmp/pika-installer-gtk4-crypttab || true
touch /tmp/pika-installer-gtk4-crypttab
for cryptentry in /tmp/pika-installer-gtk4-target-manual-luks-p*.json; do
if [[ -z $(jq -r .password $cryptentry) ]]
then
LUKS=$(jq -r .partition $cryptentry)
MAP=$(jq -r .partition $cryptentry | cut -d "/" -f2-)
UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)"
echo "$MAP UUID="$UUID" none luks,discard" >> /tmp/pika-installer-gtk4-crypttab
else
LUKS=$(jq -r .partition $cryptentry)
MAP=$(jq -r .partition $cryptentry | cut -d "/" -f2-)
UUID="$(blkid "$(lsblk -sJp | jq -r --arg dsk /dev/"$LUKS" '.blockdevices | .[] | select(.name == $dsk) | .children | .[0] | .name')" -s UUID -o value)"
LUKS_PASSWD=$(jq -r .password $cryptentry)
echo "$MAP UUID="$UUID" /key-"$MAP".txt luks" >> /tmp/pika-installer-gtk4-crypttab
touch /key-"$MAP".txt
openssl genrsa > /key-"$MAP".txt
echo $LUKS_PASSWD | cryptsetup luksAddKey UUID=$UUID /key-"$MAP".txt -
fi
done
fi
for drivemount in /tmp/pika-installer-gtk4-target-manual-p*.json; do
PARTITION="/dev/$(jq -r .partition $drivemount)"
MOUNTPOINT="/media/pika-install-mount/$(jq -r .mountpoint $drivemount)"
MOUNTOPT=$(jq -r .mountopt $drivemount)
2024-02-17 20:56:52 +01:00
if [[ $MOUNTPOINT = '/media/pika-install-mount/[SWAP]' ]]
then
touch /tmp/pika-installer-gtk4-swaplist
echo $PARTITION > /tmp/pika-installer-gtk4-swaplist
elif [[ -z $MOUNTOPT ]]
then
mkdir -p $MOUNTPOINT
mount $PARTITION $MOUNTPOINT
else
mkdir -p $MOUNTPOINT
mount -o $MOUNTOPT $PARTITION $MOUNTPOINT
2024-02-17 20:56:52 +01:00
fi
done
if [[ ! -f "/tmp/pika-installer-gtk4-crypttab" ]]
then
pikainstall -r /media/pika-install-mount/ --manual 1 -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1
2024-01-23 19:46:00 +01:00
else
pikainstall -r /media/pika-install-mount/ --manual 2 -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1
fi