Skip to content

Commit 244aeed

Browse files
authored
fix: resolve unbound variable error in snapshot restoration
1 parent 9b5c5a0 commit 244aeed

File tree

1 file changed

+31
-31
lines changed

1 file changed

+31
-31
lines changed

bin/entry-point

Lines changed: 31 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3,44 +3,44 @@
33
set -e
44
mkdir -p /configuration
55
if [[ ! -f /configuration/pgpass ]]; then
6-
gen-pgpass /run/secrets
6+
gen-pgpass /run/secrets
77
fi
88
export PGPASSFILE=/configuration/pgpass
99
mkdir -p -m 1777 /tmp
1010
set -euo pipefail
11+
1112
if [[ ! -z ${RESTORE_SNAPSHOT:-} ]]; then
12-
__base=$(basename ${RESTORE_SNAPSHOT})
13-
__mark=${__base}.restored
14-
if [[ ! -f ${RESTORED_MARKER} ]]; then
15-
if [[ ${RESTORE_SNAPSHOT} =~ ^https://.* ]]; then
16-
echo "Downloading snapshot ${RESTORE_SNAPSHOT} ..."
17-
curl -LOC - "${RESTORE_SNAPSHOT}"
18-
curl -LO "${RESTORE_SNAPSHOT}.sha256sum"
19-
sha256sum -c "${__base}.sha256sum"
20-
__snap=${__base}
21-
else
22-
__snap=${RESTORE_SNAPSHOT}
23-
fi
24-
rm -f /var/lib/cexplorer/*.lstate
25-
postgresql-setup.sh --restore-snapshot ${__snap} /var/lib/cexplorer
26-
touch ${RESTORED_MARKER}
27-
rm -f ${__snap}{,.sha256sum,.asc}
28-
fi
13+
__base=$(basename "${RESTORE_SNAPSHOT}")
14+
__mark="${__base}.restored"
15+
if [[ ! -f "${__mark}" ]]; then
16+
if [[ "${RESTORE_SNAPSHOT}" =~ ^https://.* ]]; then
17+
echo "Downloading snapshot ${RESTORE_SNAPSHOT} ..."
18+
curl -LOC - "${RESTORE_SNAPSHOT}"
19+
curl -LO "${RESTORE_SNAPSHOT}.sha256sum"
20+
sha256sum -c "${__base}.sha256sum"
21+
__snap="${__base}"
22+
else
23+
__snap="${RESTORE_SNAPSHOT}"
24+
fi
25+
rm -f /var/lib/cexplorer/*.lstate
26+
postgresql-setup.sh --restore-snapshot "${__snap}" /var/lib/cexplorer
27+
touch "${__mark}"
28+
rm -f "${__snap}"{,.sha256sum,.asc}
29+
fi
2930
fi
3031

3132
if [[ -z ${NETWORK} ]]; then
32-
echo "Connecting to network specified in configuration.yaml"
33-
exec cardano-db-sync \
34-
--schema-dir /opt/cardano/schema \
35-
--state-dir /var/lib/cexplorer ${@}
33+
echo "Connecting to network specified in configuration.yaml"
34+
exec cardano-db-sync \
35+
--schema-dir /opt/cardano/schema \
36+
--state-dir /var/lib/cexplorer "${@}"
3637
else
37-
echo "Connecting to network: ${NETWORK}"
38-
export CARDANO_NODE_SOCKET_PATH=${CARDANO_NODE_SOCKET_PATH:-/node-ipc/node.socket}
39-
mkdir -p log-dir # do we need this?
40-
exec cardano-db-sync \
41-
--config /opt/cardano/config/${NETWORK}/db-sync-config.json \
42-
--schema-dir /opt/cardano/schema \
43-
--socket-path ${CARDANO_NODE_SOCKET_PATH} \
44-
--state-dir /var/lib/cexplorer
45-
38+
echo "Connecting to network: ${NETWORK}"
39+
export CARDANO_NODE_SOCKET_PATH="${CARDANO_NODE_SOCKET_PATH:-/node-ipc/node.socket}"
40+
mkdir -p log-dir
41+
exec cardano-db-sync \
42+
--config "/opt/cardano/config/${NETWORK}/db-sync-config.json" \
43+
--schema-dir /opt/cardano/schema \
44+
--socket-path "${CARDANO_NODE_SOCKET_PATH}" \
45+
--state-dir /var/lib/cexplorer
4646
fi

0 commit comments

Comments
 (0)