Skip to content

Commit

Permalink
chore: add startup scripts for different environments
Browse files Browse the repository at this point in the history
  • Loading branch information
PhearZero committed Oct 24, 2024
1 parent 4e48c39 commit 62ee30c
Show file tree
Hide file tree
Showing 7 changed files with 174 additions and 259 deletions.
251 changes: 0 additions & 251 deletions .docker/run.sh

This file was deleted.

24 changes: 24 additions & 0 deletions .docker/start_all.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#!/usr/bin/env bash

set -e

if [ "$DEBUG" = "1" ]; then
set -x
fi

if [ "$ALGORAND_DATA" != "/algod/data" ]; then
echo "Do not override 'ALGORAND_DATA' environment variable."
exit 1
fi
# To allow mounting the data directory we need to change permissions
# to our algorand user. The script is initially run as the root user
# in order to change permissions, afterwards the script is re-launched
# as the algorand user.
if [ "$(id -u)" = '0' ]; then
chown -R algorand:algorand $ALGORAND_DATA
exec su -p -c "$(readlink -f $0) $@" algorand
fi

/node/run/start_empty.sh &
/node/run/start_fast_catchup.sh &
/node/run/start_dev.sh
39 changes: 39 additions & 0 deletions .docker/start_dev.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/usr/bin/env bash

set -e

if [ "$DEBUG" = "1" ]; then
set -x
fi

if [ "$ALGORAND_DATA" != "/algod/data" ]; then
echo "Do not override 'ALGORAND_DATA' environment variable."
exit 1
fi

# To allow mounting the data directory we need to change permissions
# to our algorand user. The script is initially run as the root user
# in order to change permissions, afterwards the script is re-launched
# as the algorand user.
if [ "$(id -u)" = '0' ]; then
chown -R algorand:algorand "$ALGORAND_DATA"
exec su -p -c "$(readlink -f $0) $@" algorand
fi


# Configure the participation node
if [ -d "$ALGORAND_DATA" ]; then
if [ "$TOKEN" != "" ]; then
echo "$TOKEN" > "$ALGORAND_DATA/algod.token"
fi
if [ "$ADMIN_TOKEN" != "" ]; then
echo "$ADMIN_TOKEN" > "$ALGORAND_DATA/algod.admin.token"
fi
cd "$ALGORAND_DATA"
cp "/node/run/genesis/testnet/genesis.json" genesis.json
algocfg profile set --yes -d "$ALGORAND_DATA" "participation"
algod -o -d $ALGORAND_DATA -l "0.0.0.0:8080"
else
echo "$ALGORAND_DATA" does not exist
exit 1
fi
41 changes: 41 additions & 0 deletions .docker/start_empty.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/usr/bin/env bash

set -e

if [ "$DEBUG" = "1" ]; then
set -x
fi

if [ "$ALGORAND_DATA" != "/algod/data" ]; then
echo "Do not override 'ALGORAND_DATA' environment variable."
exit 1
fi

EMPTY_DATA=/algod/empty

# To allow mounting the data directory we need to change permissions
# to our algorand user. The script is initially run as the root user
# in order to change permissions, afterwards the script is re-launched
# as the algorand user.
if [ "$(id -u)" = '0' ]; then
chown -R algorand:algorand $EMPTY_DATA
exec su -p -c "$(readlink -f $0) $@" algorand
fi


# Configure the participation node
if [ -d "$EMPTY_DATA" ]; then
if [ "$TOKEN" != "" ]; then
echo "$TOKEN" > "$EMPTY_DATA/algod.token"
fi
if [ "$ADMIN_TOKEN" != "" ]; then
echo "$ADMIN_TOKEN" > "$EMPTY_DATA/algod.admin.token"
fi
cd $EMPTY_DATA
cp "/node/run/genesis/testnet/genesis.json" genesis.json
algocfg profile set --yes -d "$EMPTY_DATA" "participation"
algod -o -d $EMPTY_DATA -l "0.0.0.0:8082"
else
echo $EMPTY_DATA does not exist
exit 1
fi
Loading

0 comments on commit 62ee30c

Please sign in to comment.