diff --git a/README.md b/README.md index 5758fe5..877150d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# 🖥️ Update Manager - Version: 0.3.0 +# 🖥️ Update Manager Simple CLI tool to check and manage updates across multiple Ubuntu systems over SSH. @@ -26,10 +26,10 @@ Built for Lanx environments – lightweight, fast and no unnecessary dependencie ## Features * Check updates on multiple hosts -* Run checks remotely over SSH +* Run updates remotely over SSH +* Interactive CLI menu (dialog-based UI) +* Centralized logging * Simple config files -* Built-in logging (file + terminal) -* Dialog-based UI menu * No agents required * Works with existing SSH setup @@ -37,12 +37,20 @@ Built for Lanx environments – lightweight, fast and no unnecessary dependencie ## Update Manager UI +### Main menu +

- Update Manager CLI UI + Main menu +

+ +### Log menu + +

+ Log menu

- Lightweight • Terminal-based • Works over SSH + Lightweight • No dependencies • Works over SSH

--- @@ -54,7 +62,7 @@ git clone https://github.com/YOUR-USER/update-manager.git cd update-manager sudo apt update -sudo apt install -y dialog openssh-client +sudo apt install dialog openssh-client sudo mkdir -p /opt/update-manager sudo cp update-manager.sh update-manager-ui.sh dialogrc /opt/update-manager/ @@ -62,8 +70,8 @@ sudo cp update-manager.sh update-manager-ui.sh dialogrc /opt/update-manager/ sudo chmod +x /opt/update-manager/update-manager.sh sudo chmod +x /opt/update-manager/update-manager-ui.sh -sudo ln -sf /opt/update-manager/update-manager.sh /usr/local/bin/update-manager -sudo ln -sf /opt/update-manager/update-manager-ui.sh /usr/local/bin/update-manager-ui +sudo ln -s /opt/update-manager/update-manager.sh /usr/local/bin/update-manager +sudo ln -s /opt/update-manager/update-manager-ui.sh /usr/local/bin/update-manager-ui ``` --- @@ -134,6 +142,12 @@ server3 192.168.1.30 user ## Usage +### Check updates + +```bash +update-manager check +``` + ### Start UI ```bash @@ -142,42 +156,25 @@ update-manager-ui --- -### Check updates (CLI) - -```bash -update-manager check -``` - ---- - ## Logging -The tool logs both to terminal and file. - -### Primary location +Log file location: ```bash /opt/update-manager/log/update-manager.log ``` -### Fallback location +View log: ```bash -~/update-manager/log/update-manager.log +less /opt/update-manager/log/update-manager.log ``` -### Notes +Follow log: -* Log directory is created automatically -* Log file is created automatically -* Output is written to both terminal and file -* Log levels: - - * INFO - * WARN - * ERROR - -Logs can be viewed directly from the UI. +```bash +tail -f /opt/update-manager/log/update-manager.log +``` --- @@ -189,8 +186,8 @@ Logs can be viewed directly from the UI. ├── update-manager-ui.sh ├── update-manager.conf ├── hosts.conf -└── log/ - └── update-manager.log +├── log/ +│ └── update-manager.log ``` --- @@ -199,6 +196,7 @@ Logs can be viewed directly from the UI. * Uses SSH to connect to each host * Runs `apt` commands remotely +* Logs results locally * No agents or services needed * Designed for simple and efficient operations @@ -209,7 +207,6 @@ Logs can be viewed directly from the UI. * SSH access to all hosts * SSH keys recommended (no password prompts) * Ubuntu/Debian-based systems -* `dialog` (for UI) --- @@ -218,7 +215,6 @@ Logs can be viewed directly from the UI. * 🔔 Notifications (ntfy / push alerts) * 🌐 Web interface * 📧 Email reporting -* 📜 Advanced logging / audit trail * 📊 Basic monitoring (status, last check, pending updates) * 🧩 Plugin system (extensible modules) * 🔐 Security & compliance checks diff --git a/menu-logs.png b/menu-logs.png new file mode 100644 index 0000000..1bffefe Binary files /dev/null and b/menu-logs.png differ diff --git a/menu-main.png b/menu-main.png new file mode 100644 index 0000000..80e1e80 Binary files /dev/null and b/menu-main.png differ diff --git a/update-manager-ui.sh b/update-manager-ui.sh index aa4f823..af17391 100755 --- a/update-manager-ui.sh +++ b/update-manager-ui.sh @@ -11,24 +11,85 @@ get_log_file() { if [[ -f "$primary" ]]; then echo "$primary" - else + elif [[ -f "$fallback" ]]; then echo "$fallback" + else + echo "" fi } +show_log_menu() { + while true; do + log_choice=$(dialog --clear \ + --backtitle "Update Manager" \ + --title "Log menu" \ + --menu "Select log action:" 18 60 10 \ + 1 "View full log" \ + 2 "Follow log live" \ + 3 "Show log location" \ + 4 "Show last 20 log lines" \ + 0 "Back" \ + 3>&1 1>&2 2>&3) + + clear + + case "$log_choice" in + 1) + log_file="$(get_log_file)" + if [[ -n "$log_file" ]]; then + less "$log_file" + else + echo "No log file found yet." + read -rp "Press Enter to continue..." + fi + ;; + 2) + log_file="$(get_log_file)" + if [[ -n "$log_file" ]]; then + echo "Press Ctrl+C to stop" + tail -n 20 -f "$log_file" + else + echo "No log file found yet." + fi + read -rp "Press Enter to continue..." + ;; + 3) + log_file="$(get_log_file)" + if [[ -n "$log_file" ]]; then + echo "Log file:" + echo "$log_file" + else + echo "No log file found yet." + fi + read -rp "Press Enter to continue..." + ;; + 4) + log_file="$(get_log_file)" + if [[ -n "$log_file" ]]; then + tail -n 20 "$log_file" + else + echo "No log file found yet." + fi + read -rp "Press Enter to continue..." + ;; + 0|"") + break + ;; + esac + done +} + while true; do choice=$(dialog --clear \ --backtitle "Update Manager" \ --title "Choose an action" \ - --menu "Select option:" 16 60 9 \ + --menu "Select option:" 20 60 10 \ 1 "Check all hosts" \ 2 "View hosts file" \ 3 "Edit hosts file" \ 4 "Add host" \ 5 "Remove host" \ - 6 "View full log" \ - 7 "Follow log live" \ - 8 "Show log location" \ + 6 "Log menu" \ 0 "Exit" \ 3>&1 1>&2 2>&3) @@ -40,12 +101,7 @@ while true; do read -rp "Press Enter to continue..." ;; 2) - if [[ -f "$HOSTS_FILE" ]]; then - less "$HOSTS_FILE" - else - echo "Hosts file not found: $HOSTS_FILE" - read -rp "Press Enter to continue..." - fi + less "$HOSTS_FILE" ;; 3) nano "$HOSTS_FILE" @@ -54,34 +110,27 @@ while true; do read -rp "Name: " name read -rp "IP: " ip read -rp "User: " user - echo "$name $ip $user" >> "$HOSTS_FILE" - echo "Host added." + if [[ -z "$name" || -z "$ip" || -z "$user" ]]; then + echo "All fields are required." + else + echo "$name $ip $user" >> "$HOSTS_FILE" + echo "Host added." + fi read -rp "Press Enter to continue..." ;; 5) - if [[ -f "$HOSTS_FILE" ]]; then - nl -w2 -s'. ' "$HOSTS_FILE" - read -rp "Line to remove: " line + nl -w2 -s'. ' "$HOSTS_FILE" + read -rp "Line to remove: " line + if [[ "$line" =~ ^[0-9]+$ ]]; then sed -i "${line}d" "$HOSTS_FILE" echo "Host removed." else - echo "Hosts file not found: $HOSTS_FILE" + echo "Invalid line number." fi read -rp "Press Enter to continue..." ;; 6) - less "$(get_log_file)" - ;; - 7) - echo "Following log: $(get_log_file)" - echo "Press Ctrl+C to stop." - tail -f "$(get_log_file)" - read -rp "Press Enter to continue..." - ;; - 8) - echo "Log file:" - echo "$(get_log_file)" - read -rp "Press Enter to continue..." + show_log_menu ;; 0|"") clear