@ -137,13 +137,65 @@ AutoDisk() {
disk=$(echo $disk_dev | awk '{ print substr ($0, 6 ) }')
disk=$(echo $disk_dev | awk '{ print substr ($0, 6 ) }')
}
}
UEFICheck() {
is_uefi=$([ -d /sys/firmware/efi ] && echo true || echo false)
if [[ $is_uefi == "true" ]]; then
grub_type="grub-efi"
grub_location="/boot/efi"
else
grub_type="grub-legacy"
grub_location="$disk_dev"
fi
}
ManualDisk() {
ManualDisk() {
testing="true"
# TODO: Add manual disk partitioning support
# TODO: Add manual disk partitioning support
# 1. Check if UEFI or BIOS
# 1. Check if UEFI or BIOS
# 2. Show what the user has to create like in arch wiki
if [[ $is_uefi == "true" || $testing == "true" ]]; then
# 3. Open cfdisk
# 2. Show what the user has to create like in arch wiki
# 4. Ask what partition is what
gum style --border normal --margin "1" --padding "1 2" "Example partition layout:"
echo TODO
gum style --border normal --foreground $warning_color "Note: swap partition needs to be enabled after install"
echo ""
echo ""
EFI_PART=$(gum style --border normal "EFI system partition")
EFI_SIZE=$(gum style --border normal "At least 300 MiB")
SWAP_PART=$(gum style --border normal "Linux swap")
SWAP_SIZE=$(gum style --border normal "More than 512 MiB")
ROOT_PART=$(gum style --border normal "Linux x86-64 root")
ROOT_SIZE=$(gum style --border normal "Remainder of the device")
EFI_ROW=$(gum join "$EFI_PART" "$EFI_SIZE")
SWAP_ROW=$(gum join "$SWAP_PART" "$SWAP_SIZE")
ROOT_ROW=$(gum join "$ROOT_PART" "$ROOT_SIZE")
gum join --vertical "$EFI_ROW" "$SWAP_ROW" "$ROOT_ROW"
# 3. Open cfdisk
gum style --border normal --margin "1" --padding "1 2" "Please select the disk to partition" "$(gum style --foreground "$warning_color" 'WARNING: This will erease the whole disk')"
disk_dev=$(lsblk -pdo name | grep -v zram | grep -v NAME | grep -v loop | grep -v sr | gum choose --limit 1)
clear
gum style --border normal --margin "1" --padding "1 2" "Password: crystal"
sudo cfdisk $disk_dev
# 4. Ask what partition is what
clear
gum style --border normal --margin "1" --padding "1 2" "Select EFI partition"
efi_part=$(lsblk | grep -v zram | grep -v NAME | grep -v loop | grep -v sr | gum choose --limit 1)
clear
gum style --border normal --margin "1" --padding "1 2" "Select EFI partition mountpoint"
efi_part_mount=$(gum choose --limit 1 "none" "/" "/boot" "/boot/efi" "/home" "/opt" "/tmp" "/usr" "var")
clear
gum style --border normal --margin "1" --padding "1 2" "Select root partition"
root_part=$(lsblk | grep -v zram | grep -v NAME | grep -v loop | grep -v sr | gum choose --limit 1)
clear
gum style --border normal --margin "1" --padding "1 2" "Select root partition mountpoint"
root_part_mount=$(gum choose --limit 1 "none" "/" "/boot" "/boot/efi" "/home" "/opt" "/tmp" "/usr" "var")
# TODO: remove junk from efi_part, root_part
else
echo Manual BIOS partitioning is not supported yet
fi
}
}
Desktop() {
Desktop() {
@ -174,16 +226,6 @@ Misc() {
fi
fi
}
}
UEFICheck() {
is_uefi=$([ -d /sys/firmware/efi ] && echo true || echo false)
if [[ $is_uefi == "true" ]]; then
grub_type="grub-efi"
grub_location="/boot/efi"
else
grub_type="grub-legacy"
grub_location="$disk_dev"
fi
}
Summary() {
Summary() {
clear
clear
@ -198,52 +240,52 @@ Summary() {
fi
fi
# Make config.json
# Make config.json
echo "{
echo "{
\"partition\": {
\"partition\": {
\"device\": \"$disk\",
\"device\": \"$disk\",
\"mode\": \"Auto\",
\"mode\": \"Auto\",
\"efi\": $is_uefi,
\"efi\": $is_uefi,
\"partitions\": []
\"partitions\": []
},
},
\"bootloader\": {
\"bootloader\": {
\"type\": \"$grub_type\",
\"type\": \"$grub_type\",
\"location\": \"$grub_location\"
\"location\": \"$grub_location\"
},
},
\"locale\": {
\"locale\": {
\"locale\": [
\"locale\": [
\"$locale\"
\"$locale\"
],
],
\"keymap\": \"$keymap\",
\"keymap\": \"$keymap\",
\"timezone\": \"$timezone\"
\"timezone\": \"$timezone\"
},
},
\"networking\": {
\"networking\": {
\"hostname\": \"$hostname\",
\"hostname\": \"$hostname\",
\"ipv6\": $enable_ipv6
\"ipv6\": $enable_ipv6
},
},
\"users\": [
\"users\": [
{
{
\"name\": \"$username\",
\"name\": \"$username\",
\"password\": \"$crypt_password\",
\"password\": \"$crypt_password\",
\"hasroot\": true,
\"hasroot\": true,
\"shell\": \"$shell\"
\"shell\": \"$shell\"
}
}
],
],
\"rootpass\": \"$crypt_root_password\",
\"rootpass\": \"$crypt_root_password\",
\"desktop\": \"$desktop\",
\"desktop\": \"$desktop\",
\"timeshift\": $enable_timeshift,
\"timeshift\": $enable_timeshift,
\"extra_packages\": [
\"extra_packages\": [
$fish_pkg
$fish_pkg
],
],
\"flatpak\": $enable_flatpak,
\"flatpak\": $enable_flatpak,
\"zramd\": $enable_zramd,
\"zramd\": $enable_zramd,
\"unakite\": {
\"unakite\": {
\"enable\": false,
\"enable\": false,
\"root\": \"/dev/null\",
\"root\": \"/dev/null\",
\"oldroot\": \"$disk\",
\"oldroot\": \"$disk\",
\"efidir\": \"/dev/null\",
\"efidir\": \"/dev/null\",
\"bootdev\": \"/dev/null\"
\"bootdev\": \"/dev/null\"
},
},
\"kernel\": \"linux\"
\"kernel\": \"linux\"
}" > /tmp/config.json
}" > /tmp/config.json
fi
fi
}
}
@ -274,6 +316,7 @@ RootPassword
Shell
Shell
Hostname
Hostname
AutoDisk # TODO: Add manual partitioning support
AutoDisk # TODO: Add manual partitioning support
# ManualDisk
Desktop
Desktop
Misc
Misc
UEFICheck
UEFICheck