[osm-tile-server] 17/117: Checking if db exists already
Ruben Undheim
rubund-guest at moszumanska.debian.org
Tue Nov 3 23:18:15 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 8334c5091ba32dbbef418da7fc08eb266f42389f
Author: Ruben Undheim <ruben.undheim at gmail.com>
Date: Thu Sep 3 01:03:05 2015 +0200
Checking if db exists already
---
debian/osm-tile-server-config.postinst | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/debian/osm-tile-server-config.postinst b/debian/osm-tile-server-config.postinst
index 88c9749..38e8192 100644
--- a/debian/osm-tile-server-config.postinst
+++ b/debian/osm-tile-server-config.postinst
@@ -52,10 +52,20 @@ case "$1" in
USEREXISTS=$?
set -e
if [ "$USEREXISTS" = "0" ] ; then
- echo "YES"
+ echo "YES. Do nothing."
else
- echo "NO. Creating user, database and setting it up..."
+ echo "NO. Creating user ${DBUSER}..."
su postgres -c "cd /var/lib/postgresql ; createuser $DBUSER"
+ fi
+ echo -n "Checking if database $DBNAME already exists... "
+ set +e
+ su postgres -c "cd /var/lib/postgresql ; psql postgres -tAc \"SELECT 1 FROM pg_database WHERE datname='$DBNAME'\"" | grep -q 1
+ DBEXISTS=$?
+ set -e
+ if [ "$DBEXISTS" = "0" ] ; then
+ echo "YES. Do nothing."
+ else
+ echo "NO. Creating database ${DBNAME} and setting up... "
su postgres -c "cd /var/lib/postgresql ; createdb -E UTF8 -O $DBUSER $DBNAME"
su postgres -c "cd /var/lib/postgresql ; psql -c \"CREATE EXTENSION hstore;\" -d $DBNAME"
su postgres -c "cd /var/lib/postgresql ; psql -c \"CREATE EXTENSION postgis;\" -d $DBNAME"
--
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