mirror of
https://gitlab.torproject.org/tpo/core/tor.git
synced 2024-11-10 13:13:44 +01:00
Make dbhost configureable
svn:r12600
This commit is contained in:
parent
30cbcaecc5
commit
423293dead
@ -30,7 +30,7 @@ require 'db-config'
|
||||
|
||||
verbose = ARGV.first == "-v"
|
||||
|
||||
db = Db.new($CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
|
||||
db = Db.new($CONFIG['database']['dbhost'], $CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
|
||||
|
||||
db.transaction_begin
|
||||
named = db.query2("
|
||||
|
@ -1,6 +1,8 @@
|
||||
$CONFIG = {} unless $CONFIG
|
||||
$CONFIG['database'] = {} unless $CONFIG['database']
|
||||
|
||||
# if you use postgres' "ident sameuser" auth set dbhost to ''
|
||||
$CONFIG['database']['dbhost'] = 'localhost';
|
||||
$CONFIG['database']['dbname'] = 'tornaming';
|
||||
$CONFIG['database']['user'] = 'tornaming';
|
||||
$CONFIG['database']['password'] = 'x';
|
||||
|
@ -39,8 +39,8 @@ class WeaselDbQueryHandle
|
||||
end
|
||||
|
||||
class Db
|
||||
def initialize(database, user, password)
|
||||
@dbh = DBI.connect("dbi:Pg:#{database}:localhost", user, password);
|
||||
def initialize(host, database, user, password)
|
||||
@dbh = DBI.connect("dbi:Pg:#{database}:#{host}", user, password);
|
||||
@dbh['AutoCommit'] = false
|
||||
@transaction = false
|
||||
@pre_initial_transaction=true
|
||||
|
@ -31,7 +31,7 @@ require 'db'
|
||||
require 'db-config'
|
||||
require 'update-named-status'
|
||||
|
||||
$db = Db.new($CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
|
||||
$db = Db.new($CONFIG['database']['dbhost'], $CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
|
||||
|
||||
$router_cache = {}
|
||||
$nickname_cache = {}
|
||||
|
@ -28,7 +28,12 @@ require 'db'
|
||||
require 'db-config'
|
||||
|
||||
def do_update(verbose)
|
||||
now = "TIMESTAMP '" + $db.query_row("SELECT max(last_seen) AS max FROM router_claims_nickname")['max'].to_s + "'"
|
||||
now = $db.query_row("SELECT max(last_seen) AS max FROM router_claims_nickname")['max']
|
||||
unless now == ''
|
||||
STDERR.puts "Could not find the latest last_seen timestamp. Is the database empty still?"
|
||||
return
|
||||
end
|
||||
now = "TIMESTAMP '" + now.to_s + "'"
|
||||
|
||||
denamed = $db.do("
|
||||
UPDATE router_claims_nickname
|
||||
@ -56,7 +61,7 @@ def do_update(verbose)
|
||||
end
|
||||
|
||||
if __FILE__ == $0
|
||||
$db = Db.new($CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
|
||||
$db = Db.new($CONFIG['database']['dbhost'], $CONFIG['database']['dbname'], $CONFIG['database']['user'], $CONFIG['database']['password'])
|
||||
verbose = ARGV.first == "-v"
|
||||
|
||||
$db.transaction_begin
|
||||
|
Loading…
Reference in New Issue
Block a user