versioning and compatibility check for default configuration file

This commit is contained in:
Christoph Klaffl 2017-11-08 22:08:02 +01:00
parent bc2f8bd4e9
commit 293d83bdaa
2 changed files with 14 additions and 0 deletions

12
sanoid
View File

@ -5,6 +5,7 @@
# project's Git repository at https://github.com/jimsalterjrs/sanoid/blob/master/LICENSE.
$::VERSION = '1.4.17';
my $MINIMUM_DEFAULTS_VERSION = 2;
use strict;
use warnings;
@ -568,6 +569,17 @@ sub init {
my @istrue=(1,"true","True","TRUE","yes","Yes","YES","on","On","ON");
my @isfalse=(0,"false","False","FALSE","no","No","NO","off","Off","OFF");
# check if default configuration file is up to date
my $defaults_version = 1;
if (defined $defaults{'version'}{'version'}) {
$defaults_version = $defaults{'version'}{'version'};
delete $defaults{'version'};
}
if ($defaults_version < $MINIMUM_DEFAULTS_VERSION) {
die "FATAL: you're using sanoid.defaults.conf v$defaults_version, this version of sanoid requires a minimum sanoid.defaults.conf v$MINIMUM_DEFAULTS_VERSION";
}
foreach my $section (keys %ini) {
# first up - die with honor if unknown parameters are set in any modules or templates by the user.

View File

@ -5,6 +5,8 @@
# #
# you have been warned. #
###################################################################################
[version]
version = 2
[template_default]