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"
|
|
|
|
|
2024-02-17 14:28:14 +01:00
|
|
|
if ls /tmp/pika-installer-gtk4-target-manual-luks-p*.json
|
2024-01-23 19:46:00 +01:00
|
|
|
then
|
2024-02-17 14:28:14 +01:00
|
|
|
rm -rf /tmp/pika-installer-gtk4-crypttab
|
|
|
|
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 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 /key-"$MAP".txt luks" >> /tmp/pika-installer-gtk4-crypttab
|
2024-02-17 16:54:33 +01:00
|
|
|
touch /key-"$MAP".txt
|
2024-02-17 14:28:14 +01:00
|
|
|
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)"
|
2024-02-17 16:54:33 +01:00
|
|
|
MOUNTPOINT="/media/pika-install-mount/$(jq -r .mountpoint $drivemount)"
|
2024-02-17 14:28:14 +01:00
|
|
|
MOUNTOPT=$(jq -r .mountopt $drivemount)
|
|
|
|
if [[ -z $MOUNTOPT ]]
|
|
|
|
then
|
2024-02-17 16:54:33 +01:00
|
|
|
mkdir -p $MOUNTPOINT
|
2024-02-17 14:28:14 +01:00
|
|
|
mount $PARTITION $MOUNTPOINT
|
|
|
|
elif [[ $MOUNTPOINT == "[SWAP]" ]]
|
|
|
|
then
|
|
|
|
touch /tmp/pika-installer-gtk4-swaplist
|
|
|
|
echo $PARTITION > /tmp/pika-installer-gtk4-swaplist
|
|
|
|
else
|
2024-02-17 16:54:33 +01:00
|
|
|
mkdir -p $MOUNTPOINT
|
2024-02-17 14:28:14 +01:00
|
|
|
mount -o $MOUNTOPT $PARTITION $MOUNTPOINT
|
|
|
|
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
|
2024-02-17 14:28:14 +01:00
|
|
|
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
|
2024-02-17 16:54:33 +01:00
|
|
|
fi
|