-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathdb-start
More file actions
executable file
·34 lines (28 loc) · 1023 Bytes
/
Copy pathdb-start
File metadata and controls
executable file
·34 lines (28 loc) · 1023 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#!/usr/bin/env bash
# Copyright (c) 2022 Erik Hanson
# SPDX-License-Identifier: MIT
#
# Starts postgres. Assumes that postgres is installed via `asdf` (https://asdf-vm.com).
#
# The `pgdir` variable below is set to store the postgres data in a `priv/postgres` directory inside
# the current working directory, so that each project has its own postgres data.
# Change the variable if that's not where you want to store it.
set -e
if ! eval "asdf plugin-list | grep postgres > /dev/null 2>&1"; then
echo "${0}: asdf postgres plugin not found"
exit 1
fi
asdf where postgres > /dev/null
pgdir="$(pwd)/priv/postgres"
postgres_path="$(asdf where postgres)"
log_path="${pgdir}/logfile"
datadir="${pgdir}/data"
mkdir -p ${datadir}
if [[ -f ${datadir}/PG_VERSION ]]; then
echo "${0}: Starting postgres"
"${postgres_path}/bin/pg_ctl" -D "${datadir}" -l "${log_path}" start
echo ""
else
echo "${0}: ${datadir} does not seem to be a postgres data directory"
echo "${0}: Try running: pg_ctl -D ${datadir} initdb"
fi