humble beginnings

This commit is contained in:
Motiejus Jakštys
2019-10-26 14:33:46 +03:00
parent 1624784975
commit 1367c35a31
3 changed files with 77 additions and 0 deletions

23
MTM/task4-straipsnis/managedb Executable file
View File

@@ -0,0 +1,23 @@
#!/bin/bash
set -xeuo pipefail
if [[ $1 == init ]]; then
mkdir -p db && initdb db
pg_ctl -D db -l db/logfile start
psql postgres \
-c 'CREATE DATABASE airportgames;' \
-c 'CREATE USER airportgames;' \
-c 'GRANT ALL PRIVILEGES ON DATABASE airportgames to airportgames;'
psql -d airportgames \
-c 'CREATE EXTENSION postgis'
fi
if [[ $1 == start ]]; then
pg_ctl -D db -l db/logfile start
fi
if [[ $1 == stop ]]; then
pg_ctl -D db -l db/logfile stop
fi