-
Notifications
You must be signed in to change notification settings - Fork 0
/
pkg-database.sh
executable file
·116 lines (98 loc) · 5.05 KB
/
pkg-database.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
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
#!/bin/sh
#
# This file is part of the SavaPage project <https://www.savapage.org>.
# Copyright (c) 2011-2020 Datraverse B.V.
# Author: Rijk Ravestein.
#
# SPDX-FileCopyrightText: 2011-2020 Datraverse B.V. <[email protected]>
# SPDX-License-Identifier: AGPL-3.0-or-later
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <https://www.gnu.org/licenses/>.
#
# For more information, please contact Datraverse B.V. at this
# address: [email protected]
#
#--------------------------------------------------------------------
# Get the absolute path of this (symlinked) file
#--------------------------------------------------------------------
SP_SELF_PATH=$(cd -P -- "$(dirname -- "$0")" && pwd -P) && SP_SELF_PATH=$SP_SELF_PATH/$(basename -- "$0")
# resolve symlinks
while [ -h $SP_SELF_PATH ]; do
# 1) cd to directory of the symlink
# 2) cd to the directory of where the symlink points
# 3) get the pwd
# 4) append the basename
SP_DIR=$(dirname -- "$SP_SELF_PATH")
SP_SYM=$(readlink $SP_SELF_PATH)
SP_SELF_PATH=$(cd $SP_DIR && cd $(dirname -- "$SP_SYM") && pwd)/$(basename -- "$SP_SYM")
done
_CURRENTDIR=`dirname ${SP_SELF_PATH}`
#--------------------------------------------------------------------
. ${_CURRENTDIR}/pkg-settings
#=========================================================================
# CONSTANTS
#=========================================================================
DIST_HOME=${_DIST_HOME_DERBY}
#----------------------------------------
# Remove old distribution
#----------------------------------------
rm -rf ${DIST_HOME}
#----------------------------------------
# Create again ...
#----------------------------------------
mkdir --parent ${DIST_HOME}/sql
#=======================================================================
#
#=======================================================================
readonly _SAVAPAGE_UTIL_APP=${_DIST_HOME_INTERNAL}/bin/savapage-util
echo "+-----------------------------------------------------------------"
echo "| Generating Database scripts with:"
echo "| ${_SAVAPAGE_UTIL_APP} ..."
echo "+-----------------------------------------------------------------"
readonly SCHEMA_VERSION="$(${_SAVAPAGE_UTIL_APP} --db-version)"
echo "+-----------------------------------------------------------------"
echo "| Initializing Derby Database version ${SCHEMA_VERSION} ..."
echo "+-----------------------------------------------------------------"
${_SAVAPAGE_UTIL_APP} --db-type Internal --db-create --server-home ${DIST_HOME}
#-----------------------------------------------------------------------------
# NOTE: created scripts can be used to manually compose an update script.
#-----------------------------------------------------------------------------
#------------------------------------
SCHEMA_DB_TYPE=Internal
SCHEMA_DB_HOME_NAME=Derby
echo "+---------------------------------------------------------------------"
echo "| Creating drop and create SQL scripts for ${SCHEMA_DB_HOME_NAME} schema version ${SCHEMA_VERSION} ..."
echo "+---------------------------------------------------------------------"
${_SAVAPAGE_UTIL_APP} --db-type ${SCHEMA_DB_TYPE} --db-sql-create "${DIST_HOME}/sql/create-${SCHEMA_VERSION}.sql" --db-sql-drop "${DIST_HOME}/sql/drop-${SCHEMA_VERSION}.sql"
echo "+---------------------------------------------------------------------"
echo "| Copying SQL scripts to ${_SETUP_TEMPLATE_HOME} ..."
echo "+---------------------------------------------------------------------"
cp "${DIST_HOME}"/sql/*.sql ${_SETUP_TEMPLATE_HOME}/server/lib/sql/${SCHEMA_DB_HOME_NAME}
#------------------------------------
# PostgreSQL
#------------------------------------
SCHEMA_DB_TYPE=PostgreSQL
SCHEMA_DB_HOME_NAME=PostgreSQL
DIST_HOME=${_DIST_HOME_POSTGRES}
rm -rf ${DIST_HOME}
mkdir --parent ${DIST_HOME}/sql
echo "+---------------------------------------------------------------------"
echo "| Creating drop and create SQL scripts for ${SCHEMA_DB_HOME_NAME} schema version ${SCHEMA_VERSION} ..."
echo "+---------------------------------------------------------------------"
${_SAVAPAGE_UTIL_APP} --db-type ${SCHEMA_DB_TYPE} --db-sql-create "${DIST_HOME}/sql/create-${SCHEMA_VERSION}.sql" --db-sql-drop "${DIST_HOME}/sql/drop-${SCHEMA_VERSION}.sql"
echo "+---------------------------------------------------------------------"
echo "| Copying SQL scripts to ${_SETUP_TEMPLATE_HOME} ..."
echo "+---------------------------------------------------------------------"
cp "${DIST_HOME}"/sql/*.sql ${_SETUP_TEMPLATE_HOME}/server/lib/sql/${SCHEMA_DB_HOME_NAME}
# end-of-file