-
Notifications
You must be signed in to change notification settings - Fork 0
/
run-create.sh
executable file
·45 lines (34 loc) · 1.03 KB
/
run-create.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
#!/bin/sh
date=$(date '+%Y-%m-%d')
port=5432
if [ "$OS" = "Darwin" ]; then
server=$(ipconfig getifaddr en0)
else
server=$(hostname -i | awk '{print $1}')
fi
if [ $# -ne 1 ] && [ $# -ne 2 ]; then
echo "Usage: $0 [server] [port]"
echo "$0 localhost 5432"
exit 1
fi
if [ ! -x "$(command -v psql)" ]; then
echo "please install psql"
exit 2
fi
if [ -n "$1" ]; then
server=$1
fi
if [ -n "$2" ]; then
port=$2
fi
echo "server is '$server', port is set to '$port'."
echo "Press enter to continue"
read -r x
echo "$x" > /dev/null
echo enter postgres user password to add finance_db objects
psql -h "${server}" -p "${port}" -d postgres -U henninb < finance_db-create.sql | tee -a "finance_db-create-${date}.log"
echo enter postgres user password to add finance_test_db objects
psql -h "${server}" -p "${port}" -d postgres -U henninb < finance_test_db-create.sql | tee -a "finance_test_db-create-${date}.log"
echo psql finance_db -U henninb -h "${server}" -p "${port}"
echo psql finance_test_db -U henninb -h "${server}" -p "${port}"
exit 0