]> git.proxmox.com Git - pmg-api.git/commitdiff
pmg7to8: notify about unmodified templates
authorStoiko Ivanov <s.ivanov@proxmox.com>
Fri, 7 Jul 2023 16:54:26 +0000 (18:54 +0200)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Tue, 11 Jul 2023 15:50:53 +0000 (17:50 +0200)
I considered making this a warning, but since unmodified files get
updated to the new versions in /var/lib/pmg/templates by ucf a notice
seems more appropriate.

Signed-off-by: Stoiko Ivanov <s.ivanov@proxmox.com>
 [T: merge in helper method for getting the unmodified templates ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
src/PMG/CLI/pmg7to8.pm

index ea29056d549ee54a6b05941dda3205bc9b4f8774..85e9f16dc81b065004d30627e06f9fd7d9a4558c 100644 (file)
@@ -552,6 +552,24 @@ sub check_misc {
 
     check_apt_repos();
     check_bootloader();
+
+    my ($template_dir, $base_dir) = ('/etc/pmg/templates/', '/var/lib/pmg/templates');
+    my @override_but_unmodified = ();
+    PVE::Tools::dir_glob_foreach($base_dir, '.*\.(?:tt|in).*', sub {
+       my ($filename) = @_;
+       return if !-e "$template_dir/$filename";
+
+       my $shipped = PVE::Tools::file_get_contents("$base_dir/$filename", 1024*1024);
+       my $override = PVE::Tools::file_get_contents("$template_dir/$filename", 1024*1024);
+
+       push @override_but_unmodified, $filename if $shipped eq $override;
+    });
+    if (scalar(@override_but_unmodified)) {
+       my $msg = "Found overrides in '/etc/pmg/templates/' for template, but without modification."
+           ." Consider simply removing them: \n    "
+           . join("\n    ", @override_but_unmodified);
+       log_notice($msg);
+    }
 }
 
 my sub colored_if {