From e54c510f74828ea62ebfc42f901246be749d595c Mon Sep 17 00:00:00 2001 From: Ed Nielsen Date: Wed, 18 Mar 2026 15:17:54 +0100 Subject: [PATCH] Add terminal UI and update README --- README.md | 23 +++++++++++ update-manager.sh | 98 ----------------------------------------------- 2 files changed, 23 insertions(+), 98 deletions(-) delete mode 100755 update-manager.sh diff --git a/README.md b/README.md index 48fdada..eca1709 100644 --- a/README.md +++ b/README.md @@ -110,3 +110,26 @@ db 192.168.1.20 root * Lines starting with `#` are ignored * Empty lines are ignored * Requires passwordless SSH access + +🖥️ Terminal UI + +You can also use the interactive terminal menu: + +update-manager-ui +Features + +Check all hosts + +View hosts file + +Edit hosts file + +Add host + +Remove host + +Requirements + +The UI uses whiptail. Install it if needed: + +sudo apt update && sudo apt install whiptail -y diff --git a/update-manager.sh b/update-manager.sh deleted file mode 100755 index 50d9925..0000000 --- a/update-manager.sh +++ /dev/null @@ -1,98 +0,0 @@ -#!/usr/bin/env bash - -######################################## -# Load config -######################################## - -CONFIG_FILE="/etc/update-manager.conf" -[[ -f "$CONFIG_FILE" ]] || CONFIG_FILE="./update-manager.conf" - -if [[ -f "$CONFIG_FILE" ]]; then - # shellcheck disable=SC1090 - source "$CONFIG_FILE" -fi - -HOSTS_FILE="${HOSTS_FILE:-./hosts.conf}" -SSH_OPTIONS="${SSH_OPTIONS:--o BatchMode=yes -o ConnectTimeout=5}" - -######################################## -# Check hosts -######################################## - -check_host() { - local name="$1" - local ip="$2" - local user="$3" - local result count - - result=$(ssh $SSH_OPTIONS "$user@$ip" \ - "apt list --upgradable 2>/dev/null | grep -v '^Listing'" 2>/dev/null) - - if [[ $? -ne 0 ]]; then - printf "%-15s ❌ connection failed\n" "$name" - return - fi - - if [[ -z "$result" ]]; then - printf "%-15s 🟢 up-to-date\n" "$name" - else - count=$(echo "$result" | wc -l) - printf "%-15s 🔴 %d updates\n" "$name" "$count" - fi -} - -check_all() { - while read -r name ip user; do - [[ -z "$name" ]] && continue - [[ "$name" =~ ^# ]] && continue - check_host "$name" "$ip" "$user" - done < "$HOSTS_FILE" -} - -######################################## -# Install -######################################## - -install_update_manager() { - echo "Installing update-manager..." - - local INSTALL_DIR="/opt/update-manager" - - # Opret mappe - sudo mkdir -p "$INSTALL_DIR" - - # Kopiér filer - sudo cp update-manager.sh "$INSTALL_DIR/" - sudo cp hosts.conf "$INSTALL_DIR/" 2>/dev/null - sudo cp update-manager.conf "$INSTALL_DIR/" 2>/dev/null - - # Gør eksekverbar - sudo chmod +x "$INSTALL_DIR/update-manager.sh" - - # Global config (kun hvis ikke findes) - if [[ -f update-manager.conf && ! -f /etc/update-manager.conf ]]; then - sudo cp update-manager.conf /etc/update-manager.conf - fi - - # Symlink → global kommando - sudo ln -sf "$INSTALL_DIR/update-manager.sh" /usr/local/bin/update-manager - - echo "Done!" - echo "Run: update-manager check" -} - -######################################## -# Main -######################################## - -case "$1" in - check) - check_all - ;; - install) - install_update_manager - ;; - *) - echo "Usage: $0 {check|install}" - ;; -esac