forked from percona/percona-postgresql-operator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall-extensions.sh
executable file
·47 lines (39 loc) · 961 Bytes
/
install-extensions.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
#!/bin/bash
set -e
set -o xtrace
IFS=',' read -ra extensions <<<"$INSTALL_EXTENSIONS"
declare -a args=(
-type "${STORAGE_TYPE}"
-region "${STORAGE_REGION}"
-bucket "${STORAGE_BUCKET}"
-extension-path "${PGDATA_EXTENSIONS}"
)
if [[ -n $STORAGE_ENDPOINT ]]; then
args+=(-endpoint "$STORAGE_ENDPOINT")
fi
for key in "${extensions[@]}"; do
if [ -f "${PGDATA_EXTENSIONS}"/"${key}".installed ]; then
echo "Extension ${key} already installed"
continue
fi
echo "Installing extension: ${key}"
/usr/local/bin/extension-installer \
"${args[@]}" \
-key "${key}" \
-install
done
for installed in "${PGDATA_EXTENSIONS}"/*.installed; do
filename=$(basename -- "${installed}")
key=${filename%.*}
if [[ ${key} == "*" ]]; then
continue
fi
if [[ ! ${extensions[*]} =~ ${key} ]]; then
echo "Uninstalling extension: ${key}"
/usr/local/bin/extension-installer \
"${args[@]}" \
-key "${key}" \
-uninstall
rm -f "${installed}"
fi
done