-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuildDocs
More file actions
executable file
·122 lines (93 loc) · 2.97 KB
/
buildDocs
File metadata and controls
executable file
·122 lines (93 loc) · 2.97 KB
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#!/bin/sh
# Name: buildDocs
# Purpose: use schemaSpy to build a set of HTML pages and associated images.
# These files serve as a schema browser for a Postgres database. We
# then run a script to clean up these files with some MGI
# customizations. The schemaSpy library itself is not altered -- only
# its output files.
# Notes:
# 1. We assume the traditional mgd_public account and password can be
# used to access the database.
USAGE='buildDocs <server> <database> <schema> <target dir>'
if [ "${MGICONFIG}" = "" ]; then
MGICONFIG='/usr/local/mgi/live/mgiconfig'
fi
. ${MGICONFIG}/master.config.sh
# server - name of the Postgres server
# database - name of the database in the server
# schema - name of which schema in the database (even if public, must specify)
# target dir - directory to which to write the output
# check that we have enough arguments
if [ $# -ne 4 ]; then
echo "Wrong number of arguments"
echo ${USAGE}
exit 1
fi
# pick up the arguments and put them in the appropriate environment variables,
# then export them for use by subprocesses
PGHOST=$1
export PGHOST
PGDATABASE=$2
export PGDATABASE
PGUSER=mgd_public
export PGUSER
PGPASSWORD=mgdpub
export PGPASSWORD
PGSCHEMA=$3
export PGSCHEMA
PGPORT=5432
export PGPORT
# Set the library path.
LD_LIBRARY_PATH=/usr/local/lib:/usr/local/pgsql/lib
export LD_LIBRARY_PATH
# trim any trailing slash from the target directory
TARGETDIR=`echo $4 | sed 's/\/$//'`
export TARGETDIR
# check the Java version (must be at least 1.6.0)
#JAVA_VERSION=`${JAVA} -version 2>&1 | head -1 | sed 's/\./ /g' | awk '{print $4}'`
#if [ ${JAVA_VERSION} -lt 6 ]; then
# echo "Error: Java must be at least version 1.6"
# ${JAVA} -version 2>&1
# exit 1
#fi
# check the GraphViz version (must be at least 2.4)
DOT_VERSION=`dot -V 2>&1 | sed 's/[a-zA-Z \-]//g' | sed 's/(.*//g' | sed 's/\./ /g' | awk '{print $2}'`
if [ ${DOT_VERSION} -lt 4 ]; then
echo "Error: GraphViz's dot must be at least version 2.4 -- check PATH"
dot -V 2>&1
exit 1
fi
# clean the directory, if it exists
# make the directory if it does not exist
if [ -d ${TARGETDIR} ]; then
rm -rf ${TARGETDIR}/*
echo "Cleaned out ${TARGETDIR}"
else
mkdir ${TARGETDIR}
echo "Created ${TARGETDIR}"
fi
# run schemaSpy to generate the files
echo "Running schemaSpy"
${JAVA} -jar schemaSpy_5.0.0.jar -t pgsql -host ${PGHOST} -port 5432 -db ${PGDATABASE} -u ${PGUSER} -o ${TARGETDIR} -s ${PGSCHEMA} -p ${PGPASSWORD} -dp ${PGJDBC}
# do post-processing of the files for MGI branding and some cleanup
for file in `ls ${TARGETDIR}/*.html`
do
./schemaSpyCleanup.py -a -d -i ${file} ${PGHOST} ${PGDATABASE} ${PGSCHEMA} ${PGUSER} ${PGPASSWORD}
if [ $? -eq 0 ]; then
echo "Post-processed ${file}"
else
echo "Failed on ${file}"
exit 1
fi
done
for file in `ls ${TARGETDIR}/tables/*.html`
do
./schemaSpyCleanup.py -a -d ${file} ${PGHOST} ${PGDATABASE} ${PGSCHEMA} ${PGUSER} ${PGPASSWORD}
if [ $? -eq 0 ]; then
echo "Post-processed ${file}"
else
echo "Failed on ${file}"
exit 1
fi
done
echo "Done."