Change way, new DBs are created

Signed-off-by: merspieler <merspieler@airmail.cc>
This commit is contained in:
merspieler 2019-09-29 02:46:52 +00:00
parent 54f7e1ea9d
commit 3398143f9b
2 changed files with 6 additions and 5 deletions

View file

@ -62,9 +62,7 @@ if [ ! -z "$man_user" ]; then
db_user="$man_user"
fi
sudo -u postgres createdb --encoding=UTF8 --owner=$db_user "$database"
sudo -u postgres psql --dbname="$database" -c "CREATE EXTENSION postgis;"
sudo -u postgres psql --dbname="$database" -c "CREATE EXTENSION hstore;"
createdb --encoding=UTF8 --owner=$db_user --template=osm2city_template "$database"
psql -d "$database" -f sql/pgsnapshot_schema_0.6.sql
psql -d "$database" -f sql/pgsnapshot_schema_0.6_bbox.sql

View file

@ -117,12 +117,15 @@ if [ "$skip_sql" != 1 ]; then
read db_user
echo "Please enter a password: "
read db_passwd
sudo -u postgres psql -c "CREATE USER $db_user WITH PASSWORD '$db_passwd';"
sudo -u postgres psql -c "CREATE USER $db_user WITH PASSWORD '$db_passwd'; ALTER USER $db_user CREATEDB;"
echo "db_user=$db_user" >> general-settings
echo "db_passwd=$db_passwd" >> general-settings
echo "db_passwd=\"$db_passwd\"" >> general-settings
fi
fi
echo "Creating template database..."
sudo -u postgres createdb --encoding=UTF8 osm2city_template && psql --dbname="$database" -c "CREATE EXTENSION postgis;" && psql --dbname="$database" -c "CREATE EXTENSION hstore;" && psql -c "ALTER DATABASE osm2city_template OWNER TO $db_user;"
if [ ! -f general-settings ]; then
echo "# This file must be used with "source general-settings" *from bash*" > general-settings
echo "# you cannot run it directly" >> general-settings