![使用 etckeeper 回滚 systemd 中配置错误的网络设置?](https://linux22.com/image/98232/%E4%BD%BF%E7%94%A8%20etckeeper%20%E5%9B%9E%E6%BB%9A%20systemd%20%E4%B8%AD%E9%85%8D%E7%BD%AE%E9%94%99%E8%AF%AF%E7%9A%84%E7%BD%91%E7%BB%9C%E8%AE%BE%E7%BD%AE%EF%BC%9F.png)
我正在考虑如何使用 etckeeper 和 systemd 自动回滚网络错误配置。
工作流程:
# 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
#
目前我陷入了如何挂钩重新启动事件的困境。
gdbus monitor --system --dest org.freedesktop --object-path /org/freedesktop
运行时不输出任何内容
# systemctl restart systemd-networkd
脚本本身可能是这样的:
- 挂钩到systemd
restart
,如果可能的话,直接挂钩到restart systemd-networkd
- 如果包含重启失败则读取钩子信息,否则读取
systemctl is-active systemd-networkd
- 将损坏的文件重命名为 $file.broken
- 恢复:
etckeeper vcs reset -- $file
systemctl stop automatic-net-configuration-rollback.service
(这样就不会出现无限循环)systemctl restart systemd-networkd
- 作品->
systemctl start automatic-net-configuration-rollback.service
- 没有->
echo Rollbacked config file doesn't work either. Repair manually and start automatic rollback after it works.
- 作品->
这是否可能和/或 systemd 是否已经内置了这种服务或者已经有人做了这样的服务?我的谷歌搜索结果是空的。