diff options
author | Peter Palfrader <peter@palfrader.org> | 2007-11-29 11:20:26 +0000 |
---|---|---|
committer | Peter Palfrader <peter@palfrader.org> | 2007-11-29 11:20:26 +0000 |
commit | 423293dead2208aba3428e0b7add48416c34cef4 (patch) | |
tree | 011590259a84167fcaf4f74604a63f13f2233168 /contrib/auto-naming | |
parent | 30cbcaecc55dcce728a7ddc970574d2dc8f1c536 (diff) | |
download | tor-423293dead2208aba3428e0b7add48416c34cef4.tar.gz tor-423293dead2208aba3428e0b7add48416c34cef4.zip |
Make dbhost configureable
svn:r12600
Diffstat (limited to 'contrib/auto-naming')
-rwxr-xr-x | contrib/auto-naming/build-approved-routers | 2 | ||||
-rw-r--r-- | contrib/auto-naming/db-config.rb | 2 | ||||
-rw-r--r-- | contrib/auto-naming/db.rb | 4 | ||||
-rwxr-xr-x | contrib/auto-naming/process-consensus | 2 | ||||
-rwxr-xr-x | contrib/auto-naming/update-named-status.rb | 9 |
5 files changed, 13 insertions, 6 deletions
diff --git a/contrib/auto-naming/build-approved-routers b/contrib/auto-naming/build-approved-routers index 4bbf8e7795..805321f208 100755 --- a/contrib/auto-naming/build-approved-routers +++ b/contrib/auto-naming/build-approved-routers @@ -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(" diff --git a/contrib/auto-naming/db-config.rb b/contrib/auto-naming/db-config.rb index 3cf2dbe32a..b1508c1b70 100644 --- a/contrib/auto-naming/db-config.rb +++ b/contrib/auto-naming/db-config.rb @@ -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'; diff --git a/contrib/auto-naming/db.rb b/contrib/auto-naming/db.rb index b57724acdd..822a26bad7 100644 --- a/contrib/auto-naming/db.rb +++ b/contrib/auto-naming/db.rb @@ -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 diff --git a/contrib/auto-naming/process-consensus b/contrib/auto-naming/process-consensus index 2c8b481f5d..dc9d207e43 100755 --- a/contrib/auto-naming/process-consensus +++ b/contrib/auto-naming/process-consensus @@ -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 = {} diff --git a/contrib/auto-naming/update-named-status.rb b/contrib/auto-naming/update-named-status.rb index b4d1b2d612..951e7e687a 100755 --- a/contrib/auto-naming/update-named-status.rb +++ b/contrib/auto-naming/update-named-status.rb @@ -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 |