]> git.ipfire.org Git - people/stevee/ipfire-2.x.git/commitdiff
collectd: add more changes to the converter
authorArne Fitzenreiter <arne_f@ipfire.org>
Thu, 30 Jan 2025 09:23:10 +0000 (10:23 +0100)
committerArne Fitzenreiter <arne_f@ipfire.org>
Thu, 30 Jan 2025 09:23:10 +0000 (10:23 +0100)
Signed-off-by: Arne Fitzenreiter <arne_f@ipfire.org>
config/backup/backup.pl
config/rootfiles/core/192/update.sh

index 51797c780f3a7935cfaa53dd521633f5d645e491..c64d56aee7d532e642972295433a1955b04e0bfe 100644 (file)
@@ -263,15 +263,39 @@ restore_backup() {
                rm /var/lib/ipblocklist/SPAMHAUS_EDROP.conf
        fi
 
+       # The collectd directory structure was changed but not all changes
+       # are done by the official migration script generator
+       for i in $(seq 0 63);
+       do
+               if [ -e /var/log/rrd/collectd/localhost/cpufreq/cpufreq-$i.rrd ]; then
+                       mkdir -p /var/log/rrd/collectd/localhost/cpufreq-$i
+                       mv -f /var/log/rrd/collectd/localhost/cpufreq/cpufreq-$i.rrd \
+                               /var/log/rrd/collectd/localhost/cpufreq-$i/cpufreq.rrd
+               fi
+       done
+       if [ -e /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd ]; then
+               mv -f /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd \
+               /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature.rrd
+       fi
+
        # Create collectd 4.x to 5.x migration script from rrd contents, run the script that
        # was created and then remove the old interface directory if it is present as it will
        # be empty after the migration has been carried out.
        /var/ipfire/collectd-migrate-4-to-5.pl --indir /var/log/rrd/ > /tmp/rrd-migrate.sh
        sh /tmp/rrd-migrate.sh >/dev/null 2>&1
-       rm -rf \
-               /var/log/rrd/collectd/localhost/cpufreq \
-               /var/log/rrd/collectd/localhost/interface \
-               /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd
+
+       # Run old collectd cleanup only if the interface dir exist to prevent cleanup of
+       # new devices if the user have reenabled it and restore a backup
+       if [ -d /var/log/rrd/collectd/localhost/interface ]; then
+               rm -rf \
+                       /var/log/rrd/collectd/localhost/cpufreq \
+                       /var/log/rrd/collectd/localhost/disk-loop* \
+                       /var/log/rrd/collectd/localhost/disk-sg* \
+                       /var/log/rrd/collectd/localhost/disk-sr* \
+                       /var/log/rrd/collectd/localhost/disk-ram* \
+                       /var/log/rrd/collectd/localhost/interface \
+                       /var/log/rrd/collectd/localhost/thermal-cooling_device*
+       fi
 
        # start collectd after restore
        /etc/rc.d/init.d/collectd start
index 03bfc0bd6ee374c0bda8ae49f73816e73d519a0d..858c27d2fb0b8178081e38732656efe2c7664c35 100644 (file)
@@ -109,12 +109,28 @@ ldconfig
 # Create collectd 4.x to 5.x migration script from rrd contents, run the script that
 # was created and then remove the old interface directory if it is present as it will
 # be empty after the migration has been carried out.
+for i in $(seq 0 63);
+do
+       if [ -e /var/log/rrd/collectd/localhost/cpufreq/cpufreq-$i.rrd ]; then
+               mkdir -p /var/log/rrd/collectd/localhost/cpufreq-$i
+               mv -f /var/log/rrd/collectd/localhost/cpufreq/cpufreq-$i.rrd \
+                       /var/log/rrd/collectd/localhost/cpufreq-$i/cpufreq.rrd
+       fi
+done
+if [ -e /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd ]; then
+       mv -f /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd \
+               /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature.rrd
+fi
 /var/ipfire/collectd-migrate-4-to-5.pl --indir /var/log/rrd/ > /tmp/rrd-migrate.sh
 sh /tmp/rrd-migrate.sh >/dev/null 2>&1
 rm -rvf \
        /var/log/rrd/collectd/localhost/cpufreq \
+       /var/log/rrd/collectd/localhost/disk-loop* \
+       /var/log/rrd/collectd/localhost/disk-sg* \
+       /var/log/rrd/collectd/localhost/disk-sr* \
+       /var/log/rrd/collectd/localhost/disk-ram* \
        /var/log/rrd/collectd/localhost/interface \
-       /var/log/rrd/collectd/localhost/thermal-thermal_zone*/temperature-temperature.rrd
+       /var/log/rrd/collectd/localhost/thermal-cooling_device*
 
 # Start services
 /etc/init.d/collectd start