miyagi-backup.sh aktualisiert
add WOL on Interfaces
This commit is contained in:
@@ -39,6 +39,48 @@ if [[ -n "${CONFIG_FILE:-}" ]]; then
|
||||
fi
|
||||
|
||||
# Funktionen
|
||||
set_wol_g_enabled() {
|
||||
log "Prüfe, ob ethtool installiert ist..."
|
||||
|
||||
if ! command -v ethtool >/dev/null 2>&1; then
|
||||
log "ethtool ist nicht installiert – versuche Installation..."
|
||||
apt update && apt install -y ethtool || {
|
||||
log "Fehler: ethtool konnte nicht installiert werden."
|
||||
return 1
|
||||
}
|
||||
else
|
||||
log "ethtool ist bereits installiert."
|
||||
fi
|
||||
|
||||
log "Pruefe und setze Wake-on-LAN (WOL) auf 'g' nur bei Interfaces mit statischer IP..."
|
||||
|
||||
for iface in $(ls /sys/class/net | grep -vE '^(lo|tap|vmbr|veth|br|docker|bond|wl)'); do
|
||||
if [[ -e "/sys/class/net/$iface/device" ]]; then
|
||||
log "Bearbeite physisches Interface: $iface"
|
||||
|
||||
# Aktuellen WOL-Status pruefen
|
||||
current_wol=$(ethtool "$iface" 2>/dev/null | awk '/Wake-on:/ {print $2}')
|
||||
if [[ "$current_wol" != "g" ]]; then
|
||||
log "Setze WOL auf 'g' fuer $iface..."
|
||||
ethtool -s "$iface" wol g || log "Fehler beim Setzen von WOL auf $iface"
|
||||
else
|
||||
log "WOL ist bereits korrekt auf 'g' fuer $iface"
|
||||
fi
|
||||
|
||||
# Pruefen, ob ein 'iface $iface inet static' Eintrag existiert
|
||||
if grep -qE "^\s*iface\s+$iface\s+inet\s+static" /etc/network/interfaces; then
|
||||
if ! grep -A 5 -E "^\s*iface\s+$iface\s+inet\s+static" /etc/network/interfaces | grep -q "post-up ethtool -s $iface wol g"; then
|
||||
log "Ergaenze WOL-Befehl im statischen Block fuer $iface..."
|
||||
sed -i "/^\s*iface\s\+$iface\s\+inet\s\+static/a \ post-up ethtool -s $iface wol g" /etc/network/interfaces
|
||||
else
|
||||
log "WOL-Befehl fuer $iface ist bereits im statischen Block vorhanden."
|
||||
fi
|
||||
else
|
||||
log "Kein statischer Eintrag fuer $iface gefunden, keine Aenderung vorgenommen."
|
||||
fi
|
||||
fi
|
||||
done
|
||||
}
|
||||
|
||||
write_zsync_config() {
|
||||
local conf_file="/etc/bashclub/$SOURCEHOST.conf"
|
||||
@@ -201,6 +243,7 @@ main() {
|
||||
|
||||
SOURCEHOSTNAME=$(ssh "$SOURCEHOST" hostname)
|
||||
|
||||
set_wol_g_enabled
|
||||
write_zsync_config
|
||||
run_zsync
|
||||
run_maintenance
|
||||
|
||||
Reference in New Issue
Block a user