@ -1,7 +1,20 @@
#!/usr/bin/bash
#!/usr/bin/bash
# Welcome screen
version="2.0.0 beta"
gum confirm "$(gum style --border normal --margin '1' --padding '1 2' --border-foreground 212 "$(gum style --foreground 212 ' mysssym
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
mysssym
mysssym
mysssym
@ -20,144 +33,171 @@ gum confirm "$(gum style --border normal --margin '1' --padding '1 2' --border-f
dysssym
dysssym
dysssym
dysssym
dysssym
dysssym
dysssym')" "" "Welcome to jade-tui" "Ready to make your Crystal installation... ready?")" && CONTINUE=true
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
if [[ $CONTINUE != "true" ]]; then
echo "Exiting. Have a good day!"
echo "Exiting. Have a good day!"
exit
exit
fi
fi
}
# Select timezone, keymap, locale
timezone=$(timedatectl list-timezones | gum filter --placeholder "select a timezone")
Timezone() {
keymap=$(localectl list-keymaps | gum filter --placeholder "select a keymap")
timezone=$(timedatectl list-timezones | gum filter --placeholder "select a timezone")
locale=$(cat /usr/share/jade-tui/locales | gum filter --placeholder "select a locale")
}
# Username
Keymap() {
clear
keymap=$(localectl list-keymaps | gum filter --placeholder "select a keymap")
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Please enter your username"
}
username=$(gum input --placeholder "Please enter your username")
Locale() {
# User password
locale=$(cat /usr/share/jade-tui/locales | gum filter --placeholder "select a locale")
matches="false"
}
passwrong="false"
while [[ "$matches" == "false" ]]; do
Username() {
clear
clear
if [[ "$passwrong" == "true" ]]; then
gum style --border normal --margin "1" --padding "1 2" "Please enter your username"
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Passwords did not match, please type the password again"
username=$(gum input --placeholder "Please enter your username")
else
}
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Now enter your password"
fi
Password() {
password=$(gum input --password --placeholder "Please enter a password")
matches="false"
clear
passwrong="false"
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Verify your password"
while [[ "$matches" == "false" ]]; do
password_verif=$(gum input --password --placeholder "Type your password again")
clear
if [[ "$password" == "$password_verif" ]]; then
if [[ "$passwrong" == "true" ]]; then
matches="true"
gum style --border normal --margin "1" --padding "1 2" "Passwords did not match, please type the password again"
else
else
passwrong="true"
gum style --border normal --margin "1" --padding "1 2" "Now enter your password"
fi
fi
done
password=$(gum input --password --placeholder "Please enter a password")
crypt_password=$(openssl passwd -crypt $password)
clear
gum style --border normal --margin "1" --padding "1 2" "Verify your password"
# Root password
password_verif=$(gum input --password --placeholder "Type your password again")
clear
if [[ "$password" == "$password_verif" ]]; then
different_root_password=true
matches="true"
gum confirm "$(gum style --border normal --margin '1' --padding '1 2' --border-foreground 212 'Use same password for root?')" && different_root_password=false
else
if [[ $different_root_password != "true" ]]; then
passwrong="true"
root_password=$password # set root password same as user password
fi
else
done
root_matches="false"
crypt_password=$(openssl passwd -crypt $password)
root_passwrong="false"
}
while [[ "$root_matches" == "false" ]]; do
clear
RootPassword() {
if [[ "$root_passwrong" == "true" ]]; then
clear
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Passwords did not match, please type the root password again"
different_root_password=true
else
gum confirm "$(gum style --border normal --margin '1' --padding '1 2' 'Use same password for root?')" && different_root_password=false
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Now enter your root password"
if [[ $different_root_password != "true" ]]; then
fi
root_password=$password # set root password same as user password
root_password=$(gum input --password --placeholder "Please enter a root password")
else
clear
root_matches="false"
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Verify your root password"
root_passwrong="false"
root_password_verif=$(gum input --password --placeholder "Type your root password again")
while [[ "$root_matches" == "false" ]]; do
if [[ "$root_password" == "$root_password_verif" ]]; then
clear
root_matches="true"
if [[ "$root_passwrong" == "true" ]]; then
else
gum style --border normal --margin "1" --padding "1 2" "Passwords did not match, please type the root password again"
root_passwrong="true"
else
fi
gum style --border normal --margin "1" --padding "1 2" "Now enter your root password"
done
fi
fi
root_password=$(gum input --password --placeholder "Please enter a root password")
crypt_root_password=$(openssl passwd -crypt ${root_password})
clear
gum style --border normal --margin "1" --padding "1 2" "Verify your root password"
# Default shell
root_password_verif=$(gum input --password --placeholder "Type your root password again")
clear
if [[ "$root_password" == "$root_password_verif" ]]; then
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Select a default shell"
root_matches="true"
shell=$(gum choose --limit 1 fish zsh bash)
else
if [[ "$shell" == "fish" ]]; then
root_passwrong="true"
fish_pkg="\"fish\""
fi
else
done
fish_pkg=""
fi
fi
crypt_root_password=$(openssl passwd -crypt ${root_password})
}
# Hostname
clear
Shell() {
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "Please enter a hostname"
clear
hostname=$(gum input --placeholder "Please enter a hostname")
gum style --border normal --margin "1" --padding "1 2" "Select a default shell"
shell=$(gum choose --limit 1 fish zsh bash)
# Select disk
clear
# TODO: remove when jade works all the time
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')"
if [[ "$shell" == "fish" ]]; then
disk_dev=$(lsblk -pdo name | grep -v zram | grep -v NAME | grep -v loop | grep -v sr | gum choose --limit 1)
fish_pkg="\"fish\""
disk=$(echo $disk_dev | awk '{ print substr ($0, 6 ) }')
else
fish_pkg=""
# Select desktop
fi
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)
Hostname() {
clear
# misc settings
gum style --border normal --margin "1" --padding "1 2" "Please enter a hostname"
clear
hostname=$(gum input --placeholder "Please enter a hostname")
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"
AutoDisk() {
enable_timeshift="false"
clear
enable_zramd="false"
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')"
enable_flatpak="false"
disk_dev=$(lsblk -pdo name | grep -v zram | grep -v NAME | grep -v loop | grep -v sr | gum choose --limit 1)
if [[ $misc_settings == *"ipv6"* ]]; then
disk=$(echo $disk_dev | awk '{ print substr ($0, 6 ) }')
enable_ipv6="true"
}
fi
if [[ $misc_settings == *"timeshift"* ]]; then
ManualDisk() {
enable_timeshift="true"
# TODO: Add manual disk partitioning support
fi
# 1. Check if UEFI or BIOS
if [[ $misc_settings == *"zramd"* ]]; then
# 2. Show what the user has to create like in arch wiki
enable_zramd="true"
# 3. Open cfdisk
fi
# 4. Ask what partition is what
if [[ $misc_settings == *"flatpak"* ]]; then
echo TODO
enable_flatpak="true"
}
fi
Desktop() {
# Check if system is uefi
clear
is_uefi=$([ -d /sys/firmware/efi ] && echo true || echo false)
gum style --border normal --margin "1" --padding "1 2" "Select a desktop to use"
if [[ $is_uefi == "true" ]]; then
desktop=$(gum choose --limit 1 gnome kde budgie mate cinnamon lxqt sway i3gaps herbstluftwm awesome bspwm)
grub_type="grub-efi"
}
grub_location="/boot/efi"
else
Misc() {
grub_type="grub-legacy"
clear
grub_location="$disk_dev"
gum style --border normal --margin "1" --padding "1 2" "Some miscellaneous settings" "Use space to enable/disable"
fi
misc_settings=$(gum choose --limit 4 "Enable ipv6" "Enable timeshift" "Enable zramd" "Enable flatpak")
enable_ipv6="false"
# Summary
enable_timeshift="false"
clear
enable_zramd="false"
CONTINUE=false
enable_flatpak="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 [[ $misc_settings == *"ipv6"* ]]; then
if [[ $CONTINUE != "true" ]]; then
enable_ipv6="true"
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
fi
fi
# Make config.json
if [[ $misc_settings == *"timeshift"* ]]; then
echo "{
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\": {
\"partition\": {
\"device\": \"$disk\",
\"device\": \"$disk\",
\"mode\": \"Auto\",
\"mode\": \"Auto\",
@ -204,14 +244,38 @@ else
},
},
\"kernel\": \"linux\"
\"kernel\": \"linux\"
}" > /tmp/config.json
}" > /tmp/config.json
fi
fi
}
# Ask to install
CONTINUE=false
Change() {
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
gum style --border normal --margin '1' --padding '1 2' "What do you want to change?"
if [[ $CONTINUE != "true" ]]; then
$(gum choose --limit 1 Timezone Keymap Locale Username Password RootPassword Shell Hostname AutoDisk Desktop Misc)
echo "Exiting. Have a good day!"
Summary
exit
}
else
sudo jade config /tmp/config.json
Install() {
fi
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