Install without encryption (#79)
* Configurator tester * Make it a dry run * Offer a no-encryption install mode * Fix SDDM login * Simplify the flow by using ctrl-c to toggle into unencrypted mode
This commit is contained in:
1 parent
7b42d8011e
commit
01f393f10d
3 files changed
+133
-19
No files matched your search
@@ -108,7 +108,7 @@ user_form() {
|
||||
done
|
||||
|
||||
while true; do
|
||||
password=$(gum input --placeholder "Used for user + root + encryption" --prompt.foreground="#845DF9" --password --prompt "Password> ") || abort
|
||||
password=$(gum input --placeholder "Used for user + root, and disk encryption when enabled" --prompt.foreground="#845DF9" --password --prompt "Password> ") || abort
|
||||
password_confirmation=$(gum input --placeholder "Must match the password you just typed" --prompt.foreground="#845DF9" --password --prompt "Confirm> ") || abort
|
||||
|
||||
if [[ -n "$password" && "$password" == "$password_confirmation" ]]; then
|
||||
@@ -266,15 +266,46 @@ disk_form() {
|
||||
|
||||
disk_form
|
||||
|
||||
while true; do
|
||||
gum style "Everything will be overwritten. There is no recovery possible."
|
||||
confirm_disk_overwrite() {
|
||||
local mode="encrypted"
|
||||
local affirmative confirm_status
|
||||
|
||||
echo
|
||||
if gum confirm --affirmative "Yes, format disk" --negative "No, change it" "Confirm overwriting ${disk}"; then
|
||||
break
|
||||
else
|
||||
disk_form
|
||||
fi
|
||||
while true; do
|
||||
clear_logo
|
||||
echo
|
||||
gum style "Everything will be overwritten. There is no recovery possible."
|
||||
|
||||
if [[ $mode == "encrypted" ]]; then
|
||||
gum style --foreground 8 "Press Ctrl+C for unencrypted install."
|
||||
affirmative="Yes, install"
|
||||
else
|
||||
affirmative="Yes, install without encryption"
|
||||
fi
|
||||
|
||||
echo
|
||||
gum confirm --affirmative "$affirmative" --negative "No, change it" "Confirm overwriting ${disk}"
|
||||
confirm_status=$?
|
||||
|
||||
case $confirm_status in
|
||||
0)
|
||||
[[ $mode == "encrypted" ]] && encrypt_installation=true || encrypt_installation=false
|
||||
return 0
|
||||
;;
|
||||
1)
|
||||
return 1
|
||||
;;
|
||||
130)
|
||||
[[ $mode == "encrypted" ]] && mode="unencrypted" || mode="encrypted"
|
||||
;;
|
||||
*)
|
||||
abort
|
||||
;;
|
||||
esac
|
||||
done
|
||||
}
|
||||
|
||||
while ! confirm_disk_overwrite; do
|
||||
disk_form
|
||||
done
|
||||
|
||||
clear
|
||||
@@ -289,9 +320,15 @@ password_escaped=$(echo -n "$password" | jq -Rsa)
|
||||
password_hash_escaped=$(echo -n "$password_hash" | jq -Rsa)
|
||||
username_escaped=$(echo -n "$username" | jq -Rsa)
|
||||
|
||||
if [[ $encrypt_installation == true ]]; then
|
||||
credentials_encryption_line=" \"encryption_password\": $password_escaped,"
|
||||
else
|
||||
credentials_encryption_line=""
|
||||
fi
|
||||
|
||||
cat <<-_EOF_ >user_credentials.json
|
||||
{
|
||||
"encryption_password": $password_escaped,
|
||||
$credentials_encryption_line
|
||||
"root_enc_password": $password_hash_escaped,
|
||||
"users": [
|
||||
{
|
||||
@@ -304,6 +341,8 @@ cat <<-_EOF_ >user_credentials.json
|
||||
}
|
||||
_EOF_
|
||||
|
||||
printf '%s\n' "$encrypt_installation" >user_encrypt_installation.txt
|
||||
|
||||
# Setup partition layout
|
||||
disk_size=$(lsblk -bdno SIZE "$disk")
|
||||
mib=$((1024 * 1024))
|
||||
@@ -324,6 +363,22 @@ else
|
||||
kernel_choice="linux"
|
||||
fi
|
||||
|
||||
if [[ $encrypt_installation == true ]]; then
|
||||
disk_encryption_config=$(cat <<-_EOF_
|
||||
,
|
||||
"disk_encryption": {
|
||||
"encryption_type": "luks",
|
||||
"lvm_volumes": [],
|
||||
"iter_time": 2000,
|
||||
"partitions": [ "8c2c2b92-1070-455d-b76a-56263bab24aa" ],
|
||||
"encryption_password": $password_escaped
|
||||
}
|
||||
_EOF_
|
||||
)
|
||||
else
|
||||
disk_encryption_config=""
|
||||
fi
|
||||
|
||||
cat <<-_EOF_ >user_configuration.json
|
||||
{
|
||||
"app_config": null,
|
||||
@@ -393,14 +448,7 @@ cat <<-_EOF_ >user_configuration.json
|
||||
],
|
||||
"wipe": true
|
||||
}
|
||||
],
|
||||
"disk_encryption": {
|
||||
"encryption_type": "luks",
|
||||
"lvm_volumes": [],
|
||||
"iter_time": 2000,
|
||||
"partitions": [ "8c2c2b92-1070-455d-b76a-56263bab24aa" ],
|
||||
"encryption_password": $password_escaped
|
||||
}
|
||||
]$disk_encryption_config
|
||||
},
|
||||
"hostname": "$hostname",
|
||||
"kernels": [ "$kernel_choice" ],
|
||||
@@ -453,5 +501,8 @@ if [[ $1 == "dry" ]]; then
|
||||
echo -e "\nUser Email Address:"
|
||||
cat user_email_address.txt
|
||||
|
||||
rm user_configuration.json user_credentials.json user_full_name.txt user_email_address.txt
|
||||
echo -e "\nDisk Encryption:"
|
||||
cat user_encrypt_installation.txt
|
||||
|
||||
rm user_configuration.json user_credentials.json user_full_name.txt user_email_address.txt user_encrypt_installation.txt
|
||||
fi
|
||||
Reference in new issue
Block a user