forked from SunStake/docker-java-tron
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathstart.sh
executable file
·41 lines (30 loc) · 1.16 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
#!/bin/bash
source .env
# check if MONGO_INITDB_ROOT_PASSWORD in .env is empty or doesnt exist
if [ -z "$MONGO_INITDB_ROOT_PASSWORD" ]; then
echo "[CREDENTIALS] Unsafe credentials detected. Generating new credentials..."
MONGO_INITDB_ROOT_USERNAME=root
MONGO_INITDB_ROOT_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13)
DB_USER=tron
DB_PASSWORD=$(tr -dc A-Za-z0-9 </dev/urandom | head -c 13)
# Credentials:
echo "MongoDB ROOT credentials: $MONGO_INITDB_ROOT_USERNAME:$MONGO_INITDB_ROOT_PASSWORD"
echo "MongoDB USER credentials: $DB_USER:$DB_PASSWORD"
echo "Writing credentials to .env file..."
# Emptying .env file before writing new credentials
:> .env
# Writing credentials to .env file
echo "MONGO_INITDB_ROOT_USERNAME=$MONGO_INITDB_ROOT_USERNAME" >> .env
echo "MONGO_INITDB_ROOT_PASSWORD=$MONGO_INITDB_ROOT_PASSWORD" >> .env
echo "DB_USER=$DB_USER" >> .env
echo "DB_PASSWORD=$DB_PASSWORD" >> .env
fi
echo "---"
echo "Initializing storage..."
mkdir -p ./data/mongod
mkdir -p ./data/node
echo "---"
echo "Starting Tron Node..."
echo "[MAINNET]"
# Start Tron Node
docker compose up -d