This commit is contained in:
Motiejus Jakštys
2020-12-11 10:44:26 +02:00
parent 5c3d8b465b
commit cf7b80fed3
5 changed files with 132 additions and 0 deletions

35
contours/managedb Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
PATH=$PATH:/usr/lib/postgresql/12/bin
case ${1:-} in
init)
mkdir -p db && initdb db
mkdir -p db/wal
sed -i "s/.*unix_socket_dir.*/unix_socket_directories = '.\/wal'/" \
db/postgresql.conf
pg_ctl -D db -l db/logfile start
export PGHOST=127.0.0.1
psql postgres -c 'CREATE ROLE osm WITH SUPERUSER LOGIN'
psql postgres -c 'CREATE DATABASE osm'
psql osm osm -c 'CREATE EXTENSION postgis'
;;
start)
pg_ctl -D db -l db/logfile start
;;
stop)
pg_ctl -D db -l db/logfile stop
;;
"" | --)
[[ $# -gt 1 ]] && shift
exec env \
PGHOST=127.0.0.1 \
PGUSER=osm \
PGDATABASE=osm \
psql "$@"
;;
*)
>&2 echo "Unknown command: '$*'"
exit 1
;;
esac