manager.sh aktualisiert
This commit is contained in:
1 parent
476079ffa3
commit
60d28bff57
1 file changed
+163
-81
+163
-81
@@ -58,11 +58,13 @@ wt_menu() {
|
|||||||
wt_yesno() {
|
wt_yesno() {
|
||||||
local title="$1" text="$2" default="${3:-no}" args=()
|
local title="$1" text="$2" default="${3:-no}" args=()
|
||||||
[[ "$default" == "no" ]] && args+=(--defaultno)
|
[[ "$default" == "no" ]] && args+=(--defaultno)
|
||||||
whiptail "${args[@]}" --title "$title" --yesno "$text" 12 78 </dev/tty
|
whiptail "${args[@]}" --title "$title" --yes-button "Ja" --no-button "Nein" \
|
||||||
|
--yesno "$text" 14 86 </dev/tty
|
||||||
}
|
}
|
||||||
wt_input() {
|
wt_input() {
|
||||||
local title="$1" text="$2" value="${3:-}"
|
local title="$1" text="$2" value="${3:-}"
|
||||||
whiptail --title "$title" --inputbox "$text" 12 78 "$value" 3>&1 1>&2 2>&3 </dev/tty
|
whiptail --title "$title" --ok-button "Uebernehmen" --cancel-button "Zurueck" \
|
||||||
|
--inputbox "$text" 14 86 "$value" 3>&1 1>&2 2>&3 </dev/tty
|
||||||
}
|
}
|
||||||
wt_msg() {
|
wt_msg() {
|
||||||
whiptail --title "$1" --ok-button "OK" --msgbox "$2" 24 100 </dev/tty
|
whiptail --title "$1" --ok-button "OK" --msgbox "$2" 24 100 </dev/tty
|
||||||
@@ -445,64 +447,118 @@ Diesen Zeitplan trotzdem wirklich uebernehmen?" no || return 2
|
|||||||
}
|
}
|
||||||
|
|
||||||
schedule_menu() {
|
schedule_menu() {
|
||||||
local choice x rc
|
local choice result rc
|
||||||
while true; do
|
local -a vals=()
|
||||||
choice="$(wt_menu "Automatischer Zeitplan" \
|
|
||||||
"Wie oft soll der Updater laufen?
|
|
||||||
|
|
||||||
Aktuell: $(schedule_desc)
|
choice="$(whiptail --title "Automatischer Zeitplan" \
|
||||||
|
--ok-button "Weiter" --cancel-button "Zurueck" \
|
||||||
|
--radiolist "Aktuell:
|
||||||
|
$(schedule_desc)
|
||||||
|
|
||||||
Proxmox-Autobackups:
|
Vorhandene Proxmox-Autobackups:
|
||||||
$(backup_jobs)" \
|
$(backup_jobs)
|
||||||
daily "Taeglich" \
|
|
||||||
weekly "Woechentlich (empfohlen)" \
|
Gewuenschten Rhythmus mit LEERTASTE markieren." \
|
||||||
monthly "Monatlich" \
|
26 100 8 \
|
||||||
interval "Alle X Monate" \
|
daily "Taeglich" "$([[ "$SCHEDULE_TYPE" == daily ]] && echo ON || echo OFF)" \
|
||||||
yearly "Jaehrlich" \
|
weekly "Woechentlich (empfohlen)" "$([[ "$SCHEDULE_TYPE" == weekly ]] && echo ON || echo OFF)" \
|
||||||
custom "Eigener systemd-Zeitplan" \
|
monthly "Monatlich" "$([[ "$SCHEDULE_TYPE" == monthly ]] && echo ON || echo OFF)" \
|
||||||
BACK "Zurueck")" || return
|
interval "Alle X Monate" "$([[ "$SCHEDULE_TYPE" == interval ]] && echo ON || echo OFF)" \
|
||||||
|
yearly "Jaehrlich" "$([[ "$SCHEDULE_TYPE" == yearly ]] && echo ON || echo OFF)" \
|
||||||
|
custom "Eigener systemd-Zeitplan" "$([[ "$SCHEDULE_TYPE" == custom ]] && echo ON || echo OFF)" \
|
||||||
|
3>&1 1>&2 2>&3 </dev/tty)" || return
|
||||||
|
|
||||||
[[ "$choice" == BACK ]] && return
|
|
||||||
SCHEDULE_TYPE="$choice"
|
SCHEDULE_TYPE="$choice"
|
||||||
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
daily) choose_time || continue ;;
|
daily)
|
||||||
weekly) choose_weekday || continue; choose_time || continue ;;
|
result="$(whiptail --title "Zeitplan - Taeglich" --ok-button "Pruefen" --cancel-button "Zurueck" \
|
||||||
monthly) choose_monthday || continue; choose_time || continue ;;
|
--form "Taeglicher automatischer Lauf." 14 82 4 \
|
||||||
|
"Uhrzeit (HH:MM):" 1 1 "$SCHEDULE_TIME" 1 35 8 0 \
|
||||||
|
3>&1 1>&2 2>&3 </dev/tty)" || return
|
||||||
|
mapfile -t vals <<<"$result"; SCHEDULE_TIME="${vals[0]:-}"
|
||||||
|
;;
|
||||||
|
weekly)
|
||||||
|
result="$(whiptail --title "Zeitplan - Woechentlich" --ok-button "Pruefen" --cancel-button "Zurueck" \
|
||||||
|
--form "Empfohlen: ein fester Wochentag ausserhalb der Backup-Zeiten.
|
||||||
|
|
||||||
|
Wochentag: Mon Tue Wed Thu Fri Sat Sun" 17 88 5 \
|
||||||
|
"Wochentag:" 1 1 "$SCHEDULE_WEEKDAY" 1 35 8 0 \
|
||||||
|
"Uhrzeit (HH:MM):" 3 1 "$SCHEDULE_TIME" 3 35 8 0 \
|
||||||
|
3>&1 1>&2 2>&3 </dev/tty)" || return
|
||||||
|
mapfile -t vals <<<"$result"; SCHEDULE_WEEKDAY="${vals[0]:-}"; SCHEDULE_TIME="${vals[1]:-}"
|
||||||
|
;;
|
||||||
|
monthly)
|
||||||
|
result="$(whiptail --title "Zeitplan - Monatlich" --ok-button "Pruefen" --cancel-button "Zurueck" \
|
||||||
|
--form "Monatlicher automatischer Lauf. Tag 1-28." 15 82 5 \
|
||||||
|
"Tag des Monats:" 1 1 "$SCHEDULE_MONTHDAY" 1 35 8 0 \
|
||||||
|
"Uhrzeit (HH:MM):" 3 1 "$SCHEDULE_TIME" 3 35 8 0 \
|
||||||
|
3>&1 1>&2 2>&3 </dev/tty)" || return
|
||||||
|
mapfile -t vals <<<"$result"; SCHEDULE_MONTHDAY="${vals[0]:-}"; SCHEDULE_TIME="${vals[1]:-}"
|
||||||
|
;;
|
||||||
interval)
|
interval)
|
||||||
while true; do
|
result="$(whiptail --title "Zeitplan - Alle X Monate" --ok-button "Pruefen" --cancel-button "Zurueck" \
|
||||||
x="$(wt_input "Zeitplan" "Alle wie viele Monate? (2-12)" "$SCHEDULE_INTERVAL_MONTHS")" || break
|
--form "Intervall 2-12 Monate. Startmonat 1-12. Tag 1-28." 18 88 7 \
|
||||||
[[ "$x" =~ ^([2-9]|1[0-2])$ ]] && { SCHEDULE_INTERVAL_MONTHS="$x"; break; }
|
"Intervall Monate:" 1 1 "$SCHEDULE_INTERVAL_MONTHS" 1 38 8 0 \
|
||||||
wt_msg "Fehler" "Bitte 2 bis 12 eingeben."
|
"Startmonat:" 3 1 "$SCHEDULE_START_MONTH" 3 38 8 0 \
|
||||||
done
|
"Tag des Monats:" 5 1 "$SCHEDULE_MONTHDAY" 5 38 8 0 \
|
||||||
choose_month || continue; SCHEDULE_START_MONTH="$MONTH_RESULT"
|
"Uhrzeit (HH:MM):" 7 1 "$SCHEDULE_TIME" 7 38 8 0 \
|
||||||
choose_monthday || continue; choose_time || continue
|
3>&1 1>&2 2>&3 </dev/tty)" || return
|
||||||
|
mapfile -t vals <<<"$result"
|
||||||
|
SCHEDULE_INTERVAL_MONTHS="${vals[0]:-}"; SCHEDULE_START_MONTH="${vals[1]:-}"
|
||||||
|
SCHEDULE_MONTHDAY="${vals[2]:-}"; SCHEDULE_TIME="${vals[3]:-}"
|
||||||
;;
|
;;
|
||||||
yearly)
|
yearly)
|
||||||
choose_month || continue; SCHEDULE_YEAR_MONTH="$MONTH_RESULT"
|
result="$(whiptail --title "Zeitplan - Jaehrlich" --ok-button "Pruefen" --cancel-button "Zurueck" \
|
||||||
choose_monthday || continue; SCHEDULE_YEAR_DAY="$SCHEDULE_MONTHDAY"
|
--form "Jaehrlicher automatischer Lauf. Monat 1-12, Tag 1-28." 17 88 6 \
|
||||||
choose_time || continue
|
"Monat:" 1 1 "$SCHEDULE_YEAR_MONTH" 1 38 8 0 \
|
||||||
|
"Tag:" 3 1 "$SCHEDULE_YEAR_DAY" 3 38 8 0 \
|
||||||
|
"Uhrzeit (HH:MM):" 5 1 "$SCHEDULE_TIME" 5 38 8 0 \
|
||||||
|
3>&1 1>&2 2>&3 </dev/tty)" || return
|
||||||
|
mapfile -t vals <<<"$result"
|
||||||
|
SCHEDULE_YEAR_MONTH="${vals[0]:-}"; SCHEDULE_YEAR_DAY="${vals[1]:-}"; SCHEDULE_TIME="${vals[2]:-}"
|
||||||
;;
|
;;
|
||||||
custom)
|
custom)
|
||||||
x="$(wt_input "Zeitplan" "systemd OnCalendar-Ausdruck" "$ONCALENDAR")" || continue
|
result="$(wt_input "Eigener Zeitplan" "systemd OnCalendar-Ausdruck:" "$ONCALENDAR")" || return
|
||||||
if command -v systemd-analyze >/dev/null 2>&1 && ! systemd-analyze calendar "$x" >/dev/null 2>&1; then
|
ONCALENDAR="$result"
|
||||||
wt_msg "Fehler" "Dieser systemd-Zeitplan ist ungueltig."
|
|
||||||
continue
|
|
||||||
fi
|
|
||||||
ONCALENDAR="$x"
|
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
|
# Validate all input in one place.
|
||||||
|
if [[ "$choice" != custom && ! "$SCHEDULE_TIME" =~ ^([01][0-9]|2[0-3]):[0-5][0-9]$ ]]; then
|
||||||
|
wt_msg "Ungueltige Uhrzeit" "Bitte HH:MM verwenden, z. B. 04:00."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ "$choice" == weekly && ! "$SCHEDULE_WEEKDAY" =~ ^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)$ ]]; then
|
||||||
|
wt_msg "Ungueltiger Wochentag" "Erlaubt: Mon Tue Wed Thu Fri Sat Sun"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ "$choice" =~ ^(monthly|interval)$ && ! "$SCHEDULE_MONTHDAY" =~ ^([1-9]|1[0-9]|2[0-8])$ ]]; then
|
||||||
|
wt_msg "Ungueltiger Tag" "Bitte einen Tag von 1 bis 28 verwenden."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
if [[ "$choice" == interval ]]; then
|
||||||
|
[[ "$SCHEDULE_INTERVAL_MONTHS" =~ ^([2-9]|1[0-2])$ ]] || { wt_msg "Ungueltiges Intervall" "Bitte 2 bis 12 Monate verwenden."; return; }
|
||||||
|
[[ "$SCHEDULE_START_MONTH" =~ ^([1-9]|1[0-2])$ ]] || { wt_msg "Ungueltiger Monat" "Bitte 1 bis 12 verwenden."; return; }
|
||||||
|
fi
|
||||||
|
if [[ "$choice" == yearly ]]; then
|
||||||
|
[[ "$SCHEDULE_YEAR_MONTH" =~ ^([1-9]|1[0-2])$ ]] || { wt_msg "Ungueltiger Monat" "Bitte 1 bis 12 verwenden."; return; }
|
||||||
|
[[ "$SCHEDULE_YEAR_DAY" =~ ^([1-9]|1[0-9]|2[0-8])$ ]] || { wt_msg "Ungueltiger Tag" "Bitte 1 bis 28 verwenden."; return; }
|
||||||
|
fi
|
||||||
|
|
||||||
|
build_calendar
|
||||||
|
if command -v systemd-analyze >/dev/null 2>&1 && ! systemd-analyze calendar "$ONCALENDAR" >/dev/null 2>&1; then
|
||||||
|
wt_msg "Ungueltiger Zeitplan" "systemd akzeptiert diesen Zeitplan nicht:
|
||||||
|
|
||||||
|
$ONCALENDAR"
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
|
||||||
set +e
|
set +e
|
||||||
review_schedule
|
review_schedule
|
||||||
rc=$?
|
rc=$?
|
||||||
set -e
|
set -e
|
||||||
case "$rc" in
|
[[ "$rc" -eq 0 ]] || return
|
||||||
0) return ;;
|
|
||||||
1) return ;;
|
|
||||||
2) continue ;;
|
|
||||||
esac
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
|
|
||||||
exclusions_menu() {
|
exclusions_menu() {
|
||||||
@@ -543,42 +599,68 @@ Markierte Gaeste werden NICHT automatisch aktualisiert." \
|
|||||||
}
|
}
|
||||||
|
|
||||||
notifications_menu() {
|
notifications_menu() {
|
||||||
local choice json
|
local json result name state
|
||||||
choice="$(wt_menu "Benachrichtigungen" "Proxmox-Benachrichtigung nach jedem Lauf" \
|
local -a args=()
|
||||||
yes "Aktivieren" no "Deaktivieren" BACK "Zurueck")" || return
|
|
||||||
[[ "$choice" == BACK ]] && return
|
args+=("OFF" "Benachrichtigungen deaktivieren" "$([[ "$NOTIFY_ENABLED" == no ]] && echo ON || echo OFF)")
|
||||||
NOTIFY_ENABLED="$choice"
|
|
||||||
[[ "$choice" == no ]] && { NOTIFY_TARGET=""; return; }
|
|
||||||
|
|
||||||
json="$(pvesh get /cluster/notifications/targets --output-format json 2>/dev/null || true)"
|
json="$(pvesh get /cluster/notifications/targets --output-format json 2>/dev/null || true)"
|
||||||
local -a args=()
|
|
||||||
if [[ -n "$json" ]]; then
|
if [[ -n "$json" ]]; then
|
||||||
while IFS= read -r choice; do
|
while IFS= read -r name; do
|
||||||
[[ -n "$choice" ]] && args+=("$choice" "Notification-Target")
|
[[ -z "$name" ]] && continue
|
||||||
|
state=OFF
|
||||||
|
[[ "$NOTIFY_ENABLED" == yes && "$NOTIFY_TARGET" == "$name" ]] && state=ON
|
||||||
|
args+=("$name" "Proxmox Notification Target" "$state")
|
||||||
done < <(TARGETS="$json" python3 - <<'PY'
|
done < <(TARGETS="$json" python3 - <<'PY'
|
||||||
import json,os
|
import json, os
|
||||||
try:
|
try:
|
||||||
for x in json.loads(os.environ["TARGETS"]):
|
for x in json.loads(os.environ["TARGETS"]):
|
||||||
if x.get("name"): print(x["name"])
|
n=x.get("name")
|
||||||
except: pass
|
if n: print(n)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
PY
|
PY
|
||||||
)
|
)
|
||||||
fi
|
fi
|
||||||
(( ${#args[@]} > 0 )) || { NOTIFY_ENABLED="no"; wt_msg "Benachrichtigungen" "Keine Notification-Targets gefunden."; return; }
|
|
||||||
args+=(BACK "Zurueck")
|
result="$(whiptail --title "Benachrichtigungen" \
|
||||||
choice="$(wt_menu "Benachrichtigungen" "Target auswaehlen" "${args[@]}")" || return
|
--ok-button "Uebernehmen" --cancel-button "Zurueck" \
|
||||||
[[ "$choice" == BACK ]] && return
|
--radiolist "Eine Einstellung auswaehlen.
|
||||||
NOTIFY_TARGET="$choice"
|
|
||||||
|
Mit LEERTASTE markieren, danach Uebernehmen." \
|
||||||
|
20 88 10 "${args[@]}" 3>&1 1>&2 2>&3 </dev/tty)" || return
|
||||||
|
|
||||||
|
if [[ "$result" == OFF ]]; then
|
||||||
|
NOTIFY_ENABLED=no
|
||||||
|
NOTIFY_TARGET=""
|
||||||
|
else
|
||||||
|
NOTIFY_ENABLED=yes
|
||||||
|
NOTIFY_TARGET="$result"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
advanced_menu() {
|
advanced_menu() {
|
||||||
local x
|
local result a b c
|
||||||
x="$(wt_input "Erweitert" "APT-Lock-Wartezeit in Sekunden" "$APT_LOCK_TIMEOUT")" || return
|
result="$(whiptail --title "Erweiterte Wartezeiten" \
|
||||||
[[ "$x" =~ ^[0-9]+$ ]] && APT_LOCK_TIMEOUT="$x"
|
--ok-button "Uebernehmen" --cancel-button "Zurueck" \
|
||||||
x="$(wt_input "Erweitert" "Maximale Wartezeit auf laufendes Proxmox-Backup in Sekunden" "$BACKUP_WAIT_TIMEOUT")" || return
|
--form "Normalerweise muessen diese Werte nicht geaendert werden.
|
||||||
[[ "$x" =~ ^[0-9]+$ ]] && BACKUP_WAIT_TIMEOUT="$x"
|
|
||||||
x="$(wt_input "Erweitert" "Pruefintervall fuer laufendes Backup in Sekunden" "$BACKUP_WAIT_INTERVAL")" || return
|
Alle Angaben in Sekunden." \
|
||||||
[[ "$x" =~ ^[0-9]+$ ]] && BACKUP_WAIT_INTERVAL="$x"
|
20 92 8 \
|
||||||
|
"APT-Lock warten:" 1 1 "$APT_LOCK_TIMEOUT" 1 42 12 0 \
|
||||||
|
"Max. auf Backup warten:" 3 1 "$BACKUP_WAIT_TIMEOUT" 3 42 12 0 \
|
||||||
|
"Backup-Pruefintervall:" 5 1 "$BACKUP_WAIT_INTERVAL" 5 42 12 0 \
|
||||||
|
3>&1 1>&2 2>&3 </dev/tty)" || return
|
||||||
|
|
||||||
|
mapfile -t vals <<<"$result"
|
||||||
|
a="${vals[0]:-}"; b="${vals[1]:-}"; c="${vals[2]:-}"
|
||||||
|
if [[ ! "$a" =~ ^[0-9]+$ || ! "$b" =~ ^[0-9]+$ || ! "$c" =~ ^[0-9]+$ ]]; then
|
||||||
|
wt_msg "Ungueltige Eingabe" "Bitte nur ganze Zahlen in Sekunden eingeben."
|
||||||
|
return
|
||||||
|
fi
|
||||||
|
APT_LOCK_TIMEOUT="$a"
|
||||||
|
BACKUP_WAIT_TIMEOUT="$b"
|
||||||
|
BACKUP_WAIT_INTERVAL="$c"
|
||||||
}
|
}
|
||||||
|
|
||||||
write_units() {
|
write_units() {
|
||||||
@@ -728,21 +810,22 @@ settings_menu() {
|
|||||||
|
|
||||||
$(settings_summary)
|
$(settings_summary)
|
||||||
|
|
||||||
WEITERE EINSTELLUNGEN
|
Benachrichtigungen $(yn "$NOTIFY_ENABLED")${NOTIFY_TARGET:+ ($NOTIFY_TARGET)}
|
||||||
Benachrichtigungen: $(yn "$NOTIFY_ENABLED") ${NOTIFY_TARGET:+($NOTIFY_TARGET)}
|
Gast-Ausschluesse ${EXCLUDE_GUESTS:-keine}
|
||||||
Gast-Ausschluesse: ${EXCLUDE_GUESTS:-keine}
|
Automatischer Zeitplan $(schedule_desc)
|
||||||
Zeitplan: $(schedule_desc)
|
|
||||||
|
|
||||||
Hinweis:
|
------------------------------------------------------------
|
||||||
Die fuenf Ja/Nein-Optionen werden gemeinsam in EINEM Fenster geaendert.
|
AUSWAHL
|
||||||
Dort mit Leertaste umschalten und erst am Ende uebernehmen." \
|
------------------------------------------------------------
|
||||||
"1" "Update-Optionen (Ja / Nein)" \
|
Die Ja/Nein-Schalter werden gemeinsam bearbeitet.
|
||||||
"2" "Benachrichtigungen" \
|
Innerhalb einer Auswahl wird nicht bei jeder Aenderung neu geladen." \
|
||||||
"3" "Gast-Ausschluesse" \
|
"1" "Update-Optionen | alle Ja/Nein-Schalter gemeinsam" \
|
||||||
"4" "Automatischer Zeitplan" \
|
"2" "Benachrichtigungen | ein-/ausschalten und Target waehlen" \
|
||||||
"5" "Erweiterte Wartezeiten" \
|
"3" "Gast-Ausschluesse | LXC/VM per Leertaste markieren" \
|
||||||
"6" "Speichern & anwenden" \
|
"4" "Automatischer Zeitplan | Rhythmus und Uhrzeit festlegen" \
|
||||||
"7" "Zurueck")" || return
|
"5" "Erweiterte Wartezeiten | APT- und Backup-Schutz" \
|
||||||
|
"6" "Speichern & anwenden | Konfiguration aktivieren" \
|
||||||
|
"7" "Zurueck | ohne Speichern zurueck")" || return
|
||||||
|
|
||||||
case "$choice" in
|
case "$choice" in
|
||||||
1) basic_options_menu ;;
|
1) basic_options_menu ;;
|
||||||
@@ -756,7 +839,6 @@ Dort mit Leertaste umschalten und erst am Ende uebernehmen." \
|
|||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
show_status() {
|
show_status() {
|
||||||
wt_msg "Status" "Installation: $INSTALLED
|
wt_msg "Status" "Installation: $INSTALLED
|
||||||
Host: $(hostname)
|
Host: $(hostname)
|
||||||
|
|||||||
Reference in new issue
Block a user