Rollback misconfigured network settings in systemd using etckeeper?
3
votes
0
answers
493
views
I was thinking how to automatically rollback network misconfigurations with etckeeper and systemd.
Workflow:
# etckeeper commit
# $EDITOR /etc/systemd/network/wired.network
# systemctl restart systemd-networkd
You broke the network! I'm calling your mom!
Here's your broken config:
$(cat broken_file)
$(etckeeper vcs reset -- old_config_file)
# $EDITOR /etc/systemd/network/wired.network
# systemctl restart systemd-networkd
#
Currently i'm stuck how to hook into restart event.
gdbus monitor --system --dest org.freedesktop --object-path /org/freedesktop
Doesn't output anything when running
# systemctl restart systemd-networkd
Script itself could be something like:
* hook into systemd
restart
and if possible, directly into restart systemd-networkd
* Read the hook information if it contains that restart failed, otherwise read systemctl is-active systemd-networkd
* Rename broken file to $file.broken
* Restore: etckeeper vcs reset -- $file
* systemctl stop automatic-net-configuration-rollback.service
(so that there's no infinite loop)
* systemctl restart systemd-networkd
* Works -> systemctl start automatic-net-configuration-rollback.service
* Doesn't -> echo Rollbacked config file doesn't work either. Repair manually and start automatic rollback after it works.
Is this possible and/or does systemd already have this kind of service built-in or has someone made one already? My google searches came up empty.
Asked by raspi
(1466 rep)
Nov 8, 2016, 01:28 PM