Externalized configuration (#3855).

This commit is contained in:
Christian P. MOMON 2019-08-23 16:50:58 +02:00 committed by root
parent 77d20432d6
commit 2eed7a8c21
3 changed files with 39 additions and 12 deletions

View File

@ -5,20 +5,27 @@ use warnings;
use POE qw(Component::IRC);
use List::MoreUtils qw(any);
use DBI;
use Config::Simple;
my $parser = '/srv/alexandrie/parse_known_sites';
# CONFIGURATION FILE
my $alexandrieConf = new Config::Simple("/etc/alexandrie/alexandrie.conf") or die "Missing configuration file.";
print "Configuration file loaded.\n";
# PARSER
my $parser = $alexandrieConf->param("parser.path");
# DATABASE
my $dsn = 'DBI:mysql:drupal6:172.16.0.7';
my $db_user_name = 'drupal';
my $db_password = 'xxxxxxx';
my $dbh = 0;
my $dsn = $alexandrieConf->param("database.dsn");
my $db_user_name = $alexandrieConf->param("database.username");
my $db_password = $alexandrieConf->param("database.password");
my $dbh = $alexandrieConf->param("database.dbh");
# IRC
my $nickname = 'alexandrie';
my $ircname = 'Bibliothèque de l\'April';
my $server = 'irc.freenode.net';
my $username = 'alex';
my $nickname = $alexandrieConf->param("irc.nickname");
my $ircname = $alexandrieConf->param("irc.name");
my $server = $alexandrieConf->param("irc.server");
my $username = $alexandrieConf->param("irc.username");
my @channels = ('#april', '#april-alexandrie');
#my @channels = ('#april-alexandrie');

15
alexandrie.conf Normal file
View File

@ -0,0 +1,15 @@
[parser]
path=/srv/alexandrie/parse_known_sites
[database]
dsn=DBI:mysql:drupal6:172.16.0.7
username= drupal
password=xxxxxxxx
dbh = 0;
[irc]
nickname=alexandrie
name=Bibliothèque de l\'April
server=irc.freenode.net
username=alex
channels=#april,#april-alexandrie

View File

@ -9,11 +9,16 @@
use strict;
use LWP::Simple;
use DBI;
use Config::Simple;
my $dsn = 'DBI:mysql:drupal6:172.16.0.7';
my $db_user_name = 'drupal';
my $db_password = 'xxxxxxx';
# CONFIGURATION FILE
my $alexandrieConf = new Config::Simple("/etc/alexandrie/alexandrie.conf") or die "Missing configuration file.";
print "Configuration file loaded.\n";
# DATABASE
my $dsn = $alexandrieConf->param("database.dsn");
my $db_user_name = $alexandrieConf->param("database.username");
my $db_password = $alexandrieConf->param("database.password");
sub parse_page