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)
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
# 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
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
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)
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)
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