Files
patrickandClaude Sonnet 5.5 15676a3600
test / pytest (3.11) (push) Canceled after 0s
test / pytest (3.13) (push) Canceled after 0s
feat: Preflight-Checks und VM-Tauglichkeit des Setups
deploy/lib/preflight.sh prüft Python, venv, Platz, Betriebssystem, Umgebung
(VM/Container), pypi und optional Checkmk/Ollama per TCP. first-run.sh und
setup-lxc.sh rufen ihn auf (--skip-preflight, --preflight-only). LXC-Teile
nur bei erkanntem Container; Texte neutral; README um VM-Abschnitt ergänzt.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
2026-11-06 15:09:53 +01:00

47 lines
1.6 KiB
Bash

#!/usr/bin/env bash
# Systemzeitzone setzen (wird von setup-lxc.sh gesourced). Setzt common.sh voraus.
ZONEINFO_DIR=/usr/share/zoneinfo
TZ_RE='^[A-Za-z0-9_+-]+(/[A-Za-z0-9_+-]+)*$'
LOCALTIME_FILE=/etc/localtime
TIMEZONE_FILE=/etc/timezone
validate_timezone_name() {
[[ $1 =~ $TZ_RE ]] || die "Ungültiger Zeitzonenname: '$1' (Beispiel: Europe/Berlin)"
}
current_timezone() {
local tz="" target=""
if command -v timedatectl >/dev/null 2>&1; then
tz=$(timedatectl show -p Timezone --value 2>/dev/null) || tz=""
fi
if [[ -z $tz || $tz == n/a ]]; then
target=$(readlink -f "$LOCALTIME_FILE" 2>/dev/null) || target=""
tz=${target#"$ZONEINFO_DIR"/}
[[ $tz != "$target" ]] || tz=""
fi
printf '%s' "$tz"
}
set_timezone_files() {
ln -sfn "$ZONEINFO_DIR/$1" "$LOCALTIME_FILE" && printf '%s\n' "$1" > "$TIMEZONE_FILE"
}
# In Containern fehlt oft ein nutzbares timedatectl (kein D-Bus); dann Dateien direkt schreiben, sonst nur warnen.
ensure_timezone() {
local tz=$1
[[ -f $ZONEINFO_DIR/$tz ]] || die "Zeitzone '$tz' fehlt in $ZONEINFO_DIR (Paket tzdata?)."
if [[ $(current_timezone) == "$tz" ]]; then
log "Zeitzone ist bereits $tz."
return 0
fi
if command -v timedatectl >/dev/null 2>&1 && timedatectl set-timezone "$tz" >/dev/null 2>&1; then
log "Zeitzone auf $tz gesetzt."
elif set_timezone_files "$tz" 2>/dev/null; then
log "Zeitzone auf $tz gesetzt (über $LOCALTIME_FILE)."
else
warn "Zeitzone konnte nicht auf $tz gesetzt werden (Container ohne Schreibrecht?). Zeitzone manuell einstellen (Host- bzw. Container-Konfiguration)."
fi
return 0
}