General TUI improvements
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
#!/usr/bin/env nix-shell
|
||||
#!nix-shell -i bash -p bash coreutils gnused gum fastfetch xkcdpass sops ssh-to-age age sshpass envsubst pciutils usbutils mosquitto curl jq
|
||||
#!nix-shell -i bash -p bash nano coreutils gnused gum fastfetch xkcdpass sops ssh-to-age age sshpass envsubst pciutils usbutils mosquitto curl jq
|
||||
|
||||
### --> Default settings
|
||||
export GUM_SPIN_SPINNER="minidot"
|
||||
@@ -149,13 +149,13 @@ ssh_to_host() {
|
||||
}
|
||||
|
||||
hierarchy_preparation() {
|
||||
mkdir -p final-nix-config/etc/numbus-server
|
||||
mkdir -p final-nix-config/etc/secrets
|
||||
mkdir -p final-nix-config/etc/secrets/disks
|
||||
mkdir -p final-nix-config/etc/nixos/secrets
|
||||
mkdir -p final-nix-config/var
|
||||
mkdir -p final-nix-config/var/lib
|
||||
mkdir -p final-nix-config/var/lib/sops-nix
|
||||
mkdir -p final-nix-config/var/lib/numbus-server
|
||||
|
||||
echo -e "\n✅ Writing configuration..."
|
||||
cp -${FILES_COPY_FLAGS} templates/nix-config/configuration.nix final-nix-config/etc/nixos/configuration.nix
|
||||
@@ -554,10 +554,53 @@ EOF
|
||||
)
|
||||
|
||||
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "$(gum format <<< "${DISK_RECAP_CONTENT}")"
|
||||
gum confirm "Proceed with this disk configuration?" || { echo -e "\n\n❌ Aborting as requested."; exit 1; }
|
||||
gum confirm "➡️ Proceed with this disk configuration?" || { echo -e "\n\n❌ Aborting as requested."; exit 1; }
|
||||
|
||||
SERVICES_RECAP_CONTENT=$(cat << EOF
|
||||
### Services Configuration Summary
|
||||
|
||||
Please review the selected services before proceeding.
|
||||
|
||||
**DNS Service:**
|
||||
$(echo "\`${SELECTED_DNS_SERVICE^}\`" && echo "")
|
||||
**Services:**
|
||||
$(for service in ${AVAILABLE_SERVICES[@]}`; do echo "\`${service^}\`" && echo ""; done)
|
||||
EOF
|
||||
)
|
||||
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "$(gum format <<< "${SERVICES_RECAP_CONTENT}")"
|
||||
gum confirm "➡️ Proceed with this services configuration?" || { echo -e "\n\n❌ Aborting as requested."; exit 1; }
|
||||
|
||||
DISK_RECAP_CONTENT=$(cat << EOF
|
||||
### Secrets Summary
|
||||
|
||||
Please save the following secrets to a secure place (i.e. your local password manager, or a hidden sheet of paper).
|
||||
|
||||
**Boot Disks (${#BOOT_DISKS_ID_LIST[@]}):**
|
||||
**Disk 1 Secret Key:** \`$( cat final-nix-config/etc/secrets/disks/boot-1 )\`
|
||||
$( [[ -n "${BOOT_DISKS_ID_LIST[1]:-}" ]] && echo "**Disk 2 secret key:** \`$( cat final-nix-config/etc/secrets/disks/boot-2 )\`" || echo "**Boot 2:** *Not configured*" )
|
||||
|
||||
**Data Disks ($CONTENT_DISK_NUMBER):**
|
||||
$( [[ $CONTENT_DISK_NUMBER -gt 0 ]] && j=1 && for i in $(seq 0 $(($CONTENT_DISK_NUMBER - 1))); do echo "* **Disk ${j} secret key:** \`$( cat final-nix-config/etc/secrets/disks/data-${j} )\`" && j=$((j + 1)); done )
|
||||
$( [[ $CONTENT_DISK_NUMBER -eq 0 ]] && echo "* *Not configured*" )
|
||||
|
||||
**Parity Disks ($PARITY_DISK_NUMBER):**
|
||||
$( [[ $PARITY_DISK_NUMBER -gt 0 ]] && j=1 && for i in $(seq $CONTENT_DISK_NUMBER $((${#DATA_DISKS_ID[@]} - 1))); do echo "* **Parity ${j}:** \`$( cat final-nix-config/etc/secrets/disks/parity-${j} )\`" && j=$((j + 1)); done )
|
||||
$( [[ $PARITY_DISK_NUMBER -eq 0 ]] && echo "* *Not configured*" )
|
||||
|
||||
EOF
|
||||
)
|
||||
|
||||
gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "$(gum format <<< "${DISK_RECAP_CONTENT}")"
|
||||
gum confirm "✅ I have stored these credentials in a safe place" || { echo -e "\n\n❌ Please store these credentials in a safe place as you will need them later."; exit 1; }
|
||||
|
||||
gum confirm "➡️ Would you like to manually edit the configuration (⚠️ advanced users only)" || { echo -e "\n\n✅ continuing with the installation..."; return 0; }
|
||||
|
||||
nano final-nix-config/etc/nixos/configuration.nix
|
||||
}
|
||||
|
||||
cloudflare_dns_setup() {
|
||||
gum confirm "➡️ This script can automatically create DNS records for your services. Proceed? (recommended)" || { echo -e "\n\n ⚠️ skipping the DNS records creation step..."; return 0; }
|
||||
|
||||
local ZONE_ID
|
||||
local RECORD_COUNT
|
||||
local IS_MATCHING
|
||||
@@ -649,9 +692,9 @@ cloudflare_dns_setup() {
|
||||
}
|
||||
|
||||
export_configuration() {
|
||||
cp deploy.conf final-nix-config/etc/numbus-server/numbus-server.conf
|
||||
cp deploy.conf final-nix-config/var/lib/numbus-server/numbus-server.conf
|
||||
|
||||
local CONFIG_EXPORT_DIR="final-nix-config/etc/numbus-server/"
|
||||
local CONFIG_EXPORT_DIR="final-nix-config/var/lib/numbus-server/"
|
||||
local CONFIG_EXPORT_FILE="${CONFIG_EXPORT_DIR}/numbus-server.conf"
|
||||
|
||||
echo "export TARGET_INTERFACE=\"${TARGET_INTERFACE}\"" >> $CONFIG_EXPORT_FILE
|
||||
@@ -661,7 +704,7 @@ export_configuration() {
|
||||
echo "export BOOT_DISKS_ID_LIST=\"(${BOOT_DISKS_ID_LIST[@]})\"" >> $CONFIG_EXPORT_FILE
|
||||
echo "export DATA_DISKS_ID=\"(${DATA_DISKS_ID[@]})\"" >> $CONFIG_EXPORT_FILE
|
||||
echo "export DATA_DISKS_TYPE=\"(${DATA_DISKS_TYPE[@]})\"" >> $CONFIG_EXPORT_FILE
|
||||
echo "export SPINDOWN_DISKS_LIST=\"(${SPINDOWN_DISKS_LIST[@]})\"" >> $CONFIG_EXPORT_FILE
|
||||
echo "export SPINDOWN_DISKS_LIST=\"(${SPINDOWN_DISKS_LIST[@]})\"" >> $CONFIG_EXPORT_FILE
|
||||
echo "export CONTENT_DISK_NUMBER=\"${CONTENT_DISK_NUMBER}\"" >> $CONFIG_EXPORT_FILE
|
||||
echo "export PARITY_DISK_NUMBER=\"${PARITY_DISK_NUMBER}\"" >> $CONFIG_EXPORT_FILE
|
||||
echo -e "\n# TPM SETTINGS" >> $CONFIG_EXPORT_FILE
|
||||
|
||||
Reference in New Issue
Block a user