This commit is contained in:
teldra 2022-02-06 22:12:28 +01:00
commit 9e3c35b53d
2 changed files with 100 additions and 0 deletions

27
functions Normal file
View File

@ -0,0 +1,27 @@
err() {
echo $1
echo "exiting.."
exit 1
}
input() {
local input
local found="0"
echo "$1 $2"
read input
for i in $2; do
if [ "$i" == "$input" ]; then
found=1
fi
done
if [ "$found" == "0" ]; then
err "$input: $3"
return 1
fi
output="$input"
}
header() {
echo ""
echo "#### $1"
}

73
main.sh Normal file
View File

@ -0,0 +1,73 @@
#!/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