forked from kartoza/docker-pg-backup
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·56 lines (41 loc) · 1.13 KB
/
start.sh
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#!/bin/bash
# This script will set up the postgres environment
# based done evn vars passed to then docker container
# Tim Sutton, April 2015
# Check if each var is declared and if not,
# set a sensible default
if [ -z "${POSTGRES_USER}" ]; then
POSTGRES_USER=docker
fi
if [ -z "${POSTGRES_PASS}" ]; then
POSTGRES_PASS=docker
fi
if [ -z "${POSTGRES_PORT}" ]; then
POSTGRES_PORT=5432
fi
if [ -z "${POSTGRES_HOST}" ]; then
POSTGRES_HOST=db
fi
if [ -z "${POSTGRES_DBNAME}" ]; then
POSTGRES_DBNAME=gis
fi
if [ -z "${DUMPPREFIX}" ]; then
DUMPPREFIX=PG
fi
# Now write these all to case file that can be sourced
# by then cron job - we need to do this because
# env vars passed to docker will not be available
# in then contenxt of then running cron script.
echo "
export PGUSER=$POSTGRES_USER
export PGPASSWORD=\"$POSTGRES_PASS\"
export PGPORT=$POSTGRES_PORT
export PGHOST=$POSTGRES_HOST
export PGDATABASE=$POSTGRES_DBNAME
export DUMPPREFIX=$DUMPPREFIX
export ARCHIVE_FILENAME="${ARCHIVE_FILENAME}"
" > /pgenv.sh
echo "Start script running with these environment options"
set | grep PG
# Now launch cron in then foreground.
cron -f