Commit eec6b0d0 authored by Nigel Kukard's avatar Nigel Kukard
Browse files

Use default config file /etc/dbackup.conf

parent 5e51cf40
......@@ -160,6 +160,16 @@ if (defined($optctl{'backup'}) && defined($optctl{'restore'})) {
exit 1;
}
# Check config file exists
if (!defined($optctl{'config'})) {
$optctl{'config'} = "/etc/dbackupc.conf";
}
if (! -f $optctl{'config'}) {
print(STDERR "ERROR: Configuration file '".$optctl{'config'}."' NOT found!\n");
exit 1;
}
# Make sure we only have 2 additional args
if (@ARGV > 2 || @ARGV < 2) {
print(STDERR "ERROR: Invalid number of arguments\n\n");
......@@ -177,25 +187,17 @@ if (! -d $ARGV[1]) {
exit 1;
}
# Check config file exists
if (defined($optctl{'config'})) {
if (! -f $optctl{'config'}) {
print(STDERR "ERROR: Configuration file '".$optctl{'config'}."' NOT found!\n");
exit 1;
}
# Use config file, ignore case
tie my %inifile, 'Config::IniFiles', (
-file => $optctl{'config'},
-nocase => 1
) or die "Failed to open config file '".$optctl{'config'}."': ".join("\n",@Config::IniFiles::errors);
# Check if we actually have something...
if (defined($inifile{'backup'})) {
# Loop with config items
foreach my $item (keys %{$inifile{'backup'}}) {
$config{$item} = $inifile{'backup'}{$item};
}
# Use config file, ignore case
tie my %inifile, 'Config::IniFiles', (
-file => $optctl{'config'},
-nocase => 1
) or die "Failed to open config file '".$optctl{'config'}."': ".join("\n",@Config::IniFiles::errors);
# Check if we actually have something...
if (defined($inifile{'backup'})) {
# Loop with config items
foreach my $item (keys %{$inifile{'backup'}}) {
$config{$item} = $inifile{'backup'}{$item};
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment