Skip to content

Commit 97a422d

Browse files
committed
chore: add startup scripts for different environments
1 parent 8c8cfca commit 97a422d

File tree

7 files changed

+174
-259
lines changed

7 files changed

+174
-259
lines changed

.docker/run.sh

Lines changed: 0 additions & 251 deletions
This file was deleted.

.docker/start_all.sh

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ "$DEBUG" = "1" ]; then
6+
set -x
7+
fi
8+
9+
if [ "$ALGORAND_DATA" != "/algod/data" ]; then
10+
echo "Do not override 'ALGORAND_DATA' environment variable."
11+
exit 1
12+
fi
13+
# To allow mounting the data directory we need to change permissions
14+
# to our algorand user. The script is initially run as the root user
15+
# in order to change permissions, afterwards the script is re-launched
16+
# as the algorand user.
17+
if [ "$(id -u)" = '0' ]; then
18+
chown -R algorand:algorand $ALGORAND_DATA
19+
exec su -p -c "$(readlink -f $0) $@" algorand
20+
fi
21+
22+
/node/run/start_empty.sh &
23+
/node/run/start_fast_catchup.sh &
24+
/node/run/start_dev.sh

.docker/start_dev.sh

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ "$DEBUG" = "1" ]; then
6+
set -x
7+
fi
8+
9+
if [ "$ALGORAND_DATA" != "/algod/data" ]; then
10+
echo "Do not override 'ALGORAND_DATA' environment variable."
11+
exit 1
12+
fi
13+
14+
# To allow mounting the data directory we need to change permissions
15+
# to our algorand user. The script is initially run as the root user
16+
# in order to change permissions, afterwards the script is re-launched
17+
# as the algorand user.
18+
if [ "$(id -u)" = '0' ]; then
19+
chown -R algorand:algorand "$ALGORAND_DATA"
20+
exec su -p -c "$(readlink -f $0) $@" algorand
21+
fi
22+
23+
24+
# Configure the participation node
25+
if [ -d "$ALGORAND_DATA" ]; then
26+
if [ "$TOKEN" != "" ]; then
27+
echo "$TOKEN" > "$ALGORAND_DATA/algod.token"
28+
fi
29+
if [ "$ADMIN_TOKEN" != "" ]; then
30+
echo "$ADMIN_TOKEN" > "$ALGORAND_DATA/algod.admin.token"
31+
fi
32+
cd "$ALGORAND_DATA"
33+
cp "/node/run/genesis/testnet/genesis.json" genesis.json
34+
algocfg profile set --yes -d "$ALGORAND_DATA" "participation"
35+
algod -o -d $ALGORAND_DATA -l "0.0.0.0:8080"
36+
else
37+
echo "$ALGORAND_DATA" does not exist
38+
exit 1
39+
fi

.docker/start_empty.sh

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
if [ "$DEBUG" = "1" ]; then
6+
set -x
7+
fi
8+
9+
if [ "$ALGORAND_DATA" != "/algod/data" ]; then
10+
echo "Do not override 'ALGORAND_DATA' environment variable."
11+
exit 1
12+
fi
13+
14+
EMPTY_DATA=/algod/empty
15+
16+
# To allow mounting the data directory we need to change permissions
17+
# to our algorand user. The script is initially run as the root user
18+
# in order to change permissions, afterwards the script is re-launched
19+
# as the algorand user.
20+
if [ "$(id -u)" = '0' ]; then
21+
chown -R algorand:algorand $EMPTY_DATA
22+
exec su -p -c "$(readlink -f $0) $@" algorand
23+
fi
24+
25+
26+
# Configure the participation node
27+
if [ -d "$EMPTY_DATA" ]; then
28+
if [ "$TOKEN" != "" ]; then
29+
echo "$TOKEN" > "$EMPTY_DATA/algod.token"
30+
fi
31+
if [ "$ADMIN_TOKEN" != "" ]; then
32+
echo "$ADMIN_TOKEN" > "$EMPTY_DATA/algod.admin.token"
33+
fi
34+
cd $EMPTY_DATA
35+
cp "/node/run/genesis/testnet/genesis.json" genesis.json
36+
algocfg profile set --yes -d "$EMPTY_DATA" "participation"
37+
algod -o -d $EMPTY_DATA -l "0.0.0.0:8082"
38+
else
39+
echo $EMPTY_DATA does not exist
40+
exit 1
41+
fi

0 commit comments

Comments
 (0)