aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2011-10-10 20:38:34 +0200
committerJochen Topf <jochen@topf.org>2011-10-10 20:38:34 +0200
commit37218f57f1b53a5f0b1a3d4e4444e8d80b5d667c (patch)
treecbd6b41d6696e7e7a2df009c6470df152b4b3dfe
parent82c320568448206a65816cb602dfa8f8a3399c1e (diff)
downloadtaginfo-37218f57f1b53a5f0b1a3d4e4444e8d80b5d667c.tar
taginfo-37218f57f1b53a5f0b1a3d4e4444e8d80b5d667c.tar.gz
Add taginfo-config.rb to read config from command line.
I added bin/taginfo-config.rb to easily access the config file from the command line. This is now used in sources/db/update.sh and sources/update_all.sh. This, again, reduces the places in the distribution where things needed to be changed for each instance.
-rwxr-xr-xbin/taginfo-config.rb20
-rwxr-xr-xsources/db/update.sh2
-rwxr-xr-xsources/update_all.sh8
-rw-r--r--taginfo-config-example.json (renamed from taginfo-config.json)14
-rw-r--r--web/lib/config.rb2
5 files changed, 39 insertions, 7 deletions
diff --git a/bin/taginfo-config.rb b/bin/taginfo-config.rb
new file mode 100755
index 0000000..fbeb163
--- /dev/null
+++ b/bin/taginfo-config.rb
@@ -0,0 +1,20 @@
+#!/usr/bin/ruby
+#
+# taginfo-config.rb [KEY]
+#
+
+require 'rubygems'
+require 'json'
+
+require File.expand_path(File.dirname(__FILE__)) + '/../web/lib/config.rb'
+
+TaginfoConfig.read
+
+value = TaginfoConfig.get(ARGV[0])
+if value.nil?
+ puts ''
+ exit 1
+end
+
+puts value
+
diff --git a/sources/db/update.sh b/sources/db/update.sh
index 5adf383..19d3518 100755
--- a/sources/db/update.sh
+++ b/sources/db/update.sh
@@ -21,7 +21,7 @@ if [ "x" = "x$DIR" ]; then
fi
if [ "x" = "x$PLANETFILE" ]; then
- PLANETFILE=/osm/planet/var/current-planet.osm.pbf
+ PLANETFILE=`../../bin/taginfo-config.rb sources.db.planetfile`
fi
echo "`$DATECMD` Start db..."
diff --git a/sources/update_all.sh b/sources/update_all.sh
index 6e2aeac..c9fbc40 100755
--- a/sources/update_all.sh
+++ b/sources/update_all.sh
@@ -16,14 +16,14 @@
#
#------------------------------------------------------------------------------
-# These sources will be downloaded from http://taginfo.openstreetmap.de/download/
+# These sources will be downloaded from http://taginfo.openstreetmap.org/download/
# Note that this will NOT work for the "db" source! Well, you can download it,
# but it will fail later, because the database is changed by the master.sql
# scripts.
-SOURCES_DOWNLOAD=""
+SOURCES_DOWNLOAD=`../bin/taginfo-config.rb sources.download`
# These sources will be created from the actual sources
-SOURCES_CREATE="josm potlatch merkaartor wiki db"
+SOURCES_CREATE=`../bin/taginfo-config.rb sources.create`
#------------------------------------------------------------------------------
@@ -50,7 +50,7 @@ for source in $SOURCES_DOWNLOAD; do
echo "====================================="
echo "Downloading $source..."
mkdir -p $DIR/$source
- wget --quiet -O $DIR/download/taginfo-$source.db.bz2 http://taginfo.openstreetmap.de/download/taginfo-$source.db.bz2
+ wget --quiet -O $DIR/download/taginfo-$source.db.bz2 http://taginfo.openstreetmap.org/download/taginfo-$source.db.bz2
bzcat $DIR/download/taginfo-$source.db.bz2 >$DIR/$source/taginfo-$source.db
echo "Done."
done
diff --git a/taginfo-config.json b/taginfo-config-example.json
index cf37ca4..ff2f0a2 100644
--- a/taginfo-config.json
+++ b/taginfo-config-example.json
@@ -1,5 +1,5 @@
// This is an example of a Taginfo config file.
-// Copy it to the directory above where you found this example file.
+// Copy it to the directory above and name it 'taginfo-config.json', then change your local settings.
{
// You probably want to change all these.
"instance": {
@@ -30,5 +30,17 @@
"contact": "somebody@example.com",
"description": "Find metadata about OpenStreetMap tags",
"tags": "osm openstreetmap tag tags taginfo"
+ },
+ "sources": {
+ // These sources will be downloaded from http://taginfo.openstreetmap.org/download/
+ // Note that this will NOT work for the "db" source! Well, you can download it,
+ // but it will fail later, because the database is changed by the master.sql
+ // scripts.
+ "download": "josm potlatch merkaartor wiki",
+ // These sources will be created from the actual sources.
+ "create": "db",
+ "db": {
+ "planetfile": "/osm/planet/var/current-planet.osm.pbf"
+ }
}
}
diff --git a/web/lib/config.rb b/web/lib/config.rb
index 135337d..c901921 100644
--- a/web/lib/config.rb
+++ b/web/lib/config.rb
@@ -5,7 +5,7 @@ class TaginfoConfig
@@config = {}
def self.read
- open('../../taginfo-config.json') do |file|
+ open(File.expand_path(File.dirname(__FILE__)) + '/../../../taginfo-config.json') do |file|
@@config = JSON.parse(file.gets(nil))
end
end