From 15fda585d1ed4b167882bf5ec30b2758fb13935e Mon Sep 17 00:00:00 2001 From: zaphod-black Date: Sun, 2 Nov 2025 01:37:19 -0500 Subject: [PATCH] UX: Smart menu adapts based on installation status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Menu now automatically detects if PBSClientTool is installed as a system command and hides the install option when already installed. DETECTION: - Checks if /usr/local/bin/PBSClientTool exists at startup - Stores result in SCRIPT_INSTALLED variable (true/false) - No verbose messages - detection is silent MENU BEHAVIOR: When NOT installed: 1) List all backup targets 2) Add new backup target 3) Edit existing target 4) Delete target 5) Run backup now (select target) 6) Reinstall PBS client 7) Install as system command ← Shows option 8) Exit Select option [1-8] [8]: When INSTALLED: 1) List all backup targets 2) Add new backup target 3) Edit existing target 4) Delete target 5) Run backup now (select target) 6) Reinstall PBS client 7) Exit ← Option 7 is now Exit Select option [1-7] [7]: SMART CASE HANDLING: - Option 7 handler checks SCRIPT_INSTALLED status - If false: Runs install_script() - If true: Exits program - Option 8 handler checks SCRIPT_INSTALLED status - If false: Exits program - If true: Shows "Invalid option" error - After installing from menu, SCRIPT_INSTALLED updates to true - Menu immediately reflects change on next iteration BENEFITS: - Cleaner UX - no redundant options - Self-documenting - absence of option indicates already installed - Automatic adaptation - no manual refresh needed - Prevents confusion - users won't try to install twice - Professional behavior - menus adapt to system state EDGE CASE HANDLING: - If user installs from menu option 7, status updates immediately - Next menu loop shows 7 options instead of 8 - Install option doesn't reappear until uninstalled 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- CHANGELOG.md | 9 +++++++++ pbs-client-installer.sh | 40 ++++++++++++++++++++++++++++++++++------ 2 files changed, 43 insertions(+), 6 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b1a4128..5cb9eb3 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -142,6 +142,15 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Runs in subshell to avoid environment pollution ### Changed +- **Smart menu adaptation based on installation status** + - Script detects if already installed as system command at startup + - Hides "Install as system command" menu option if already installed + - Menu adjusts from 8 options to 7 options when installed + - Exit option renumbers from 8 to 7 automatically + - Prompt range adjusts: [1-8] when not installed, [1-7] when installed + - Installation status tracked in SCRIPT_INSTALLED variable + - After installing from menu, option disappears immediately (updates status) + - Cleaner UX - no redundant install option when already installed - **Documentation reorganization** - README.md simplified from 750 lines to 243 lines - Removed redundant step-by-step walkthrough sections diff --git a/pbs-client-installer.sh b/pbs-client-installer.sh index 4f96e8d..979df72 100755 --- a/pbs-client-installer.sh +++ b/pbs-client-installer.sh @@ -2138,6 +2138,12 @@ main() { # Migrate legacy configuration if needed migrate_legacy_config + # Check if script is installed as system command + SCRIPT_INSTALLED=false + if [ -f "$INSTALL_PATH" ]; then + SCRIPT_INSTALLED=true + fi + # Check if PBS client is already installed if command -v proxmox-backup-client &> /dev/null; then warn "Proxmox Backup Client is already installed" @@ -2161,9 +2167,16 @@ main() { echo " 4) Delete target" echo " 5) Run backup now (select target)" echo " 6) Reinstall PBS client" - echo " 7) Install as system command" - echo " 8) Exit" - ACTION=$(prompt "Select option [1-8]" "8") + + # Only show install option if not already installed + if [ "$SCRIPT_INSTALLED" = false ]; then + echo " 7) Install as system command" + echo " 8) Exit" + ACTION=$(prompt "Select option [1-8]" "8") + else + echo " 7) Exit" + ACTION=$(prompt "Select option [1-7]" "7") + fi case "$ACTION" in 1) @@ -2241,11 +2254,26 @@ main() { log "PBS client reinstalled successfully" ;; 7) - install_script + # Option 7 is either "Install" or "Exit" depending on install status + if [ "$SCRIPT_INSTALLED" = false ]; then + install_script + # Update status if installation succeeded + if [ -f "$INSTALL_PATH" ]; then + SCRIPT_INSTALLED=true + fi + else + info "Exiting" + exit 0 + fi ;; 8) - info "Exiting" - exit 0 + # Option 8 only exists when not installed (it's Exit) + if [ "$SCRIPT_INSTALLED" = false ]; then + info "Exiting" + exit 0 + else + error "Invalid option" + fi ;; *) error "Invalid option"