From 0004dbed9faad453812760f7a0e2daa7cd19fc62 Mon Sep 17 00:00:00 2001 From: shuki Date: Thu, 5 Mar 2026 21:38:19 +0200 Subject: [PATCH] Add first-time setup wizard for new installations Guides users through creating their first remote and target when gniza launches with no configuration. Optionally runs a first backup. Triggers only when both remotes.d/ and targets.d/ are empty. Co-Authored-By: Claude Opus 4.6 --- bin/gniza | 4 ++++ lib/ui_wizard.sh | 56 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 lib/ui_wizard.sh diff --git a/bin/gniza b/bin/gniza index 1c40276..f44b647 100755 --- a/bin/gniza +++ b/bin/gniza @@ -36,6 +36,7 @@ source "$GNIZA_DIR/lib/ui_retention.sh" source "$GNIZA_DIR/lib/ui_logs.sh" source "$GNIZA_DIR/lib/ui_schedule.sh" source "$GNIZA_DIR/lib/ui_settings.sh" +source "$GNIZA_DIR/lib/ui_wizard.sh" # ── ASCII Logo ─────────────────────────────────────────────── show_logo() { @@ -438,6 +439,9 @@ elif [[ "$FORCE_CLI" == "true" ]]; then elif command -v whiptail &>/dev/null && [[ -t 1 ]]; then # TUI mode show_logo + if ! has_remotes && ! has_targets; then + ui_first_run_wizard + fi ui_main_menu else # Fallback to CLI help diff --git a/lib/ui_wizard.sh b/lib/ui_wizard.sh new file mode 100644 index 0000000..452a35b --- /dev/null +++ b/lib/ui_wizard.sh @@ -0,0 +1,56 @@ +#!/usr/bin/env bash +# gniza4linux/lib/ui_wizard.sh — First-time setup wizard + +[[ -n "${_GNIZA4LINUX_UI_WIZARD_LOADED:-}" ]] && return 0 +_GNIZA4LINUX_UI_WIZARD_LOADED=1 + +ui_first_run_wizard() { + # Step 1: Welcome + ui_msgbox "Welcome to gniza Backup Manager!\n\nThis wizard will help you set up your first backup:\n\n 1. Configure a backup destination (remote)\n 2. Define what to back up (target)\n 3. Optionally run your first backup\n\nPress OK to start, or Cancel to skip." \ + || return 0 + + # Step 2: Create first remote + ui_msgbox "Step 1 of 3: Configure Backup Destination\n\nChoose where your backups will be stored:\n - SSH server\n - Local directory (USB/NFS)\n - Amazon S3\n - Google Drive" + + local remote_created=false + while ! $remote_created; do + ui_remote_add + if has_remotes; then + remote_created=true + else + if ! ui_yesno "No remote was created.\n\nWould you like to try again?"; then + ui_msgbox "You can configure remotes later from the main menu.\n\nSetup wizard exiting." + return 0 + fi + fi + done + + # Step 3: Create first target + ui_msgbox "Step 2 of 3: Define Backup Target\n\nChoose a name for your backup profile and select the folders you want to back up." + + local target_created=false + while ! $target_created; do + ui_target_add + if has_targets; then + target_created=true + else + if ! ui_yesno "No target was created.\n\nWould you like to try again?"; then + ui_msgbox "You can configure targets later from the main menu.\n\nSetup wizard exiting." + return 0 + fi + fi + done + + # Step 4: Optionally run first backup + local target + target=$(list_targets | head -1) + local remote + remote=$(list_remotes | head -1) + + if ui_yesno "Step 3 of 3: Run First Backup?\n\nTarget: $target\nRemote: $remote\n\nRun your first backup now?"; then + _ui_run_backup "$target" "$remote" + fi + + # Done + ui_msgbox "Setup complete!\n\nYou can manage your backups from the main menu:\n - Add more targets and remotes\n - Schedule automatic backups\n - Browse and restore snapshots" +}