-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisql
executable file
·53 lines (43 loc) · 997 Bytes
/
isql
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
#!/bin/bash
#
# Patches/applies one or more change requests (or any SQL file) to a database.
SHELL=/bin/bash
source .env
g_db=sead_staging_development
g_host=$(dnsdomainname -A)
g_port=5433
g_user=
if [ -f ~/vault/.default.sead.server ]; then
g_host=`cat ~/vault/.default.sead.server`
fi
if [ -f ~/vault/.default.sead.username ]; then
g_user=`cat ~/vault/.default.sead.username`
fi
POSITIONAL=()
while [[ $# -gt 0 ]]
do
key="$1"
case $key in
--database|-d)
g_db="$2"; shift 2;
;;
--port|-p)
g_port="$2"; shift 2;
;;
--user|-U)
g_user="$2"; shift 2;
;;
--host|-h)
g_host="$2"; shift 2;
;;
--*)
usage 'fatal: target database not specified!'
shift 2;
;;
esac
done
set -- "${POSITIONAL[@]}"
if [ "$g_db" == "" ]; then
usage 'fatal: target database not specified!'
fi
psql -h $g_host -p $g_port -U $g_user -d $g_db