-
Notifications
You must be signed in to change notification settings - Fork 132
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: adds container image for jormungandr
- Loading branch information
Showing
2 changed files
with
112 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
#!/usr/bin/bash | ||
|
||
echo ">>> Entering entrypoint script..." | ||
|
||
# Verify the storage path exists | ||
if [[ ! -d "$STORAGE_PATH" ]]; then | ||
echo "ERROR: storage path does not exist at: $STORAGE_PATH" | ||
echo ">>> Aborting..." | ||
exit 1 | ||
fi | ||
|
||
# Verify config is present | ||
if [[ ! -f "$NODE_CONFIG_PATH" ]]; then | ||
echo "ERROR: node configuration is absent at: $NODE_CONFIG_PATH" | ||
echo ">>> Aborting..." | ||
exit 1 | ||
fi | ||
|
||
# Verify genesis block is present | ||
if [[ ! -f "$GENESIS_PATH" ]]; then | ||
echo "ERROR: genesis block is absent at: $GENESIS_PATH" | ||
echo ">>> Aborting..." | ||
exit 1 | ||
fi | ||
|
||
# Allow overriding jormungandr binary | ||
BIN_PATH=''${BIN_PATH:=/app/jormungandr} | ||
|
||
echo ">>> Using the following parameters:" | ||
echo "Storage path: $STORAGE_PATH" | ||
echo "Node config: $NODE_CONFIG_PATH" | ||
echo "Genesis block: $GENESIS_PATH" | ||
echo "Binary path: $BIN_PATH" | ||
|
||
args+=() | ||
args+=("--storage" "$STORAGE_PATH") | ||
args+=("--config" "$NODE_CONFIG_PATH") | ||
args+=("--genesis-block" "$GENESIS_PATH") | ||
|
||
if [[ -n "${LEADER:=}" ]]; then | ||
echo ">>> Configuring node as leader..." | ||
|
||
# shellcheck disable=SC2153 | ||
if [[ ! -f "$BFT_PATH" ]]; then | ||
echo "ERROR: BFT is absent at: $BFT_PATH" | ||
echo ">>> Aborting..." | ||
exit 1 | ||
fi | ||
|
||
echo ">>> Using BFT at: $BFT_PATH" | ||
args+=("--secret" "$BFT_PATH") | ||
fi | ||
|
||
# Nodes will fail to start if they cannot resolve the domain names of | ||
# their respective peers. If domains are used for peers, it's necessary | ||
# to wait for them to resolve first before starting the node. | ||
if [[ -n "${DNS_PEERS:=}" ]]; then | ||
for PEER in $DNS_PEERS; do | ||
while ! nslookup "$PEER"; do | ||
echo ">>> Waiting for $PEER to be resolvable..." | ||
sleep 1 | ||
done | ||
echo "Successfully resolved $PEER" | ||
done | ||
fi | ||
|
||
# Allows resetting our footprint in persistent storage | ||
if [[ -f "$STORAGE_PATH/reset" ]]; then | ||
echo ">>> Reset file detected at $STORAGE_PATH/reset" | ||
rm -rf "$STORAGE_PATH/reset" | ||
|
||
if [[ -d "$STORAGE_PATH/fragments" ]]; then | ||
echo ">>> Deleting $STORAGE_PATH/fragments" | ||
rm -rf "$STORAGE_PATH/fragments" | ||
fi | ||
|
||
if [[ -d "$STORAGE_PATH/permanent" ]]; then | ||
echo ">>> Deleting $STORAGE_PATH/permanent" | ||
rm -rf "$STORAGE_PATH/permanent" | ||
fi | ||
|
||
if [[ -d "$STORAGE_PATH/volatile" ]]; then | ||
echo ">>> Deleting $STORAGE_PATH/volatile" | ||
rm -rf "$STORAGE_PATH/volatile" | ||
fi | ||
|
||
echo ">>> Reset complete" | ||
fi | ||
|
||
echo "Starting node..." | ||
exec "$BIN_PATH" "${args[@]}" |