Skip to content

Commit 3337fd7

Browse files
committed
Fix entrypoint commands
1 parent 9ba2cb9 commit 3337fd7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

entrypoint.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#!/bin/bash
12
set -euo pipefail
23

34
### generate pgpass file
@@ -31,6 +32,12 @@ then
3132

3233

3334
DB_MAX_BLOCK=$(psql -h $PGHOST $PGDATABASE -U $PGUSER -t -c 'select max (block_no) from block;')
35+
# Ensure DB_MAX_BLOCK is a valid integer, if not, exit with an error
36+
if ! [[ "$DB_MAX_BLOCK" =~ ^[0-9]+$ ]]; then
37+
echo "Block in db:" $DB_MAX_BLOCK
38+
DB_MAX_BLOCK=0
39+
exit 1
40+
fi
3441
NODE_CUR_BLOCK=0
3542
while [ $NODE_CUR_BLOCK -lt $DB_MAX_BLOCK ]; do
3643
NODE_STATUS="$(cardano-cli query tip --mainnet 2>/dev/null || true)"
@@ -54,7 +61,7 @@ CONFIG_HOME="/environments"
5461
if [ -z "${NETWORK:-}" ]; then
5562
echo "NETWORK is not set, defaulting to mainnet"
5663
NETWORK="mainnet"
57-
NO_NETWORK_SET=1
64+
NO_NETWORK_SET="1"
5865
else
5966
echo "NETWORK is set to $NETWORK"
6067
fi
@@ -76,7 +83,7 @@ fi
7683
if [[ -z "${DB_SYNC_CONFIG:-}" ]]; then
7784
DB_SYNC_CONFIG="$CONFIG_HOME/$NETWORK"
7885

79-
elif [[ -z "${NO_NETWORK_SET}" ]]; then # dbsync config is set and network is not
86+
elif [[ -z "${NO_NETWORK_SET:-}" ]]; then # dbsync config is set and network is not
8087
DB_SYNC_CONFIG="$CONFIG_HOME"
8188

8289
else ## both NETWORK and DB_SYNC_CONFIG are set
@@ -90,7 +97,7 @@ else ## both NETWORK and DB_SYNC_CONFIG are set
9097
fi
9198

9299

93-
SCHEMA_DIR=$(find /nix/store -name -type d '*-schema')}
100+
SCHEMA_DIR=$(find /nix/store -name '*-schema')}
94101

95102
exec cardano-db-sync \
96103
--config "$DB_SYNC_CONFIG" \

0 commit comments

Comments
 (0)