[2/2] backup.pl: Update the RW entry in collectd.vpn if restoring old backup

Message ID 20250908125938.3389609-2-adolf.belka@ipfire.org
State New
Headers
Series [1/2] update.sh: Update collectd.vpn to the new RW log file name |

Commit Message

Adolf Belka 8 Sep 2025, 12:59 p.m. UTC
Signed-off-by: Adolf Belka <adolf.belka@ipfire.org>
---
 config/backup/backup.pl | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
  

Patch

diff --git a/config/backup/backup.pl b/config/backup/backup.pl
index e79f510c6..8988427ea 100644
--- a/config/backup/backup.pl
+++ b/config/backup/backup.pl
@@ -349,8 +349,12 @@  restore_backup() {
 		rm /var/log/pakfire.log
 	fi
 
-	# Update the OpenVPN configuration and restart the openvpn daemons
+	# Update the OpenVPN configuration, update the RW log entry in collectd.vpn
+	# if it is the old name and restart the openvpn daemons
 	sudo -u nobody /srv/web/ipfire/cgi-bin/ovpnmain.cgi
+	if grep -q "/var/run/ovpnserver.log" /var/ipfire/ovpn/collectd.vpn; then
+		sed -i 's|"/var/run/ovpnserver.log"|"/var/run/openvpn-rw.log"|' /var/ipfire/ovpn/collectd.vpn
+	fi
 	/etc/init.d/openvpn-n2n restart
 	/etc/init.d/openvpn-rw restart