core89: Update OpenVPN configuration during the update
authorAlexander Marx <alexander.marx@ipfire.org>
Fri, 10 Apr 2015 11:16:33 +0000 (13:16 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 10 Apr 2015 11:16:33 +0000 (13:16 +0200)
config/rootfiles/common/stage2
config/rootfiles/core/89/filelists/files
config/rootfiles/core/89/update.sh
src/scripts/ovpn-collectd-convert [new file with mode: 0644]

index 44f24b4..f506daf 100644 (file)
@@ -124,6 +124,7 @@ usr/local/bin/update-lang-cache
 #usr/local/src
 #usr/sbin
 usr/sbin/ovpn-ccd-convert
+usr/sbin/ovpn-collectd-convert
 #usr/share
 #usr/share/doc
 #usr/share/doc/licenses
index 2be73d7..70c5f3d 100644 (file)
@@ -13,6 +13,7 @@ srv/web/ipfire/cgi-bin/ovpnmain.cgi
 srv/web/ipfire/cgi-bin/vpnmain.cgi
 usr/local/bin/collectdctrl
 usr/local/bin/openvpnctrl
+usr/sbin/ovpn-collectd-convert
 usr/sbin/setup
 var/ipfire/backup/bin/backup.pl
 var/ipfire/graphs.pl
index bc80709..e15f937 100644 (file)
@@ -66,6 +66,9 @@ rm -f \
        /opt/pakfire/db/*/meta-sqlite \
        /opt/pakfire/db/rootfiles/sqlite
 
+# Update OpenVPN/collectd configuration
+/usr/sbin/ovpn-collectd-convert
+
 # Fix #10625
 mkdir -p /etc/logrotate.d
 
diff --git a/src/scripts/ovpn-collectd-convert b/src/scripts/ovpn-collectd-convert
new file mode 100644 (file)
index 0000000..59d67b9
--- /dev/null
@@ -0,0 +1,26 @@
+#!/usr/bin/perl
+# Converter script for adding existing OpenVPN N2N connections to collectd
+# Used for core update 89
+
+my %ovpnconfig=();
+
+require '/var/ipfire/general-functions.pl';
+
+open(COLLECTDVPN, ">${General::swroot}/ovpn/collectd.vpn") or die "Unable to open collectd.vpn: $!";
+print COLLECTDVPN "Loadplugin openvpn\n";
+print COLLECTDVPN "\n";
+print COLLECTDVPN "<Plugin openvpn>\n";
+print COLLECTDVPN "Statusfile \"/var/run/ovpnserver.log\"\n";
+
+&General::readhasharray("/var/ipfire/ovpn/ovpnconfig", \%ovpnconfig);
+foreach my $key (keys %ovpnconfig) {
+       if ($ovpnconfig{$key}[0] eq 'on' && $ovpnconfig{$key}[3] eq 'net') {
+               print COLLECTDVPN "Statusfile \"/var/run/openvpn/$ovpnconfig{$key}[1]-n2n\"\n";
+       }
+}
+
+print COLLECTDVPN "</Plugin>\n";
+close(COLLECTDVPN);
+
+# Reload collectd afterwards
+system("/usr/local/bin/collectdctrl restart &>/dev/null");