forked from volaradlp/minercli
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun_docker.sh
executable file
·135 lines (115 loc) · 3.92 KB
/
run_docker.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
echo -e "
@@@ @@@
@@@@@@ @@@@@@
@@@@@@@@@ @@@@@@@@@
@@ @@@@@@@@ @@@@@@@@ @@
@@@@@ @@@@@@@@ @@@@@@@ @@@@
@@@@@@@@ @@@@@@ @@@@@@@ @@@@@@@
@@@@@@ @@@@@@@ @@@@@@@@@
@@@@@ @@@@@@ @@@@@ @@@@@@ @@@@
@@@@ @@@ @ @@@@@ @@@@ @@@@@@ @@@@@
@@@ @@ @@ @ @@@@@ @@@@ @@@@@ @@@@@@
@@ @@ @@ @@@ @@@@ @@@ @@@@ @@@@@@@ @@
@ @@ @@ @@ @ @@@@@@ @@@@@@@ @@@@@
@@ @@ @@ @@ @@@@ @@@@@@ @@@@@@@
@@ @@ @@@ @@ @ @@@@@@@@@@@
@@@ @@@ @@@ @@@@@ @@@
@@ @@ @@ @@@@ @@@@@@@@@@@
@ @@ @@ @@@@@@
@@@ @@@@ @@@@@@@@@
@@ @@@@@
@@@ @@@@@@@@
@@@@@
@@@@
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
▗▖ ▗▖ ▗▄▖ ▗▖ ▗▄▖ ▗▄▄▖ ▗▄▖
▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌
▐▌ ▐▌▐▌ ▐▌▐▌ ▐▛▀▜▌▐▛▀▚▖▐▛▀▜▌
▝▚▞▘ ▝▚▄▞▘▐▙▄▄▖▐▌ ▐▌▐▌ ▐▌▐▌ ▐▌
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"
CONTAINER_NAME="volara_miner"
# Function to check if the container exists
container_exists() {
sudo docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"
}
# Function to check if the container is running
is_container_running() {
sudo docker ps --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"
}
# Function to run the container if it doesn't exist
run_container() {
echo "Running ${CONTAINER_NAME} container interactively..."
sudo docker run -it -e VANA_PRIVATE_KEY=${VANA_PRIVATE_KEY} --name ${CONTAINER_NAME} volara/miner
}
# Function to start the container if it exists but is not running
start_container() {
echo "Starting ${CONTAINER_NAME} container interactively..."
sudo docker start -i ${CONTAINER_NAME}
}
# Function to attach to a running container
attach_container() {
echo "Attaching to ${CONTAINER_NAME} container..."
sudo docker attach --sig-proxy=false ${CONTAINER_NAME}
}
BOLD=$(tput bold)
NORMAL=$(tput sgr0)
PINK='\033[1;35m'
show() {
case $2 in
"error")
echo -e "${PINK}${BOLD}❌ $1${NORMAL}"
;;
"progress")
echo -e "${PINK}${BOLD}⏳ $1${NORMAL}"
;;
*)
echo -e "${PINK}${BOLD}✅ $1${NORMAL} "
;;
esac
}
check_docker_installed() {
if command -v docker >/dev/null 2>&1; then
show "Docker is already installed."
return 0
else
return 1
fi
}
pull_volara_image() {
show "Pulling Volara image..." "progress"
sudo docker pull volara/miner > /dev/null 2>&1
show "Volara image pulled successfully."
}
install_docker() {
show "Installing Docker..." "progress"
source <(wget -O - "https://raw.githubusercontent.com/zunxbt/installation/98a351c5ff781415cbb9f1a250a6d2699cb814c7/docker.sh")
}
prompt_user_input() {
read -p "Enter your burner wallet's private key: " VANA_PRIVATE_KEY
}
run_docker_containers() {
if ! container_exists; then
run_container
elif ! is_container_running; then
start_container
else
echo "${CONTAINER_NAME} container is already running."
attach_container
fi
# Trap to handle SIGINT (Ctrl+C) gracefully
trap 'echo "Detached from container. To stop it, use: docker stop ${CONTAINER_NAME}"; exit' SIGINT
# Keep the script running to maintain the container connection
while true; do
sleep 1
done
}
if ! check_docker_installed; then
install_docker
fi
pull_volara_image
prompt_user_input
show "Running Docker containers..." "progress"
run_docker_containers
echo