2024-01-23 19:46:00 +01:00
|
|
|
#! /bin/bash
|
|
|
|
|
2024-02-18 20:36:24 +01:00
|
|
|
export LANG=en_US.UTF8
|
|
|
|
|
2024-01-23 19:46:00 +01:00
|
|
|
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 20:05:42 +01:00
|
|
|
rm -rf /tmp/pika-installer-gtk4-swaplist || true
|
|
|
|
|
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 20:05:42 +01:00
|
|
|
rm -rf /tmp/pika-installer-gtk4-crypttab || true
|
2024-02-17 14:28:14 +01:00
|
|
|
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)"
|
2024-02-18 16:39:04 +01:00
|
|
|
echo "$MAP UUID="$UUID" none luks,discard" >> /tmp/pika-installer-gtk4-crypttab
|
2024-02-17 14:28:14 +01:00
|
|
|
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)
|
2024-02-18 16:39:04 +01:00
|
|
|
echo "$MAP UUID="$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)
|
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 ]]
|
2024-02-17 14:28:14 +01:00
|
|
|
then
|
2024-02-17 16:54:33 +01:00
|
|
|
mkdir -p $MOUNTPOINT
|
2024-02-17 14:28:14 +01:00
|
|
|
mount $PARTITION $MOUNTPOINT
|
|
|
|
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
|
2024-02-17 20:56:52 +01:00
|
|
|
fi
|
2024-02-17 14:28:14 +01:00
|
|
|
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
|