aboutsummaryrefslogtreecommitdiffstats
path: root/lacme-accountd
diff options
context:
space:
mode:
Diffstat (limited to 'lacme-accountd')
-rwxr-xr-xlacme-accountd23
1 files changed, 13 insertions, 10 deletions
diff --git a/lacme-accountd b/lacme-accountd
index 1dc5f03..b9a6e33 100755
--- a/lacme-accountd
+++ b/lacme-accountd
@@ -69,16 +69,19 @@ do {
( ($ENV{XDG_CONFIG_HOME} // "$ENV{HOME}/.config") . "/lacme/$NAME.conf"
, "@@sysconfdir@@/lacme/$NAME.conf"
);
- die "Error: Can't find configuration file\n" unless defined $conffile;
- print STDERR "Using configuration file: $conffile\n" if $OPTS{debug};
-
- my $h = Config::Tiny::->read($conffile) or die Config::Tiny::->errstr()."\n";
- my $h2 = delete $h->{_} // {};
- die "Invalid section(s): ".join(', ', keys %$h)."\n" if %$h;
- my %h = map { $_ => delete $h2->{$_} } qw/privkey gpg socket quiet/;
- die "Unknown option(s): ".join(', ', keys %$h2)."\n" if %$h2;
- $h{quiet} = lc $h{quiet} eq 'yes' ? 1 : 0 if defined $h{quiet};
- $OPTS{$_} //= $h{$_} foreach grep {defined $h{$_}} keys %h;
+
+ if (defined $OPTS{config} or -e $conffile) {
+ print STDERR "Using configuration file: $conffile\n" if $OPTS{debug};
+ my $h = Config::Tiny::->read($conffile) or die Config::Tiny::->errstr()."\n";
+ my $h2 = delete $h->{_} // {};
+ die "Invalid section(s): ".join(', ', keys %$h)."\n" if %$h;
+ my %h = map { $_ => delete $h2->{$_} } qw/privkey gpg socket quiet/;
+ die "Unknown option(s): ".join(', ', keys %$h2)."\n" if %$h2;
+ $h{quiet} = lc $h{quiet} eq 'yes' ? 1 : 0 if defined $h{quiet};
+ $OPTS{$_} //= $h{$_} foreach grep {defined $h{$_}} keys %h;
+ } else {
+ print STDERR "Ignoring missing configuration file at default location $conffile\n" if $OPTS{debug};
+ }
$OPTS{quiet} = 0 if $OPTS{debug};
die "Error: 'privkey' is not specified\n" unless defined $OPTS{privkey};