miyagi-check.sh aktualisiert

This commit is contained in:
2025-07-15 01:49:11 +02:00
parent 127431689a
commit 564939053a
+36 -12
View File
@@ -2,6 +2,7 @@
set -euo pipefail set -euo pipefail
IFS=$'\n\t' IFS=$'\n\t'
PERMITROOT_YES_HOSTS=()
LOG() { LOG() {
echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*" echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
} }
@@ -9,25 +10,24 @@ LOG() {
CONFIG_FILE="${1:-}" CONFIG_FILE="${1:-}"
if [[ -z "$CONFIG_FILE" ]]; then if [[ -z "$CONFIG_FILE" ]]; then
LOG "Keine Konfigurationsdatei übergeben." LOG "Keine Konfigurationsdatei übergeben."
echo "Usage: $0 /pfad/zur/config" echo "Usage: $0 /pfad/zur/config"
exit 1 exit 1
fi fi
if [[ ! -f "$CONFIG_FILE" ]]; then if [[ ! -f "$CONFIG_FILE" ]]; then
LOG "Konfigurationsdatei nicht gefunden: $CONFIG_FILE" LOG "Konfigurationsdatei nicht gefunden: $CONFIG_FILE"
exit 1 exit 1
fi fi
if ! bash -n "$CONFIG_FILE"; then if ! bash -n "$CONFIG_FILE"; then
LOG "Syntaxfehler in der Konfigurationsdatei!" LOG "Syntaxfehler in der Konfigurationsdatei!"
exit 1 exit 1
fi fi
source "$CONFIG_FILE" source "$CONFIG_FILE"
REQUIRED_VARS=( REQUIRED_VARS=(
SOURCEHOST
SOURCEPORT SOURCEPORT
BACKUPSERVER BACKUPSERVER
ZSYNC ZSYNC
@@ -106,7 +106,6 @@ check_and_copy_ssh_key() {
LOG " Lokaler SSH-Public-Key ($keyfile) nicht gefunden!" LOG " Lokaler SSH-Public-Key ($keyfile) nicht gefunden!"
return 1 return 1
fi fi
local pubkey local pubkey
pubkey=$(<"$keyfile") pubkey=$(<"$keyfile")
@@ -119,7 +118,7 @@ check_and_copy_ssh_key() {
read -rp " Möchtest du den SSH-Key jetzt via ssh-copy-id übertragen? [j/N] " ans read -rp " Möchtest du den SSH-Key jetzt via ssh-copy-id übertragen? [j/N] " ans
if [[ "$ans" =~ ^[JjYy]$ ]]; then if [[ "$ans" =~ ^[JjYy]$ ]]; then
ssh-copy-id -p "$SSHPORT" "$host" ssh-copy-id -p "$SOURCEPORT" "$host"
else else
LOG " SSH-Key nicht übertragen." LOG " SSH-Key nicht übertragen."
fi fi
@@ -155,23 +154,48 @@ check_pveversion() {
LOG " 'pveversion' ist auf $host nicht verfügbar kein Proxmox?" LOG " 'pveversion' ist auf $host nicht verfügbar kein Proxmox?"
fi fi
} }
check_pbs_version() {
local host=$1
local port=$2
LOG "Prüfe PBS-Version auf $host ..."
if ssh -p "$port" "$host" "command -v proxmox-backup-manager >/dev/null"; then
ssh -p "$port" "$host" "proxmox-backup-manager version" | while read -r line; do
LOG " $host: $line"
done
else
LOG " 'proxmox-backup-manager' ist auf $host nicht verfügbar kein PBS?"
fi
}
run_host_check() { run_host_check() {
local host=$1 local host=$1
local type=${2:-pve}
local port=$SOURCEPORT
local pbsport=$PBSPORT
LOG "" LOG ""
LOG "=== Prüfung für Host: $host ===" LOG "=== Prüfung für Host: $host (Typ: $type) ==="
if check_ssh_connection "$host"; then
if check_ssh_connection "$host" "$port"; then
check_and_copy_ssh_key "$host" check_and_copy_ssh_key "$host"
check_sshd_config_recommendation "$host" check_sshd_config_recommendation "$host"
check_pveversion "$host"
if [[ "$type" == "pve" ]]; then
check_pveversion "$host" "$port"
elif [[ "$type" == "pbs" ]]; then
check_pbs_version "$host" "$pbsport"
else
LOG " Unbekannter Host-Typ: $type"
fi
fi fi
echo "" echo ""
} }
run_host_check "$SOURCEHOST"
run_host_check "$SOURCEHOST" pve
if [[ "$BACKUPSERVER" == "yes" ]]; then if [[ "$BACKUPSERVER" == "yes" ]]; then
run_host_check "$PBSHOST" run_host_check "$PBSHOST" pbs
else else
LOG " BACKUPSERVER ist deaktiviert PBSHOST wird übersprungen." LOG " BACKUPSERVER ist deaktiviert PBSHOST wird übersprungen."
fi fi