[osm-tile-server] 66/117: Included scripts from switch2osm
Ruben Undheim
rubund-guest at moszumanska.debian.org
Tue Nov 3 23:18:21 UTC 2015
This is an automated email from the git hooks/post-receive script.
rubund-guest pushed a commit to branch master
in repository osm-tile-server.
commit 116c26809c82d90d1b89cecd4b725189d285d8ff
Author: Ruben Undheim <ruben.undheim at gmail.com>
Date: Sun Sep 6 11:44:30 2015 +0200
Included scripts from switch2osm
---
scripts/Makefile | 3 ++
scripts/install-postgis-osm-db.sh | 83 +++++++++++++++++++++++++++++++++++++
scripts/install-postgis-osm-user.sh | 43 +++++++++++++++++++
3 files changed, 129 insertions(+)
diff --git a/scripts/Makefile b/scripts/Makefile
index 8b52d71..6b48a87 100644
--- a/scripts/Makefile
+++ b/scripts/Makefile
@@ -6,3 +6,6 @@ install:
install osm-tile-server-status ${DESTDIR}/usr/bin/
install osm-tile-server-download ${DESTDIR}/usr/bin/
install osm-tile-server-import ${DESTDIR}/usr/bin/
+ mkdir -p ${DESTDIR}/usr/lib/osm-tile-server-base/bin
+ install install-postgis-osm-db.sh ${DESTDIR}/usr/lib/osm-tile-server-base/bin/
+ install install-postgis-osm-user.sh ${DESTDIR}/usr/lib/osm-tile-server-base/bin/
diff --git a/scripts/install-postgis-osm-db.sh b/scripts/install-postgis-osm-db.sh
new file mode 100755
index 0000000..a6e113c
--- /dev/null
+++ b/scripts/install-postgis-osm-db.sh
@@ -0,0 +1,83 @@
+#!/bin/sh
+set -e
+
+if [ -z $DBOWNER ]; then
+ DBOWNER=osm-tile-server
+fi
+if [ -z $DBNAME ]; then
+ DBNAME=osmdb
+fi
+
+# echo "Removing Old Database"
+# sudo -u postgres dropdb $DBNAME >/dev/null 2>&1 || true
+
+ echo "Create user $DBOWNER"
+ sudo -u postgres createuser --no-superuser --no-createdb --no-createrole "$DBOWNER" || true
+
+ echo "Creating Database"
+ sudo -u postgres createdb -EUTF8 -O $DBOWNER $DBNAME
+
+ echo "Initializing Database"
+
+ sudo -u postgres createlang plpgsql $DBNAME || true
+
+ if [ -e /usr/share/postgresql/9.3/extension/postgis.control ]; then
+ echo "Initializing Spatial Extentions for postgresql 9.3"
+ echo "CREATE EXTENSION postgis;" | sudo -u postgres psql $DBNAME
+ echo "Initializing hstore"
+ echo "CREATE EXTENSION hstore;" | sudo -u postgres psql $DBNAME
+ else if [ -e /usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql ] ; then
+ echo "Initializing Spatial Extentions for postgresql 9.1"
+ file_postgis=/usr/share/postgresql/9.1/contrib/postgis-1.5/postgis.sql
+ file_spatial_ref=/usr/share/postgresql/9.1/contrib/postgis-1.5/spatial_ref_sys.sql
+
+ sudo -u postgres psql $DBNAME <$file_postgis >/dev/null 2>&1
+ sudo -u postgres psql $DBNAME <$file_spatial_ref >/dev/null 2>&1
+ echo "Spatial Extentions initialized"
+
+ echo "Initializing hstore"
+ echo "CREATE EXTENSION hstore;" | sudo -u postgres psql $DBNAME
+ else
+ echo "Initializing Spatial Extentions for postgresql 8.4"
+ file_postgis=/usr/share/postgresql/8.4/contrib/postgis-1.5/postgis.sql
+ file_spatial_ref=/usr/share/postgresql/8.4/contrib/postgis-1.5/spatial_ref_sys.sql
+
+ sudo -u postgres psql $DBNAME <$file_postgis >/dev/null 2>&1
+ sudo -u postgres psql $DBNAME <$file_spatial_ref >/dev/null 2>&1
+ echo "Spatial Extentions initialized"
+
+ echo "Initializing hstore"
+ file_hstore=/usr/share/postgresql/8.4/contrib/hstore.sql
+ sudo -u postgres psql $DBNAME <$file_hstore >/dev/null 2>&1
+ fi fi
+
+ echo "Setting ownership to user $DBOWNER"
+
+ echo 'ALTER TABLE geometry_columns OWNER TO ' $DBOWNER '; ALTER TABLE spatial_ref_sys OWNER TO ' $DBOWNER ';' | sudo -u postgres psql $DBNAME
+
+
+
+if [ -n "$GRANT_USER" ] ; then
+
+ if [ "$GRANT_USER" = "*" ] ; then
+ echo "GRANT Rights to every USER"
+ GRANT_USER=''
+ for user in `users` ; do
+ GRANT_USER="$GRANT_USER $user"
+ done
+ fi
+
+ for user in $GRANT_USER; do
+ sudo -u postgres createuser --no-superuser --no-createdb --no-createrole "$user" || true
+ echo "Granting rights to user '$user'"
+ (
+ echo "GRANT ALL on geometry_columns TO \"$user\";"
+ echo "GRANT ALL ON SCHEMA PUBLIC TO \"$user\";"
+ echo "GRANT ALL on spatial_ref_sys TO \"$user\";"
+ )| sudo -u postgres psql -U postgres $DBNAME
+ done
+else
+ echo "No extra user for postgress Database created. Please do so yourself"
+fi
+
+exit 0
diff --git a/scripts/install-postgis-osm-user.sh b/scripts/install-postgis-osm-user.sh
new file mode 100755
index 0000000..e5fcc6b
--- /dev/null
+++ b/scripts/install-postgis-osm-user.sh
@@ -0,0 +1,43 @@
+#!/bin/sh
+set -e
+
+if [ $# -ne 2 ] ; then
+ echo "Usage: install-postgis-osm-user.sh DBNAME USERNAME"
+ exit
+fi
+
+DBNAME=$1
+GRANT_USER=$2
+
+
+if [ -n "$GRANT_USER" ] ; then
+
+ if [ "$GRANT_USER" = "*" ] ; then
+ echo "GRANT Rights to every USER"
+ GRANT_USER=''
+ for user in `users` ; do
+ GRANT_USER="$GRANT_USER $user"
+ done
+ fi
+
+ for user in $GRANT_USER; do
+ sudo -u postgres createuser --no-superuser --no-createdb --no-createrole "$user" || true
+ echo "Granting rights to user '$user'"
+ (
+ echo "GRANT ALL on geometry_columns TO \"$user\";"
+ echo "GRANT ALL ON SCHEMA PUBLIC TO \"$user\";"
+ echo "GRANT ALL on spatial_ref_sys TO \"$user\";"
+ echo "GRANT ALL on planet_osm_line TO \"$user\";"
+ echo "GRANT ALL on planet_osm_nodes TO \"$user\";"
+ echo "GRANT ALL on planet_osm_point TO \"$user\";"
+ echo "GRANT ALL on planet_osm_rels TO \"$user\";"
+ echo "GRANT ALL on planet_osm_roads TO \"$user\";"
+ echo "GRANT ALL on planet_osm_ways TO \"$user\";"
+ echo "GRANT ALL on planet_osm_polygon TO \"$user\";"
+ )| sudo -u postgres psql -Upostgres $DBNAME
+ done
+else
+ echo "No extra user for postgress Database created. Please do so yourself"
+fi
+
+exit 0
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-grass/osm-tile-server.git
More information about the Pkg-grass-devel
mailing list