File: fixup-db.sh

package info (click to toggle)
gnumed-server 21.11-1
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 45,408 kB
  • ctags: 3,891
  • sloc: sql: 1,210,640; python: 13,526; sh: 1,476; makefile: 19
file content (93 lines) | stat: -rwxr-xr-x 2,180 bytes parent folder | download | duplicates (3)
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash

# ========================================================
# Apply GNUmed database fixups.
#
# usage:
#  fixup-db.sh XX <quiet>
#		XX: the database version to upgrade, such as 15
#
# prerequisites:
#  fixup_db-vX.conf must exist
#
# "secret" command line options:
#  quiet
#  - display failures only, don't chatter
#
# ========================================================

VER="$1"
QUIET="$2"
LOG_BASE="."
LOG="${LOG_BASE}/fixup_db-v${VER}.log"
CONF="fixup_db-v${VER}.conf"


if test ! -f $CONF ; then
	echo ""
	echo "Trying to fix database version <${VER}> ..."
	echo ""
	echo "========================================="
	echo "ERROR: The configuration file:"
	echo "ERROR:"
	echo "ERROR:  $CONF"
	echo "ERROR"
	echo "ERROR: does not exist. Aborting."
	echo "========================================="
	echo ""
	echo "USAGE: $0 xx"
	echo "   xx   - database version to fix"
	exit
fi ;


# if you need to adjust the database name to something
# other than what the config file has you can use the
# following environment variable:
#export GM_CORE_DB="gnumed_v${VER}"


# if you need to adjust the port you want to use to
# connect to PostgreSQL you can use the environment
# variable below (this may be necessary if your PostgreSQL
# server is running on a port different from the default 5432)
#export GM_DB_PORT="5433"


# tell libpq-based tools about the non-default port, if any
if test -n "${GM_DB_PORT}" ; then
	PORT_DEF="-p ${GM_DB_PORT}"
	export PGPORT="${GM_DB_PORT}"
else
	PORT_DEF=""
fi ;


function echo_msg () {
	if test "$QUIET" == "quiet"; then
		return
	fi ;
	echo $1 ;
}


echo_msg ""
echo_msg "==========================================================="
echo_msg "Fixing GNUmed database."
echo_msg ""
echo_msg "This will apply fixups to an existing GNUmed database of"
echo_msg "version ${VER} named \"gnumed_v${VER}\"."
echo_msg "==========================================================="


echo_msg ""
echo_msg "1) applying fixes to database ..."
./bootstrap_gm_db_system.py --log-file=${LOG} --conf-file=${CONF} --${QUIET}
if test "$?" != "0" ; then
	echo "Fixing \"gnumed_v${VER}\" did not finish successfully."
	read
	exit 1
fi


exit 0