Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
awit-dbackup
awit-dbackup
Commits
90b994b8
Commit
90b994b8
authored
Jul 11, 2014
by
Nigel Kukard
Browse files
Make sure the config file is not mandatory
parent
c08178a6
Changes
1
Hide whitespace changes
Inline
Side-by-side
dbackup
View file @
90b994b8
...
...
@@ -156,16 +156,6 @@ 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
");
...
...
@@ -183,21 +173,33 @@ if (! -d $ARGV[1]) {
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
};
# If backup file is specified and it does not exist, throw an error
if
(
defined
(
$optctl
{'
config
'})
&&
!
-
f
$optctl
{'
config
'})
{
print
(
STDERR
"
ERROR: Configuration file '
"
.
$optctl
{'
config
'}
.
"
' NOT found!
\n
");
exit
1
;
}
# Check config file was specified, if not set default
my
$configFile
;
if
(
!
defined
(
$configFile
=
$optctl
{'
config
'}))
{
$configFile
=
"
/etc/dbackup.conf
";
}
# If we have a config file, read it in
if
(
-
f
$configFile
)
{
# 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
};
}
}
}
#
# Process config
#
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment