diff --git a/alexandrie b/alexandrie index 90950d8..d74c86c 100755 --- a/alexandrie +++ b/alexandrie @@ -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'); diff --git a/alexandrie.conf b/alexandrie.conf new file mode 100644 index 0000000..b1488a3 --- /dev/null +++ b/alexandrie.conf @@ -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 diff --git a/parse_known_sites b/parse_known_sites index 727451f..a05b326 100755 --- a/parse_known_sites +++ b/parse_known_sites @@ -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