33
44echo " Running Theta in mode: $THETA_MODE "
55
6+ # Ensure dirs exist
7+ mkdir -p /theta
8+ mkdir -p ~ /.thetacli
9+
10+ # Create password file (required for non-interactive Docker)
11+ PASSWORD_FILE=" /theta/password.txt"
12+ echo " $THETA_PASSWORD " > $PASSWORD_FILE
13+ chmod 600 $PASSWORD_FILE
14+
615start_cli () {
716 echo " Starting ThetaCli daemon on port 16889..."
817 thetacli daemon start --port=16889 &
918}
1019
20+ # Create wallet if it doesn't exist
21+ init_wallet () {
22+ if [ ! -d " /root/.thetacli/keys" ] || [ -z " $( ls -A /root/.thetacli/keys 2> /dev/null) " ]; then
23+ echo " No wallet found. Creating new wallet..."
24+ echo " $THETA_PASSWORD " | thetacli key new || true
25+ else
26+ echo " Wallet already exists. Skipping creation."
27+ fi
28+ }
29+
1130case " $THETA_MODE " in
1231
1332 privatenet)
14- echo " ⚡ PrivateNet setup..."
33+ echo " PrivateNet setup..."
1534
1635 mkdir -p /theta/privatenet
1736 cp -r /theta/theta/integration/privatenet /theta/ || true
@@ -20,27 +39,33 @@ case "$THETA_MODE" in
2039 cp -r /theta/theta/integration/privatenet/thetacli/* ~ /.thetacli/ || true
2140 chmod 700 ~ /.thetacli/keys/encrypted || true
2241
42+ init_wallet
2343 start_cli
2444
25- exec theta start --config=/theta/privatenet/node --password=$THETA_PASSWORD
45+ exec theta start \
46+ --config=/theta/privatenet/node \
47+ --password-file=$PASSWORD_FILE
2648 ;;
2749
2850 testnet)
29- echo " 🌐 TestNet setup..."
51+ echo " TestNet setup..."
3052
3153 mkdir -p /theta/testnet
3254 cp -r /theta/theta/integration/testnet/walletnode /theta/testnet || true
3355
3456 wget -O /theta/testnet/walletnode/snapshot \
3557 $( curl -k https://theta-testnet-backup.s3.amazonaws.com/snapshot/snapshot)
3658
59+ init_wallet
3760 start_cli
3861
39- exec theta start --config=/theta/testnet/walletnode
62+ exec theta start \
63+ --config=/theta/testnet/walletnode \
64+ --password-file=$PASSWORD_FILE
4065 ;;
4166
4267 mainnet)
43- echo " 🚀 MainNet setup..."
68+ echo " MainNet setup..."
4469
4570 mkdir -p /theta/mainnet/walletnode
4671
@@ -50,13 +75,16 @@ case "$THETA_MODE" in
5075 wget -O /theta/mainnet/walletnode/snapshot \
5176 $( curl -k https://mainnet-data.thetatoken.org/snapshot)
5277
78+ init_wallet
5379 start_cli
5480
55- exec theta start --config=/theta/mainnet/walletnode
81+ exec theta start \
82+ --config=/theta/mainnet/walletnode \
83+ --password-file=$PASSWORD_FILE
5684 ;;
5785
5886 * )
59- echo " ❌ Unknown mode: $THETA_MODE "
87+ echo " Unknown mode: $THETA_MODE "
6088 exit 1
6189 ;;
6290esac
0 commit comments