From 33d64041ff1c657f54544c373c228c0d50897e1a Mon Sep 17 00:00:00 2001 From: Peter Wood Date: Thu, 12 Mar 2026 11:18:36 -0400 Subject: [PATCH] feat: Update color code definitions for consistency across scripts --- plex/backup-plex.sh | 12 +++---- plex/check-plex-builtin-backups.sh | 10 +++--- plex/cleanup-plex-databases.sh | 10 +++--- plex/integration-test-plex.sh | 12 +++---- plex/monitor-plex-backup.sh | 14 ++++---- plex/nuclear-plex-recovery.sh | 10 +++--- plex/plex-db-manager.sh | 18 +++++------ plex/plex.sh | 51 +++++++++++++++++++++++------- plex/scan-plex-libraries.sh | 20 ++++++------ plex/test-plex-backup.sh | 12 +++---- plex/validate-plex-backups.sh | 10 +++--- plex/validate-plex-recovery.sh | 10 +++--- 12 files changed, 109 insertions(+), 80 deletions(-) diff --git a/plex/backup-plex.sh b/plex/backup-plex.sh index 47ff232..d74a59e 100755 --- a/plex/backup-plex.sh +++ b/plex/backup-plex.sh @@ -51,12 +51,12 @@ # Critical operations use explicit error checking instead of automatic exit # Color codes for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -CYAN='\033[0;36m' -NC='\033[0m' # No Color +RED=$'\033[0;31m' +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +CYAN=$'\033[0;36m' +NC=$'\033[0m' # No Color # Performance tracking variables (removed unused variables) diff --git a/plex/check-plex-builtin-backups.sh b/plex/check-plex-builtin-backups.sh index 5060d5c..92424f6 100755 --- a/plex/check-plex-builtin-backups.sh +++ b/plex/check-plex-builtin-backups.sh @@ -15,11 +15,11 @@ ################################################################################ # Color codes -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -RED='\033[0;31m' -NC='\033[0m' # No Color +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +RED=$'\033[0;31m' +NC=$'\033[0m' # No Color # Plex database path PLEX_DB_PATH="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases" diff --git a/plex/cleanup-plex-databases.sh b/plex/cleanup-plex-databases.sh index a35c867..2b8c382 100755 --- a/plex/cleanup-plex-databases.sh +++ b/plex/cleanup-plex-databases.sh @@ -12,11 +12,11 @@ set +e # Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color +RED=$'\033[0;31m' +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +NC=$'\033[0m' # No Color # Configuration PLEX_DB_DIR="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases" diff --git a/plex/integration-test-plex.sh b/plex/integration-test-plex.sh index 479cfd5..cce7249 100755 --- a/plex/integration-test-plex.sh +++ b/plex/integration-test-plex.sh @@ -55,12 +55,12 @@ set -e # Color codes for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -CYAN='\033[0;36m' -NC='\033[0m' # No Color +RED=$'\033[0;31m' +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +CYAN=$'\033[0;36m' +NC=$'\033[0m' # No Color # Test configuration SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" diff --git a/plex/monitor-plex-backup.sh b/plex/monitor-plex-backup.sh index 213ad50..86ece52 100755 --- a/plex/monitor-plex-backup.sh +++ b/plex/monitor-plex-backup.sh @@ -49,13 +49,13 @@ set -e # Color codes for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -CYAN='\033[0;36m' -MAGENTA='\033[0;35m' -NC='\033[0m' # No Color +RED=$'\033[0;31m' +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +CYAN=$'\033[0;36m' +MAGENTA=$'\033[0;35m' +NC=$'\033[0m' # No Color # Configuration SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" diff --git a/plex/nuclear-plex-recovery.sh b/plex/nuclear-plex-recovery.sh index 4639a99..d5b940c 100755 --- a/plex/nuclear-plex-recovery.sh +++ b/plex/nuclear-plex-recovery.sh @@ -58,11 +58,11 @@ set -e # Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color +RED=$'\033[0;31m' +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +NC=$'\033[0m' # No Color # Configuration PLEX_DB_DIR="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases" diff --git a/plex/plex-db-manager.sh b/plex/plex-db-manager.sh index e4dfdf8..35e2adf 100755 --- a/plex/plex-db-manager.sh +++ b/plex/plex-db-manager.sh @@ -34,15 +34,15 @@ set -euo pipefail # Color codes for output -readonly RED='\033[0;31m' -readonly GREEN='\033[0;32m' -readonly YELLOW='\033[1;33m' -readonly BLUE='\033[0;34m' -readonly CYAN='\033[0;36m' -readonly WHITE='\033[1;37m' -readonly BOLD='\033[1m' -readonly DIM='\033[2m' -readonly RESET='\033[0m' +readonly RED=$'\033[0;31m' +readonly GREEN=$'\033[0;32m' +readonly YELLOW=$'\033[1;33m' +readonly BLUE=$'\033[0;34m' +readonly CYAN=$'\033[0;36m' +readonly WHITE=$'\033[1;37m' +readonly BOLD=$'\033[1m' +readonly DIM=$'\033[2m' +readonly RESET=$'\033[0m' # Configuration readonly PLEX_SERVICE="plexmediaserver" diff --git a/plex/plex.sh b/plex/plex.sh index 68944ae..c43be94 100755 --- a/plex/plex.sh +++ b/plex/plex.sh @@ -57,16 +57,16 @@ set -euo pipefail # 🎨 Color definitions for sexy output -readonly RED='\033[0;31m' -readonly GREEN='\033[0;32m' -readonly YELLOW='\033[1;33m' -readonly BLUE='\033[0;34m' -readonly PURPLE='\033[0;35m' -readonly CYAN='\033[0;36m' -readonly WHITE='\033[1;37m' -readonly BOLD='\033[1m' -readonly DIM='\033[2m' -readonly RESET='\033[0m' +readonly RED=$'\033[0;31m' +readonly GREEN=$'\033[0;32m' +readonly YELLOW=$'\033[1;33m' +readonly BLUE=$'\033[0;34m' +readonly PURPLE=$'\033[0;35m' +readonly CYAN=$'\033[0;36m' +readonly WHITE=$'\033[1;37m' +readonly BOLD=$'\033[1m' +readonly DIM=$'\033[2m' +readonly RESET=$'\033[0m' # 🔧 Configuration readonly PLEX_SERVICE="plexmediaserver" @@ -784,6 +784,7 @@ show_help() { printf " ${RED}${BOLD}%-18s${RESET} %s %s\n" "nuclear" "[!!]" "Nuclear database recovery (last resort)" printf " ${CYAN}${BOLD}%-18s${RESET} %s %s\n" "backups" "[#]" "List and manage database backup files" printf " ${GREEN}${BOLD}%-18s${RESET} %s %s\n" "install-dbrepair" "[+]" "Install or update DBRepair tool" + printf " ${WHITE}${BOLD}%-18s${RESET} %s %s\n" "tui" "[>]" "Launch interactive TUI dashboard" printf " ${PURPLE}${BOLD}%-18s${RESET} %s %s\n" "help" "${HOURGLASS}" "Show this help message" echo "" echo -e "${DIM}${WHITE}Examples:${RESET}" @@ -796,10 +797,35 @@ show_help() { printf " ${DIM}%-40s # %s${RESET}\n" "${SCRIPT_NAME} backups delete" "Interactive backup deletion" printf " ${DIM}%-40s # %s${RESET}\n" "${SCRIPT_NAME} backups delete --name foo" "Delete by name pattern" printf " ${DIM}%-40s # %s${RESET}\n" "${SCRIPT_NAME} install-dbrepair" "Install/update DBRepair" + printf " ${DIM}%-40s # %s${RESET}\n" "${SCRIPT_NAME} tui" "Launch full TUI dashboard" echo "" } -# 📚 Function to launch library scanner +# �️ Function to launch the Python TUI dashboard +launch_tui() { + local venv_dir="${SCRIPT_DIR}/.venv" + local tui_app="${SCRIPT_DIR}/tui/app.py" + + if [[ ! -f "$tui_app" ]]; then + print_status "${CROSS}" "TUI application not found: $tui_app" "${RED}" + return 1 + fi + + # Create venv and install dependencies if needed + if [[ ! -d "$venv_dir" ]]; then + print_status "${INFO}" "Setting up Python environment (first run)..." "${BLUE}" + if ! python3 -m venv "$venv_dir" 2>/dev/null; then + print_status "${CROSS}" "Failed to create Python venv. Install python3-venv." "${RED}" + return 1 + fi + "${venv_dir}/bin/pip" install --quiet textual + print_status "${CHECKMARK}" "Python environment ready" "${GREEN}" + fi + + exec "${venv_dir}/bin/python3" "$tui_app" +} + +# �📚 Function to launch library scanner launch_scanner() { print_status "${SPARKLES}" "Launching Plex Library Scanner..." "${PURPLE}" @@ -966,6 +992,9 @@ main() { "install-dbrepair"|"update-dbrepair"|"dbrepair") install_or_update_dbrepair ;; + "tui"|"dashboard"|"ui") + launch_tui + ;; "backups"|"backup-list") if [[ $# -ge 2 && "${2,,}" == "delete" ]]; then if [[ $# -ge 4 && "${3}" == "--name" ]]; then diff --git a/plex/scan-plex-libraries.sh b/plex/scan-plex-libraries.sh index 6ef8010..73bc52e 100755 --- a/plex/scan-plex-libraries.sh +++ b/plex/scan-plex-libraries.sh @@ -44,16 +44,16 @@ set -euo pipefail # 🎨 Color definitions for styled output -readonly RED='\033[0;31m' -readonly GREEN='\033[0;32m' -readonly YELLOW='\033[1;33m' -readonly BLUE='\033[0;34m' -readonly PURPLE='\033[0;35m' -readonly CYAN='\033[0;36m' -readonly WHITE='\033[1;37m' -readonly BOLD='\033[1m' -readonly DIM='\033[2m' -readonly RESET='\033[0m' +readonly RED=$'\033[0;31m' +readonly GREEN=$'\033[0;32m' +readonly YELLOW=$'\033[1;33m' +readonly BLUE=$'\033[0;34m' +readonly PURPLE=$'\033[0;35m' +readonly CYAN=$'\033[0;36m' +readonly WHITE=$'\033[1;37m' +readonly BOLD=$'\033[1m' +readonly DIM=$'\033[2m' +readonly RESET=$'\033[0m' # 🔧 Configuration readonly PLEX_SERVICE="plexmediaserver" diff --git a/plex/test-plex-backup.sh b/plex/test-plex-backup.sh index c1d6b2b..79ee58f 100755 --- a/plex/test-plex-backup.sh +++ b/plex/test-plex-backup.sh @@ -54,12 +54,12 @@ set -e # Color codes for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -CYAN='\033[0;36m' -NC='\033[0m' # No Color +RED=$'\033[0;31m' +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +CYAN=$'\033[0;36m' +NC=$'\033[0m' # No Color # Test configuration TEST_DIR="/tmp/plex-backup-test-$(date +%s)" diff --git a/plex/validate-plex-backups.sh b/plex/validate-plex-backups.sh index b73e3c5..302ac0f 100755 --- a/plex/validate-plex-backups.sh +++ b/plex/validate-plex-backups.sh @@ -50,11 +50,11 @@ set -e -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' +RED=$'\033[0;31m' +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +NC=$'\033[0m' # Configuration SCRIPT_DIR="$(dirname "$(readlink -f "$0")")" diff --git a/plex/validate-plex-recovery.sh b/plex/validate-plex-recovery.sh index d1e0259..a0040c9 100755 --- a/plex/validate-plex-recovery.sh +++ b/plex/validate-plex-recovery.sh @@ -53,11 +53,11 @@ # Comprehensive check to ensure Plex is fully recovered and functional # Colors for output -RED='\033[0;31m' -GREEN='\033[0;32m' -YELLOW='\033[1;33m' -BLUE='\033[0;34m' -NC='\033[0m' # No Color +RED=$'\033[0;31m' +GREEN=$'\033[0;32m' +YELLOW=$'\033[1;33m' +BLUE=$'\033[0;34m' +NC=$'\033[0m' # No Color PLEX_DB_DIR="/var/lib/plexmediaserver/Library/Application Support/Plex Media Server/Plug-in Support/Databases"