From: Marius Gavrilescu Date: Thu, 24 Mar 2016 13:16:48 +0000 (+0200) Subject: Support configuration via the environment X-Git-Tag: 1.000~3 X-Git-Url: http://git.ieval.ro/?a=commitdiff_plain;h=01dcdb6958f188e5aa30f44f06989e4f0cac8e41;p=app-statsbot.git Support configuration via the environment --- diff --git a/lib/App/Statsbot.pm b/lib/App/Statsbot.pm index 902f9d3..fcc7959 100644 --- a/lib/App/Statsbot.pm +++ b/lib/App/Statsbot.pm @@ -31,6 +31,15 @@ our $SSL = ''; our @CHANNELS; our $DB = '/var/lib/statsbot/db'; +{ + my %cfg = (debug => \$DEBUG, tick => \$TICK, nickname => \$NICKNAME, server => \$SERVER, port => \$PORT, ssl => \$SSL, channels => \@CHANNELS, db => \$DB); + for my $var (keys %cfg) { + my $key = "STATSBOT_\U$var"; + ${$cfg{$var}} = $ENV{$key} if exists $ENV{$key} && ref $cfg{$var} eq 'SCALAR'; + @{$cfg{$var}} = split ' ', $ENV{$key} if exists $ENV{$key} && ref $cfg{$var} eq 'ARRAY'; + } +} + my $dbh; my $insert; my $update; @@ -198,6 +207,11 @@ a channel. It is able to answer queries of the form "In the last