forked from kevkevinpal/attackathon
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart_warnet.sh
executable file
·57 lines (47 loc) · 1.34 KB
/
start_warnet.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
#!/bin/bash
# Function to check if a command is available
check_command() {
if ! command -v "$1" &> /dev/null; then
echo "Error: $1 is not installed."
exit 1
fi
}
check_command just
check_command docker
if [ ! -d "warnet" ]; then
git clone https://github.com/bitcoin-dev-project/warnet
fi
cd warnet
if [ -n "$(git status --porcelain)" ]; then
echo "There are uncommitted changes in warnet, please stash them!"
exit 1
fi
# Check whether running docker desktop or minikube.
docker_info=$(docker info)
if grep -q "Operating System:.*Desktop" <<< "$docker_info"; then
docker_desktop=true
else
docker_desktop=false
fi
# Only ask this question once, otherwise it's annoying.
if [ "$docker_desktop" = true ]; then
echo "Detected docker desktop running."
else
echo "Detected minikube running."
fi
read -p "Is this correct (y/n): " confirm
if [ "$confirm" != "y" ]; then
echo "Unable to detect kubernetes platform - please open an issue with the output of $ docker info"
exit 1
fi
# Check Docker info and start accordingly
if [ "$docker_desktop" = true ]; then
echo "Starting warnet for Docker Desktop."
just startd
else
echo "Starting warnet for Minikube."
just start
fi
# Port forward for warcli
echo "Port forwarding from kubernetes to warnet cluster for warcli (don't close this!)"
just p