|
3 | 3 | set -e |
4 | 4 | mkdir -p /configuration |
5 | 5 | if [[ ! -f /configuration/pgpass ]]; then |
6 | | - gen-pgpass /run/secrets |
| 6 | + gen-pgpass /run/secrets |
7 | 7 | fi |
8 | 8 | export PGPASSFILE=/configuration/pgpass |
9 | 9 | mkdir -p -m 1777 /tmp |
10 | 10 | set -euo pipefail |
| 11 | + |
11 | 12 | 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 |
29 | 30 | fi |
30 | 31 |
|
31 | 32 | 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 "${@}" |
36 | 37 | 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 |
46 | 46 | fi |
0 commit comments