[vhffs-dev] [2150] nss and mydns mirrors benefit of the DSN feature as well

[ Thread Index | Date Index | More vhffs.org/vhffs-dev Archives ]


Revision: 2150
Author:   gradator
Date:     2012-04-16 00:57:52 +0200 (Mon, 16 Apr 2012)
Log Message:
-----------
nss and mydns mirrors benefit of the DSN feature as well

Modified Paths:
--------------
    trunk/vhffs-backend/src/mirror/mydns-mirror.pl
    trunk/vhffs-backend/src/mirror/nss-mirror.pl

Modified: trunk/vhffs-backend/src/mirror/mydns-mirror.pl
===================================================================
--- trunk/vhffs-backend/src/mirror/mydns-mirror.pl	2012-04-15 22:32:46 UTC (rev 2149)
+++ trunk/vhffs-backend/src/mirror/mydns-mirror.pl	2012-04-15 22:57:52 UTC (rev 2150)
@@ -39,27 +39,23 @@
 use utf8;
 
 # Master DB params
-my $MASTER_DB_HOST = 'localhost';
-my $MASTER_DB_PORT = 5432;
-my $MASTER_DB_NAME = 'vhffs';
+my $MASTER_DB_DATASOURCE = 'database=vhffs;host=localhost;port=5432';
 my $MASTER_DB_USER = 'vhffs';
 my $MASTER_DB_PASS = 'vhffs';
 
 # Slave DB params
-my $SLAVE_DB_HOST = 'localhost';
-my $SLAVE_DB_PORT = 5432;
-my $SLAVE_DB_NAME = 'dns';
-my $SLAVE_DB_USER = 'mydns';
-my $SLAVE_DB_PASS = 'mydns';
+my $SLAVE_DB_DATASOURCE = 'database=dns;host=localhost;port=5432';
+my $SLAVE_DB_USER = 'dns';
+my $SLAVE_DB_PASS = 'dns';
 
 # We've to connect to the master DB, fetch soa & rr
 # tables and reinject them in slave DB
 
-my $master_dbh = DBI->connect("DBI:Pg:dbname=$MASTER_DB_NAME;host=$MASTER_DB_HOST;port=$MASTER_DB_PORT", $MASTER_DB_USER, $MASTER_DB_PASS)
-    or die("Unable to open master connection\n");
+my $master_dbh = DBI->connect('DBI:Pg:'.$MASTER_DB_DATASOURCE, $MASTER_DB_USER, $MASTER_DB_PASS)
+	or die('Unable to open master connection'."\n");
 
-my $slave_dbh = DBI->connect("DBI:Pg:dbname=$SLAVE_DB_NAME;host=$SLAVE_DB_HOST;port=$SLAVE_DB_PORT", $SLAVE_DB_USER, $SLAVE_DB_PASS)
-    or die("Unable to open slave connection\n");
+my $slave_dbh = DBI->connect('DBI:Pg:'.$SLAVE_DB_DATASOURCE, $SLAVE_DB_USER, $SLAVE_DB_PASS)
+	or die('Unable to open slave connection'."\n");
 
 # Create temporary tables
 # mirror table containing SOA must be named vhffs_dns_soa

Modified: trunk/vhffs-backend/src/mirror/nss-mirror.pl
===================================================================
--- trunk/vhffs-backend/src/mirror/nss-mirror.pl	2012-04-15 22:32:46 UTC (rev 2149)
+++ trunk/vhffs-backend/src/mirror/nss-mirror.pl	2012-04-15 22:57:52 UTC (rev 2150)
@@ -36,12 +36,10 @@
 use strict;
 use utf8;
 
-# TODO Set us!
-my $PG_DB_HOST = 'localhost';           # Host running pg
-my $PG_DB_PORT = 5432;                  # Port on which pg is listening
-my $PG_DB_NAME = 'vhffs';               # VHFFS' database name
-my $PG_DB_USER = 'vhffs';               # VHFFS' database user
-my $PG_DB_PASS = 'vhffs';               # VHFFS' database password
+# Master DB params
+my $PG_DB_DATASOURCE = 'database=vhffs;host=localhost;port=5432';
+my $PG_DB_USER = 'vhffs';
+my $PG_DB_PASS = 'vhffs';
 
 my $ST_PW_DB = '/var/db/passwd.sqlite'; # SQLite users database
 my $ST_SP_DB = '/var/db/shadow.sqlite'; # SQLite shadow database
@@ -81,7 +79,7 @@
 }
 
 # Let's open pg connection
-my $pg_dbh = DBI->connect("DBI:Pg:dbname=$PG_DB_NAME;host=$PG_DB_HOST;port=$PG_DB_PORT", $PG_DB_USER, $PG_DB_PASS)
+my $pg_dbh = DBI->connect('DBI:Pg:'.$PG_DB_DATASOURCE, $PG_DB_USER, $PG_DB_PASS)
     or die("Unable to open pg connection\n");
 
 # SQLite connection now


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/