Add terminal UI and update README
This commit is contained in:
parent
9b52c19d86
commit
e54c510f74
2 changed files with 23 additions and 98 deletions
23
README.md
23
README.md
|
|
@ -110,3 +110,26 @@ db 192.168.1.20 root
|
||||||
* Lines starting with `#` are ignored
|
* Lines starting with `#` are ignored
|
||||||
* Empty lines are ignored
|
* Empty lines are ignored
|
||||||
* Requires passwordless SSH access
|
* 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
|
||||||
|
|
|
||||||
|
|
@ -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
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue