Skip to content

Commit 5c8d914

Browse files
sbalousekDjelibeybi
authored andcommitted
Oracle GoldenGate
- Run all shell scripts through `shfmt -w`, replacing leading spaces with TAB characters Signed-off-by: Stephen Balousek <[email protected]>
1 parent a7760ca commit 5c8d914

File tree

5 files changed

+139
-139
lines changed

5 files changed

+139
-139
lines changed

OracleGoldenGate/23/bin/create-certificate.sh

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ set -e
99
## Create a self-signed certificate/key pair
1010
##
1111
function create_certificate() {
12-
local config
13-
config="$(mktemp)"
14-
cat <<EOF >"${config}"
12+
local config
13+
config="$(mktemp)"
14+
cat <<EOF >"${config}"
1515
[req]
1616
distinguished_name = distinguished_name
1717
x509_extensions = x509_extensions
@@ -23,12 +23,12 @@ CN = GoldenGate Deployment
2323
[x509_extensions]
2424
extendedKeyUsage = serverAuth
2525
EOF
26-
mkdir -p "$(dirname "${NGINX_CRT}")"
27-
openssl req -x509 -sha256 \
28-
-newkey rsa:2048 -nodes -keyout "${NGINX_KEY}" \
29-
-days $((365 * 3)) -out "${NGINX_CRT}" \
30-
-config "${config}"
31-
rm "${config}"
26+
mkdir -p "$(dirname "${NGINX_CRT}")"
27+
openssl req -x509 -sha256 \
28+
-newkey rsa:2048 -nodes -keyout "${NGINX_KEY}" \
29+
-days $((365 * 3)) -out "${NGINX_CRT}" \
30+
-config "${config}"
31+
rm "${config}"
3232
}
3333

3434
create_certificate

OracleGoldenGate/23/bin/deployment-main.sh

Lines changed: 83 additions & 83 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ set -e
1010
## Terminate with an error message
1111
##
1212
function abort() {
13-
echo "Error - $*"
14-
exit 1
13+
echo "Error - $*"
14+
exit 1
1515
}
1616

1717
: "${OGG_DEPLOYMENT:=Local}"
@@ -40,143 +40,143 @@ export OGG_DEPLOYMENT OGG_ADMIN NGINX_CRT NGINX_KEY
4040
## - at least one digit character
4141
##
4242
function generatePassword {
43-
if [[ -n "${OGG_ADMIN_PWD}" || -d "${OGG_DEPLOYMENT_HOME}/Deployment/etc" ]]; then
44-
return
45-
fi
46-
local password
47-
password="$(openssl rand -base64 9)-$(openssl rand -base64 3)"
48-
if [[ "${password}" != "${password/[A-Z]/_}" &&
49-
"${password}" != "${password/[a-z]/_}" &&
50-
"${password}" != "${password/[0-9]/_}" ]]; then
51-
export OGG_ADMIN_PWD="${password}"
52-
echo "----------------------------------------------------------------------------------"
53-
echo "-- Password for OGG administrative user '${OGG_ADMIN}' is '${OGG_ADMIN_PWD}'"
54-
echo "----------------------------------------------------------------------------------"
55-
return
56-
fi
57-
generatePassword
43+
if [[ -n "${OGG_ADMIN_PWD}" || -d "${OGG_DEPLOYMENT_HOME}/Deployment/etc" ]]; then
44+
return
45+
fi
46+
local password
47+
password="$(openssl rand -base64 9)-$(openssl rand -base64 3)"
48+
if [[ "${password}" != "${password/[A-Z]/_}" &&
49+
"${password}" != "${password/[a-z]/_}" &&
50+
"${password}" != "${password/[0-9]/_}" ]]; then
51+
export OGG_ADMIN_PWD="${password}"
52+
echo "----------------------------------------------------------------------------------"
53+
echo "-- Password for OGG administrative user '${OGG_ADMIN}' is '${OGG_ADMIN_PWD}'"
54+
echo "----------------------------------------------------------------------------------"
55+
return
56+
fi
57+
generatePassword
5858
}
5959

6060
##
6161
## Locate the Java installation and set JAVA_HOME
6262
##
6363
function locate_java() {
64-
[[ -n "${JAVA_HOME}" ]] && return 0
64+
[[ -n "${JAVA_HOME}" ]] && return 0
6565

66-
local java
67-
java=$(command -v java)
68-
[[ -z "${java}" ]] && abort "Java installation not found"
66+
local java
67+
java=$(command -v java)
68+
[[ -z "${java}" ]] && abort "Java installation not found"
6969

70-
JAVA_HOME="$(dirname "$(dirname "$(readlink -f "${java}")")")"
71-
export JAVA_HOME
70+
JAVA_HOME="$(dirname "$(dirname "$(readlink -f "${java}")")")"
71+
export JAVA_HOME
7272
}
7373

7474
##
7575
## Locate the shared library libjvm.so and set LD_LIBRARY_PATH
7676
##
7777
function locate_lib_jvm() {
78-
[[ -z "${JAVA_HOME}" ]] && abort "Java installation not found"
79-
80-
local libjvm
81-
libjvm="$(find "${JAVA_HOME}" -name libjvm.so | head -1)"
82-
if [ -z "${libjvm}" ]; then
83-
echo "Warning: The shared library libjvm.so cannot be located."
84-
else
85-
local JVM_LIBRARY_PATH
86-
JVM_LIBRARY_PATH="$(dirname "${libjvm}")"
87-
export LD_LIBRARY_PATH=$JVM_LIBRARY_PATH:$LD_LIBRARY_PATH
88-
fi
78+
[[ -z "${JAVA_HOME}" ]] && abort "Java installation not found"
79+
80+
local libjvm
81+
libjvm="$(find "${JAVA_HOME}" -name libjvm.so | head -1)"
82+
if [ -z "${libjvm}" ]; then
83+
echo "Warning: The shared library libjvm.so cannot be located."
84+
else
85+
local JVM_LIBRARY_PATH
86+
JVM_LIBRARY_PATH="$(dirname "${libjvm}")"
87+
export LD_LIBRARY_PATH=$JVM_LIBRARY_PATH:$LD_LIBRARY_PATH
88+
fi
8989
}
9090

9191
##
9292
## Return a string used for running a process as the 'ogg' user
9393
##
9494
function run_as_ogg() {
95-
local user="ogg"
96-
local uid gid
97-
uid="$(id -u "${user}")"
98-
gid="$(id -g "${user}")"
99-
echo "setpriv --ruid ${uid} --euid ${uid} --groups ${gid} --rgid ${gid} --egid ${gid} -- "
95+
local user="ogg"
96+
local uid gid
97+
uid="$(id -u "${user}")"
98+
gid="$(id -g "${user}")"
99+
echo "setpriv --ruid ${uid} --euid ${uid} --groups ${gid} --rgid ${gid} --egid ${gid} -- "
100100
}
101101

102102
##
103103
## Create and set permissions for directories for the deployment
104104
##
105105
function setup_deployment_directories() {
106-
rm -fr "${OGG_DEPLOYMENT_HOME}"/Deployment/var/{run,temp,lib/db} \
107-
"${OGG_TEMPORARY_FILES}"/{run,temp}
108-
mkdir -p "${OGG_TEMPORARY_FILES}"/{run,temp,db} \
109-
"${OGG_DEPLOYMENT_HOME}"/Deployment/var/lib
110-
ln -s "${OGG_TEMPORARY_FILES}"/run "${OGG_DEPLOYMENT_HOME}"/Deployment/var/run
111-
ln -s "${OGG_TEMPORARY_FILES}"/temp "${OGG_DEPLOYMENT_HOME}"/Deployment/var/temp
112-
ln -s "${OGG_TEMPORARY_FILES}"/db "${OGG_DEPLOYMENT_HOME}"/Deployment/var/lib/db
113-
114-
chown ogg:ogg "${OGG_DEPLOYMENT_HOME}" "${OGG_TEMPORARY_FILES}"
115-
chmod 0750 "${OGG_DEPLOYMENT_HOME}" "${OGG_TEMPORARY_FILES}"
116-
find "${OGG_DEPLOYMENT_HOME}" "${OGG_TEMPORARY_FILES}" -mindepth 1 -maxdepth 1 -not -name '.*' -exec \
117-
chown -R ogg:ogg {} \;
106+
rm -fr "${OGG_DEPLOYMENT_HOME}"/Deployment/var/{run,temp,lib/db} \
107+
"${OGG_TEMPORARY_FILES}"/{run,temp}
108+
mkdir -p "${OGG_TEMPORARY_FILES}"/{run,temp,db} \
109+
"${OGG_DEPLOYMENT_HOME}"/Deployment/var/lib
110+
ln -s "${OGG_TEMPORARY_FILES}"/run "${OGG_DEPLOYMENT_HOME}"/Deployment/var/run
111+
ln -s "${OGG_TEMPORARY_FILES}"/temp "${OGG_DEPLOYMENT_HOME}"/Deployment/var/temp
112+
ln -s "${OGG_TEMPORARY_FILES}"/db "${OGG_DEPLOYMENT_HOME}"/Deployment/var/lib/db
113+
114+
chown ogg:ogg "${OGG_DEPLOYMENT_HOME}" "${OGG_TEMPORARY_FILES}"
115+
chmod 0750 "${OGG_DEPLOYMENT_HOME}" "${OGG_TEMPORARY_FILES}"
116+
find "${OGG_DEPLOYMENT_HOME}" "${OGG_TEMPORARY_FILES}" -mindepth 1 -maxdepth 1 -not -name '.*' -exec \
117+
chown -R ogg:ogg {} \;
118118
}
119119

120120
##
121121
## Run custom scripts in the container before and after GoldenGate starts
122122
##
123123
function run_user_scripts {
124-
local scripts="${1}"
125-
while read -r script; do
126-
case "${script}" in
127-
*.sh)
128-
echo "Running script '${script}'"
129-
# shellcheck disable=SC1090
130-
source "${script}"
131-
;;
132-
*)
133-
echo "Ignoring '${script}'"
134-
;;
135-
esac
136-
done < <(find "${scripts}" -type f | sort)
124+
local scripts="${1}"
125+
while read -r script; do
126+
case "${script}" in
127+
*.sh)
128+
echo "Running script '${script}'"
129+
# shellcheck disable=SC1090
130+
source "${script}"
131+
;;
132+
*)
133+
echo "Ignoring '${script}'"
134+
;;
135+
esac
136+
done < <(find "${scripts}" -type f | sort)
137137
}
138138

139139
##
140140
## Initialize and start the OGG installation
141141
##
142142
function start_ogg() {
143-
$(run_as_ogg) python3 /usr/local/bin/deployment-init.py
144-
$(run_as_ogg) tail -F "${OGG_DEPLOYMENT_HOME}"/ServiceManager/var/log/ServiceManager.log &
145-
ogg_pid=$!
143+
$(run_as_ogg) python3 /usr/local/bin/deployment-init.py
144+
$(run_as_ogg) tail -F "${OGG_DEPLOYMENT_HOME}"/ServiceManager/var/log/ServiceManager.log &
145+
ogg_pid=$!
146146
}
147147

148148
##
149149
## Start the reverse proxy daemon
150150
##
151151
function start_nginx() {
152-
[[ ! -f "${NGINX_CRT}" || ! -f "${NGINX_KEY}" ]] && {
153-
/usr/local/bin/create-certificate.sh
154-
}
155-
replace-variables.sh /etc/nginx/*.conf
156-
/usr/sbin/nginx -t
157-
/usr/sbin/nginx
152+
[[ ! -f "${NGINX_CRT}" || ! -f "${NGINX_KEY}" ]] && {
153+
/usr/local/bin/create-certificate.sh
154+
}
155+
replace-variables.sh /etc/nginx/*.conf
156+
/usr/sbin/nginx -t
157+
/usr/sbin/nginx
158158
}
159159

160160
##
161161
## Termination handler
162162
##
163163
function termination_handler() {
164-
[[ -z "${ogg_pid}" ]] || {
165-
kill "${ogg_pid}"
166-
unset ogg_pid
167-
}
168-
[[ ! -f "/var/run/nginx.pid" ]] || {
169-
/usr/sbin/nginx -s stop
170-
}
171-
exit 0
164+
[[ -z "${ogg_pid}" ]] || {
165+
kill "${ogg_pid}"
166+
unset ogg_pid
167+
}
168+
[[ ! -f "/var/run/nginx.pid" ]] || {
169+
/usr/sbin/nginx -s stop
170+
}
171+
exit 0
172172
}
173173

174174
##
175175
## Signal Handling for this script
176176
##
177177
function signal_handling() {
178-
trap - SIGTERM SIGINT
179-
trap termination_handler SIGTERM SIGINT
178+
trap - SIGTERM SIGINT
179+
trap termination_handler SIGTERM SIGINT
180180
}
181181

182182
##

OracleGoldenGate/23/bin/healthcheck

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66
##
77

88
declare -A Ports=([nginx]=80
9-
[ServiceManager]=9011
10-
[adminsrvr]=9012
11-
[distsrvr]=9013
12-
[recvsrvr]=9014
13-
[pmsrvr]=9015)
9+
[ServiceManager]=9011
10+
[adminsrvr]=9012
11+
[distsrvr]=9013
12+
[recvsrvr]=9014
13+
[pmsrvr]=9015)
1414

1515
function service_healthy() {
16-
local serviceName="${1}" health healthy
17-
pgrep "${serviceName}" &>/dev/null || return 1
18-
health="$(curl -sf "http://127.0.0.1:${Ports[${serviceName}]}/services/v2/config/health/check")" || return 1
19-
healthy="$(echo "${health}" | jq -r .response.healthy)" || return 1
20-
[[ "${healthy}" == "true" ]]
16+
local serviceName="${1}" health healthy
17+
pgrep "${serviceName}" &>/dev/null || return 1
18+
health="$(curl -sf "http://127.0.0.1:${Ports[${serviceName}]}/services/v2/config/health/check")" || return 1
19+
healthy="$(echo "${health}" | jq -r .response.healthy)" || return 1
20+
[[ "${healthy}" == "true" ]]
2121
}
2222

2323
function deployment_healthy() {
24-
for key in "${!Ports[@]}"; do
25-
service_healthy "${key}" || return 1
26-
done
24+
for key in "${!Ports[@]}"; do
25+
service_healthy "${key}" || return 1
26+
done
2727
}
2828

2929
[[ -f /tmp/paused ]] || {
30-
deployment_healthy
30+
deployment_healthy
3131
}

0 commit comments

Comments
 (0)