-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathentrypoint.sh
More file actions
64 lines (56 loc) · 2.01 KB
/
entrypoint.sh
File metadata and controls
64 lines (56 loc) · 2.01 KB
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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#!/usr/bin/env bash
#Author: MRColorR
# Load BITPING_EMAIL and BITPING_PASSWD from environment variables
# BITPING_EMAIL and BITPING_PASSWD are set in the Dockerfile
# BITPING_EMAIL and BITPING_PASSWD are set in the docker-compose.yml file
# BITPING_EMAIL and BITPING_PASSWD are set in the .env file
# Function to perform Bitping auto login
performLogin() {
expect -c "
spawn bitpingd login
expect \"Email:\"
sleep [expr {rand()*3}]
send \"$BITPING_EMAIL\r\"
expect \"Password:\"
sleep [expr {rand()*3}]
send \"$BITPING_PASSWD\r\"
expect eof
"
# Check login status
local LOGIN_STATUS=$?
if [ $LOGIN_STATUS -ne 0 ]; then
echo "Auto Login failed"
exit 1
fi
}
# Check if Bitping NODE_DB_PATH is set in the environment if not tell it and use the default
if [ -z "$NODE_DB_PATH" ]; then
echo "NODE_DB_PATH is not set. Using default path"
NODE_DB_PATH="/root/.bitping/node.db"
fi
# Check if BITPING_EMAIL and BITPING_PASSWD have been passed in
if [ -z "$BITPING_EMAIL" ] || [ -z "$BITPING_PASSWD" ]; then
echo "BITPING_EMAIL and BITPING_PASSWD must be set as environment variables"
exit 1
fi
# Check if the user is already logged in by examining if the node.db exists and if the email is in the node.db
if [ -f "$NODE_DB_PATH" ]; then
# Check if email is already in the node.db
if grep -q "$BITPING_EMAIL" "$NODE_DB_PATH"; then
echo "User already logged in with $BITPING_EMAIL"
else
# Perform login
echo "User not logged in with $BITPING_EMAIL but $NODE_DB_PATH exists. Performing login as $BITPING_EMAIL"
performLogin
echo "Login function completed"
fi
else
echo "$NODE_DB_PATH does not exist. Creating $NODE_DB_PATH by performing a fresh login as $BITPING_EMAIL"
performLogin
echo "Login function completed"
fi
## Change the refresh interval to 1 minute to reduce logging
bitpingd config refresh-interval 60sec
# Start Supervisor
mkdir -p /var/log/supervisor/children
exec supervisord -c /etc/supervisord.conf