RR: prepare for integration with pikainstall

This commit is contained in:
Ward from fusion-voyager-3 2024-02-17 16:28:14 +03:00
parent 2f1c3316d5
commit 36b0cf35c2
2 changed files with 50 additions and 5 deletions

View File

@ -2,17 +2,58 @@
set -e
DISK="$(cat "/tmp/pika-installer-gtk4-target-manual.txt")"
LOCALE="$(cat "/tmp/pika-installer-gtk4-lang.txt")"
KEYBOARD="$(cat "/tmp/pika-installer-gtk4-keyboard.txt")"
TIMEZONE="$(cat "/tmp/pika-installer-gtk4-timezone.txt")"
touch "/tmp/pika-installer-gtk4-status-parting.txt"
if [[ ! -f "/tmp/pika-installer-gtk4-target-manual-luks.txt" ]]
if ls /tmp/pika-installer-gtk4-target-manual-luks-p*.json
then
pikainstall -r ${DISK}/ -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1
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
touch /keyfile.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=$(jq -r .mountpoint $drivemount)
MOUNTOPT=$(jq -r .mountopt $drivemount)
if [[ -z $MOUNTOPT ]]
then
mkdir -p /media/pika-install-mount/$MOUNTPOINT
mount $PARTITION $MOUNTPOINT
elif [[ $MOUNTPOINT == "[SWAP]" ]]
then
touch /tmp/pika-installer-gtk4-swaplist
echo $PARTITION > /tmp/pika-installer-gtk4-swaplist
else
mkdir -p /media/pika-install-mount/$MOUNTPOINT
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
else
LUKS_KEY="$(cat "/tmp/pika-installer-gtk4-target-manual-luks.txt")"
pikainstall -r ${DISK}/ -c ${LUKS_KEY} -l ${LOCALE} -k ${KEYBOARD} -t ${TIMEZONE} && touch /tmp/pika-installer-gtk4-successful.txt || touch /tmp/pika-installer-gtk4-fail.txt && exit 1
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

View File

@ -282,6 +282,10 @@ pub fn partitioning_page(
let partition_file = partition_file.unwrap();
fs::remove_file(&partition_file).expect(&partition_file.to_str().unwrap());
}
for luks_file in glob("/tmp/pika-installer-gtk4-target-manual-luks-p*").expect("Failed to read glob pattern") {
let luks_file = luks_file.unwrap();
fs::remove_file(&luks_file).expect(&luks_file.to_str().unwrap());
}
if partitioning_stack.visible_child_name() == Some(GString::from_string_unchecked("partition_method_automatic_page".into())) {
fs::write("/tmp/pika-installer-gtk4-target-auto.txt", partition_method_automatic_target_buffer_clone.text(&partition_method_automatic_target_buffer_clone.bounds().0, &partition_method_automatic_target_buffer_clone.bounds().1, true).to_string()).expect("Unable to write file");
let automatic_luks_result = partition_method_automatic_luks_buffer_clone.text(&partition_method_automatic_luks_buffer_clone.bounds().0, &partition_method_automatic_luks_buffer_clone.bounds().1, true).to_string();