vinstaller/main.sh
2022-02-06 22:12:28 +01:00

74 lines
1.5 KiB
Bash

#!/bin/bash
main="/tmp/vinstall"
target="${main}/target"
. functions
target_phy_disk() {
header "Choose target disk"
local DISKS_DETAILS
local output
DISKS_DETAILS=$(lsblk -l -o KNAME,TYPE,SIZE,MODEL,WWN|grep disk)
echo "$DISKS_DETAILS"
input "which one?" "$(echo "$DISKS_DETAILS"|awk '{print $1}'|tr '\n' ' ')" "not found."
TARGET_PHY_DISK="$output"
}
target_phy_id() {
local i
local f1
local f2
for i in $(find /dev/disk/by-id|grep -v part); do
if realpath "$i" | grep -q -i "$TARGET_PHY_DISK"; then
if echo "$i" | grep -q "wwn"; then
TARGET_PHY_WWN="$i"
f1=1
fi
if echo "$i" | grep -q -v "wwn"; then
TARGET_PHY_ID="$i"
f2=1
fi
fi
done
if [ "$f1" == "1" ] && [ "$f2" == "1" ]; then
return 0
else
err "no id found"
fi
}
use_efi() {
if test -e /sys/firmware/efi; then
EFI=1
else
EFI=0
fi
}
encryption_style() {
header "Choose encryption style"
echo "implemented:"
echo "a)keyfile in initramfs" #bios: 1 uefi: 2
echo "b)no encryption" #bios: 1 uefi: 2
echo "not implemented:"
echo "c)no keyfile (double pw enter)" #bios: 1 uefi: 2
echo "d)keyfile on usb" #bios: 1 uefi: ?
echo "e)unencrypted boot" #bios: 2 uefi: 2
input "how to encrypt?" "a b c d e" "wrong input"
ENCRYPTION_STYLE="$output"
}
partition() {
if [ "$EFI" == "1" ]; then
echo parted --script $TARGET_PHY_WWN 'mklabel gpt'
else
echo parted --script $TARGET_PHY_WWN 'mklabel msdos'
fi
}
target_phy_disk
target_phy_id
use_efi
encryption_style