diff --git a/bin/omarchy-iso-configurator b/bin/omarchy-iso-configurator new file mode 100755 index 0000000..d17e873 --- /dev/null +++ b/bin/omarchy-iso-configurator @@ -0,0 +1,27 @@ +#!/usr/bin/env bash +set -euo pipefail + +repo_root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" + +cleanup() { + [[ -n "${mock_omarchy_install:-}" ]] && rm -rf "$(dirname "$mock_omarchy_install")" +} +trap cleanup EXIT + +if [[ -z "${OMARCHY_INSTALL:-}" ]]; then + if [[ -r /root/omarchy/install/helpers/all.sh ]]; then + export OMARCHY_INSTALL=/root/omarchy/install + else + mock_root="$(mktemp -d)" + mock_omarchy_install="$mock_root/install" + mkdir -p "$mock_omarchy_install/helpers" + cat >"$mock_omarchy_install/helpers/all.sh" <<'EOF' +PADDING_LEFT=0 +PADDING_LEFT_SPACES="" +clear_logo() { clear; } +EOF + export OMARCHY_INSTALL="$mock_omarchy_install" + fi +fi + +exec bash "$repo_root/configs/airootfs/root/configurator" dry "$@" diff --git a/configs/airootfs/root/.automated_script.sh b/configs/airootfs/root/.automated_script.sh index 78c7751..24000ac 100644 --- a/configs/airootfs/root/.automated_script.sh +++ b/configs/airootfs/root/.automated_script.sh @@ -35,6 +35,8 @@ install_omarchy() { chroot_bash -lc "sudo pacman -S --noconfirm --needed gum" >/dev/null chroot_bash -lc "source /home/$OMARCHY_USER/.local/share/omarchy/install.sh || bash" + configure_login_for_unencrypted_install + # Reboot if requested by installer if [[ -f /mnt/var/tmp/omarchy-install-completed ]]; then reboot @@ -138,6 +140,40 @@ EOF chmod +x /mnt/home/$OMARCHY_USER/.local/share/omarchy/default/waybar/indicators/notification-silencing.sh 2>/dev/null || true } +configure_login_for_unencrypted_install() { + if [[ $(/mnt/etc/sddm.conf.d/99-omarchy-login.conf </mnt/var/lib/sddm/state.conf </dev/null 2>&1 || true + arch-chroot /mnt systemctl enable sddm.service >/dev/null 2>&1 || true +} + chroot_bash() { HOME=/home/$OMARCHY_USER \ arch-chroot -u $OMARCHY_USER /mnt/ \ diff --git a/configs/airootfs/root/configurator b/configs/airootfs/root/configurator index 5243d84..701b60a 100644 --- a/configs/airootfs/root/configurator +++ b/configs/airootfs/root/configurator @@ -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