From 022d3b414db58e2db6e4defae3a0401641a8a684 Mon Sep 17 00:00:00 2001 From: Matt C Date: Wed, 24 Aug 2022 15:55:43 -0400 Subject: [PATCH 1/4] seems to work :shipit: --- PKGBUILD | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 PKGBUILD diff --git a/PKGBUILD b/PKGBUILD new file mode 100644 index 0000000..390f032 --- /dev/null +++ b/PKGBUILD @@ -0,0 +1,20 @@ +# Maintainer: echo -n 'bWF0dEBnZXRjcnlzdC5hbA==' | base64 --decode + +pkgname=jade_tui +pkgver=1.0.0 +pkgrel=1 +pkgdesc="TUI for installing the system with jade" +license=('GPL3') +arch=('any') +url="https://github.com/crystal-linux/jade-tui" +source=("jade-tui" "locales") +depends=('jade' 'gum' 'openssl') +md5sums=('f8bfed0ea3f1b5e85138b0c8b4770e48' + 'cba37f460dcf5f678043df39d6378c35') + +package() { + mkdir -p ${pkgdir}/usr/{share/jade-tui,bin} + chmod +x jade-tui + cp jade-tui ${pkgdir}/usr/bin/. + cp locales ${pkgdir}/usr/share/jade-tui/. +} From 49f181852d4a6ca283c42dc47573bbb2a686b188 Mon Sep 17 00:00:00 2001 From: Lexi <63929325+ShyyLexi@users.noreply.github.com> Date: Mon, 29 Aug 2022 20:39:18 +0000 Subject: [PATCH 2/4] Version 2 beta --- jade-tui | 364 ++++++++++++++++++++++++++++++++----------------------- 1 file changed, 214 insertions(+), 150 deletions(-) diff --git a/jade-tui b/jade-tui index 5ea71b8..bc8771f 100755 --- a/jade-tui +++ b/jade-tui @@ -1,7 +1,20 @@ #!/usr/bin/bash -# Welcome screen -gum confirm "$(gum style --border normal --margin '1' --padding '1 2' --border-foreground 212 "$(gum style --foreground 212 ' mysssym +version="2.0.0 beta" + +main_color="#A900FF" +warning_color="#ff0000" + +export BORDER_FOREGROUND="$main_color" +export GUM_CONFIRM_SELECTED_BACKGROUND="$main_color" +export GUM_CHOOSE_CURSOR_FOREGROUND="$main_color" +export GUM_CHOOSE_SELECTED_FOREGROUND="$main_color" +export GUM_INPUT_CURSOR_FOREGROUND="$main_color" +export GUM_FILTER_INDICATOR_FOREGROUND="$main_color" +export FOREGROUND="#ffffff" + +Welcome() { + gum confirm "$(gum style --border normal --margin '1' --padding '1 2' "$(gum style --foreground "$main_color" ' mysssym mysssym mysssym mysssym @@ -20,144 +33,171 @@ gum confirm "$(gum style --border normal --margin '1' --padding '1 2' --border-f dysssym dysssym dysssym - dysssym')" "" "Welcome to jade-tui" "Ready to make your Crystal installation... ready?")" && CONTINUE=true -if [[ $CONTINUE != "true" ]]; then - echo "Exiting. Have a good day!" - exit -fi - -# Select timezone, keymap, locale -timezone=$(timedatectl list-timezones | gum filter --placeholder "select a timezone") -keymap=$(localectl list-keymaps | gum filter --placeholder "select a keymap") -locale=$(cat /usr/share/jade-tui/locales | gum filter --placeholder "select a locale") - -# Username -clear -gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Please enter your username" -username=$(gum input --placeholder "Please enter your username") - -# User password -matches="false" -passwrong="false" -while [[ "$matches" == "false" ]]; do - clear - if [[ "$passwrong" == "true" ]]; then - gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Passwords did not match, please type the password again" - else - gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Now enter your password" - fi - password=$(gum input --password --placeholder "Please enter a password") - clear - gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Verify your password" - password_verif=$(gum input --password --placeholder "Type your password again") - if [[ "$password" == "$password_verif" ]]; then - matches="true" - else - passwrong="true" - fi -done -crypt_password=$(openssl passwd -crypt $password) - -# Root password -clear -different_root_password=true -gum confirm "$(gum style --border normal --margin '1' --padding '1 2' --border-foreground 212 'Use same password for root?')" && different_root_password=false -if [[ $different_root_password != "true" ]]; then - root_password=$password # set root password same as user password -else - root_matches="false" - root_passwrong="false" - while [[ "$root_matches" == "false" ]]; do - clear - if [[ "$root_passwrong" == "true" ]]; then - gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Passwords did not match, please type the root password again" - else - gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Now enter your root password" - fi - root_password=$(gum input --password --placeholder "Please enter a root password") - clear - gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Verify your root password" - root_password_verif=$(gum input --password --placeholder "Type your root password again") - if [[ "$root_password" == "$root_password_verif" ]]; then - root_matches="true" - else - root_passwrong="true" - fi - done -fi -crypt_root_password=$(openssl passwd -crypt ${root_password}) - -# Default shell -clear -gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Select a default shell" -shell=$(gum choose --limit 1 fish zsh bash) -if [[ "$shell" == "fish" ]]; then - fish_pkg="\"fish\"" -else - fish_pkg="" -fi - -# Hostname -clear -gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Please enter a hostname" -hostname=$(gum input --placeholder "Please enter a hostname") - -# Select disk -clear -gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Please select the disk to install to" "$(gum style --foreground 212 '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) -disk=$(echo $disk_dev | awk '{ print substr ($0, 6 ) }') - -# Select desktop -clear -gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Select a desktop to use" -desktop=$(gum choose --limit 1 gnome kde budgie mate cinnamon lxqt sway i3gaps herbstluftwm awesome bspwm) - -# misc settings -clear -gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Some miscellaneous settings" "Use space to enable/disable" -misc_settings=$(gum choose --limit 4 "Enable ipv6" "Enable timeshift" "Enable zramd" "Enable flatpak") -enable_ipv6="false" -enable_timeshift="false" -enable_zramd="false" -enable_flatpak="false" -if [[ $misc_settings == *"ipv6"* ]]; then - enable_ipv6="true" -fi -if [[ $misc_settings == *"timeshift"* ]]; then - enable_timeshift="true" -fi -if [[ $misc_settings == *"zramd"* ]]; then - enable_zramd="true" -fi -if [[ $misc_settings == *"flatpak"* ]]; then - enable_flatpak="true" -fi - -# Check if system is uefi -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 -clear -CONTINUE=false -gum confirm "$(gum style --border normal --margin '1' --padding '1 2' --border-foreground 212 "Summary, is this correct?" "" "keymap: $keymap" "timezone: $timezone" "locale: $locale" "username: $username" "password: $password" "Default shell: $shell" "root-password: $root_password" "hostname: $hostname" "disk: $disk" "desktop: $desktop" "ipv6: $enable_ipv6" "timeshift: $enable_timeshift" "enable zramd: $enable_zramd" "enable flatpak: $enable_flatpak" "efi: $is_uefi")" && CONTINUE=true -if [[ $CONTINUE != "true" ]]; then - echo "Exiting. Have a good day!" - exit -else - # Remove config.json if it exists - if [[ $(ls | grep "/tmp/config.json") ]]; then - rm /tmp/config.json + dysssym')" "" "Welcome to jade-tui" "Ready to make your Crystal installation... ready?" "$(gum style --foreground "#2B2B2B" "jade-tui version: $version")")" && CONTINUE=true + if [[ $CONTINUE != "true" ]]; then + echo "Exiting. Have a good day!" + exit + fi +} + +Timezone() { + timezone=$(timedatectl list-timezones | gum filter --placeholder "select a timezone") +} + +Keymap() { + keymap=$(localectl list-keymaps | gum filter --placeholder "select a keymap") +} + +Locale() { + locale=$(cat /usr/share/jade-tui/locales | gum filter --placeholder "select a locale") +} + +Username() { + clear + gum style --border normal --margin "1" --padding "1 2" "Please enter your username" + username=$(gum input --placeholder "Please enter your username") +} + +Password() { + matches="false" + passwrong="false" + while [[ "$matches" == "false" ]]; do + clear + if [[ "$passwrong" == "true" ]]; then + gum style --border normal --margin "1" --padding "1 2" "Passwords did not match, please type the password again" + else + gum style --border normal --margin "1" --padding "1 2" "Now enter your password" + fi + password=$(gum input --password --placeholder "Please enter a password") + clear + gum style --border normal --margin "1" --padding "1 2" "Verify your password" + password_verif=$(gum input --password --placeholder "Type your password again") + if [[ "$password" == "$password_verif" ]]; then + matches="true" + else + passwrong="true" + fi + done + crypt_password=$(openssl passwd -crypt $password) +} + +RootPassword() { + clear + different_root_password=true + gum confirm "$(gum style --border normal --margin '1' --padding '1 2' 'Use same password for root?')" && different_root_password=false + if [[ $different_root_password != "true" ]]; then + root_password=$password # set root password same as user password + else + root_matches="false" + root_passwrong="false" + while [[ "$root_matches" == "false" ]]; do + clear + if [[ "$root_passwrong" == "true" ]]; then + gum style --border normal --margin "1" --padding "1 2" "Passwords did not match, please type the root password again" + else + gum style --border normal --margin "1" --padding "1 2" "Now enter your root password" + fi + root_password=$(gum input --password --placeholder "Please enter a root password") + clear + gum style --border normal --margin "1" --padding "1 2" "Verify your root password" + root_password_verif=$(gum input --password --placeholder "Type your root password again") + if [[ "$root_password" == "$root_password_verif" ]]; then + root_matches="true" + else + root_passwrong="true" + fi + done + fi + crypt_root_password=$(openssl passwd -crypt ${root_password}) +} + +Shell() { + clear + gum style --border normal --margin "1" --padding "1 2" "Select a default shell" + shell=$(gum choose --limit 1 fish zsh bash) + + # TODO: remove when jade works all the time + if [[ "$shell" == "fish" ]]; then + fish_pkg="\"fish\"" + else + fish_pkg="" + fi +} + +Hostname() { + clear + gum style --border normal --margin "1" --padding "1 2" "Please enter a hostname" + hostname=$(gum input --placeholder "Please enter a hostname") +} + +AutoDisk() { + clear + gum style --border normal --margin "1" --padding "1 2" "Please select the disk to install to" "$(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) + disk=$(echo $disk_dev | awk '{ print substr ($0, 6 ) }') +} + +ManualDisk() { + # TODO: Add manual disk partitioning support + # 1. Check if UEFI or BIOS + # 2. Show what the user has to create like in arch wiki + # 3. Open cfdisk + # 4. Ask what partition is what + echo TODO +} + +Desktop() { + clear + gum style --border normal --margin "1" --padding "1 2" "Select a desktop to use" + desktop=$(gum choose --limit 1 gnome kde budgie mate cinnamon lxqt sway i3gaps herbstluftwm awesome bspwm) +} + +Misc() { + clear + gum style --border normal --margin "1" --padding "1 2" "Some miscellaneous settings" "Use space to enable/disable" + misc_settings=$(gum choose --limit 4 "Enable ipv6" "Enable timeshift" "Enable zramd" "Enable flatpak") + enable_ipv6="false" + enable_timeshift="false" + enable_zramd="false" + enable_flatpak="false" + if [[ $misc_settings == *"ipv6"* ]]; then + enable_ipv6="true" fi - # Make config.json - echo "{ + if [[ $misc_settings == *"timeshift"* ]]; then + enable_timeshift="true" + fi + if [[ $misc_settings == *"zramd"* ]]; then + enable_zramd="true" + fi + if [[ $misc_settings == *"flatpak"* ]]; then + enable_flatpak="true" + 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() { + clear + CONTINUE=false + gum confirm "$(gum style --border normal --margin '1' --padding '1 2' "Summary, is this correct?" "" "keymap: $keymap" "timezone: $timezone" "locale: $locale" "username: $username" "password: $password" "Default shell: $shell" "root-password: $root_password" "hostname: $hostname" "disk: $disk" "desktop: $desktop" "ipv6: $enable_ipv6" "timeshift: $enable_timeshift" "enable zramd: $enable_zramd" "enable flatpak: $enable_flatpak" "efi: $is_uefi")" && CONTINUE=true + if [[ $CONTINUE != "true" ]]; then + Change + else + # Remove config.json if it exists + if [[ $(ls | grep "/tmp/config.json") ]]; then + rm /tmp/config.json + fi + # Make config.json + echo "{ \"partition\": { \"device\": \"$disk\", \"mode\": \"Auto\", @@ -204,14 +244,38 @@ else }, \"kernel\": \"linux\" }" > /tmp/config.json -fi - -# Ask to install -CONTINUE=false -gum confirm "$(gum style --border normal --margin '1' --padding '1 2' --border-foreground 212 "Are you sure you want to install?" "$(gum style --foreground 212 'WARNING: This will erease the whole disk')")" && CONTINUE=true -if [[ $CONTINUE != "true" ]]; then - echo "Exiting. Have a good day!" - exit -else - sudo jade config /tmp/config.json -fi + fi +} + +Change() { + gum style --border normal --margin '1' --padding '1 2' "What do you want to change?" + $(gum choose --limit 1 Timezone Keymap Locale Username Password RootPassword Shell Hostname AutoDisk Desktop Misc) + Summary +} + +Install() { + CONTINUE=false + gum confirm "$(gum style --border normal --margin '1' --padding '1 2' "Are you sure you want to install?" "$(gum style --foreground "$warning_color" 'WARNING: This will erease the whole disk')")" && CONTINUE=true + if [[ $CONTINUE != "true" ]]; then + echo "Exiting. Have a good day!" + exit + else + sudo jade config /tmp/config.json + fi +} + +Welcome +Timezone +Keymap +Locale +Username +Password +RootPassword +Shell +Hostname +AutoDisk # TODO: Add manual partitioning support +Desktop +Misc +UEFICheck +Summary +Install \ No newline at end of file From 602b45c3a75075b02dd45c97a6a3ce8b4ccadbc2 Mon Sep 17 00:00:00 2001 From: Matt C Date: Mon, 29 Aug 2022 16:43:23 -0400 Subject: [PATCH 3/4] Update PKGBUILD Signed-off-by: Matt C --- PKGBUILD | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/PKGBUILD b/PKGBUILD index 390f032..465a1b9 100644 --- a/PKGBUILD +++ b/PKGBUILD @@ -13,8 +13,6 @@ md5sums=('f8bfed0ea3f1b5e85138b0c8b4770e48' 'cba37f460dcf5f678043df39d6378c35') package() { - mkdir -p ${pkgdir}/usr/{share/jade-tui,bin} - chmod +x jade-tui - cp jade-tui ${pkgdir}/usr/bin/. - cp locales ${pkgdir}/usr/share/jade-tui/. + install -D -m 755 jade-tui ${pkgdir}/usr/bin/. + install -D -m 700 locales ${pkgdir}/usr/share/jade-tui/. } From 4dae12365d43c2d3bc199b26749aa8308c337735 Mon Sep 17 00:00:00 2001 From: Lexi <63929325+ShyyLexi@users.noreply.github.com> Date: Mon, 29 Aug 2022 21:37:48 +0000 Subject: [PATCH 4/4] Add manual partitioning base (NOT WORKING YET) --- jade-tui | 165 +++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 104 insertions(+), 61 deletions(-) diff --git a/jade-tui b/jade-tui index bc8771f..06d2cf3 100755 --- a/jade-tui +++ b/jade-tui @@ -137,13 +137,65 @@ AutoDisk() { 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() { + testing="true" # TODO: Add manual disk partitioning support # 1. Check if UEFI or BIOS - # 2. Show what the user has to create like in arch wiki - # 3. Open cfdisk - # 4. Ask what partition is what - echo TODO + if [[ $is_uefi == "true" || $testing == "true" ]]; then + # 2. Show what the user has to create like in arch wiki + gum style --border normal --margin "1" --padding "1 2" "Example partition layout:" + 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() { @@ -174,16 +226,6 @@ Misc() { 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() { clear @@ -198,52 +240,52 @@ Summary() { fi # Make config.json echo "{ - \"partition\": { - \"device\": \"$disk\", - \"mode\": \"Auto\", - \"efi\": $is_uefi, - \"partitions\": [] - }, - \"bootloader\": { - \"type\": \"$grub_type\", - \"location\": \"$grub_location\" - }, - \"locale\": { - \"locale\": [ - \"$locale\" - ], - \"keymap\": \"$keymap\", - \"timezone\": \"$timezone\" - }, - \"networking\": { - \"hostname\": \"$hostname\", - \"ipv6\": $enable_ipv6 - }, - \"users\": [ - { - \"name\": \"$username\", - \"password\": \"$crypt_password\", - \"hasroot\": true, - \"shell\": \"$shell\" - } - ], - \"rootpass\": \"$crypt_root_password\", - \"desktop\": \"$desktop\", - \"timeshift\": $enable_timeshift, - \"extra_packages\": [ - $fish_pkg - ], - \"flatpak\": $enable_flatpak, - \"zramd\": $enable_zramd, - \"unakite\": { - \"enable\": false, - \"root\": \"/dev/null\", - \"oldroot\": \"$disk\", - \"efidir\": \"/dev/null\", - \"bootdev\": \"/dev/null\" - }, - \"kernel\": \"linux\" - }" > /tmp/config.json + \"partition\": { + \"device\": \"$disk\", + \"mode\": \"Auto\", + \"efi\": $is_uefi, + \"partitions\": [] + }, + \"bootloader\": { + \"type\": \"$grub_type\", + \"location\": \"$grub_location\" + }, + \"locale\": { + \"locale\": [ + \"$locale\" + ], + \"keymap\": \"$keymap\", + \"timezone\": \"$timezone\" + }, + \"networking\": { + \"hostname\": \"$hostname\", + \"ipv6\": $enable_ipv6 + }, + \"users\": [ + { + \"name\": \"$username\", + \"password\": \"$crypt_password\", + \"hasroot\": true, + \"shell\": \"$shell\" + } + ], + \"rootpass\": \"$crypt_root_password\", + \"desktop\": \"$desktop\", + \"timeshift\": $enable_timeshift, + \"extra_packages\": [ + $fish_pkg + ], + \"flatpak\": $enable_flatpak, + \"zramd\": $enable_zramd, + \"unakite\": { + \"enable\": false, + \"root\": \"/dev/null\", + \"oldroot\": \"$disk\", + \"efidir\": \"/dev/null\", + \"bootdev\": \"/dev/null\" + }, + \"kernel\": \"linux\" + }" > /tmp/config.json fi } @@ -274,8 +316,9 @@ RootPassword Shell Hostname AutoDisk # TODO: Add manual partitioning support +# ManualDisk Desktop Misc UEFICheck Summary -Install \ No newline at end of file +Install