Skip to content

Commit a6f1205

Browse files
authored
Merge pull request bitcoin-dev-project#369 from mplsgrant/2024-05-ez-startup
2 parents 0939d19 + aeb7fe6 commit a6f1205

File tree

2 files changed

+180
-0
lines changed

2 files changed

+180
-0
lines changed

justfile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ start:
3333
sleep 4
3434
done
3535

36+
echo "⏲️ This could take a minute or so."
3637
kubectl wait --for=condition=Ready --timeout=2m pod rpc-0
3738

3839
echo Done...

quick_start.sh

Lines changed: 179 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,179 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
5+
is_cygwin_etal() {
6+
uname -s | grep -qE "CYGWIN|MINGW|MSYS"
7+
}
8+
is_wsl() {
9+
grep -qEi "(Microsoft|WSL)" /proc/version &> /dev/null
10+
}
11+
if is_cygwin_etal || is_wsl; then
12+
echo "Quick start does not support Windows"
13+
exit 1
14+
fi
15+
16+
17+
# Colors and styles
18+
RESET='\033[0m'
19+
BOLD='\033[1m'
20+
21+
# Use colors if we can and have the color space
22+
if command -v tput &> /dev/null; then
23+
ncolors=$(tput colors)
24+
if [ -n "$ncolors" ] && [ "$ncolors" -ge 8 ]; then
25+
RESET=$(tput sgr0)
26+
BOLD=$(tput bold)
27+
fi
28+
fi
29+
30+
print_message() {
31+
local color="$1"
32+
local message="$2"
33+
local format="${3:-}"
34+
echo -e "${format}${color}${message}${RESET}"
35+
}
36+
37+
print_partial_message() {
38+
local pre_message="$1"
39+
local formatted_part="$2"
40+
local post_message="$3"
41+
local format="$4"
42+
local color="${5:-$RESET}"
43+
44+
echo -e "${color}${pre_message}${format}${formatted_part}${RESET}${color}${post_message}${RESET}"
45+
}
46+
47+
print_message "" "" ""
48+
print_message "" " ╭───────────────────────────────────╮" ""
49+
print_message "" " │ Welcome to the Warnet Quickstart │" ""
50+
print_message "" " ╰───────────────────────────────────╯" ""
51+
print_message "" "" ""
52+
print_message "" " Let's find out if your system has what it takes to run Warnet..." ""
53+
print_message "" "" ""
54+
55+
current_git=$(basename "$(git rev-parse --show-toplevel)" || true)
56+
if [ -n "$current_git" ]; then
57+
print_message "" " ⭐️ Currently in the warnet directory"
58+
else
59+
print_message "" " Please navigate to the warnet directory."
60+
exit 1
61+
fi
62+
63+
minikube_path=$(command -v minikube || true)
64+
if [ -n "$minikube_path" ]; then
65+
print_partial_message " ⭐️ Found " "minikube" ": $minikube_path " "$BOLD"
66+
else
67+
print_partial_message " 💥 Could not find " "minikube" ". Please follow this link to install it..." "$BOLD"
68+
print_message "" " https://minikube.sigs.k8s.io/docs/start/" "$BOLD"
69+
exit 127
70+
fi
71+
72+
kubectl_path=$(command -v kubectl || true)
73+
if [ -n "$kubectl_path" ]; then
74+
print_partial_message " ⭐️ Found " "kubectl" ": $kubectl_path " "$BOLD"
75+
else
76+
print_partial_message " 💥 Could not find " "kubectl" ". Please follow this link to install it..." "$BOLD"
77+
print_message "" " https://kubernetes.io/docs/tasks/tools/" "$BOLD"
78+
exit 127
79+
fi
80+
81+
docker_path=$(command -v docker || true)
82+
if [ -n "$docker_path" ]; then
83+
print_partial_message " ⭐️ Found " "docker" ": $docker_path" "$BOLD"
84+
else
85+
print_partial_message " 💥 Could not find " "docker" ". Please follow this link to install Docker Engine..." "$BOLD"
86+
print_message "" " https://docs.docker.com/engine/install/" "$BOLD"
87+
exit 127
88+
fi
89+
90+
current_user=$(whoami)
91+
if id -nG "$current_user" | grep -qw "docker"; then
92+
print_partial_message " ⭐️ Found " "$current_user" " in the docker group" "$BOLD"
93+
else
94+
print_partial_message " 💥 Could not find " "$current_user" " in the docker group. Please add it like this..." "$BOLD"
95+
print_message "" " sudo usermod -aG docker $current_user && newgrp docker" "$BOLD"
96+
exit 1
97+
fi
98+
99+
100+
just_path=$(command -v just || true)
101+
if [ -n "$just_path" ]; then
102+
print_partial_message " ⭐️ Found " "just" ": $just_path " "$BOLD"
103+
else
104+
print_partial_message " 💥 Could not find " "just" ". Please follow this link to install it..." "$BOLD"
105+
print_message "" " https://github.com/casey/just?tab=readme-ov-file#pre-built-binaries" "$BOLD"
106+
exit 127
107+
fi
108+
109+
python_path=$(command -v python3 || true)
110+
if [ -n "$python_path" ]; then
111+
print_partial_message " ⭐️ Found " "python3" ": $python_path " "$BOLD"
112+
else
113+
print_partial_message " 💥 Could not find " "python3" ". Please follow this link to install it (or use your package manager)..." "$BOLD"
114+
print_message "" " https://www.python.org/downloads/" "$BOLD"
115+
exit 127
116+
fi
117+
118+
venv_status=$(python3 -m venv --help || true)
119+
if [ -n "$venv_status" ]; then
120+
print_partial_message " ⭐️ Found " "venv" ": a python3 module" "$BOLD"
121+
else
122+
print_partial_message " 💥 Could not find " "venv" ". Please install it using your package manager." "$BOLD"
123+
exit 127
124+
fi
125+
126+
bpf_status=$(grep CONFIG_BPF /boot/config-"$(uname -r)" || true)
127+
if [ -n "$bpf_status" ]; then
128+
config_bpf=$(echo "$bpf_status" | grep CONFIG_BPF=y)
129+
if [ "$config_bpf" = "CONFIG_BPF=y" ]; then
130+
print_partial_message " ⭐️ Found " "BPF" ": Berkeley Packet Filters appear enabled" "$BOLD"
131+
else
132+
print_partial_message " 💥 Could not find " "BPF" ". Please figure out how to enable Berkeley Packet Filters in your kernel." "$BOLD"
133+
exit 1
134+
fi
135+
else
136+
print_partial_message " 💥 Could not find " "BPF" ". Please figure out how to enable Berkeley Packet Filters in your kernel." "$BOLD"
137+
exit 1
138+
fi
139+
140+
print_message "" "" ""
141+
print_message "" " Let's try to spin up a python virtual environment..." ""
142+
print_message "" "" ""
143+
144+
if [ -d ".venv" ]; then
145+
print_message "" " It looks like a virtual environment already exists!" ""
146+
else
147+
print_message "" " Creating a new virtual environment..." ""
148+
python3 -m venv .venv
149+
fi
150+
151+
source .venv/bin/activate
152+
153+
print_message "" "" ""
154+
print_partial_message " ⭐️ " "venv" ": The python virtual environment looks good" "$BOLD"
155+
print_message "" "" ""
156+
print_message "" " Let's install warnet into that virtual environment..." ""
157+
print_message "" "" ""
158+
159+
pip install --upgrade pip
160+
pip install -e .
161+
162+
print_message "" "" ""
163+
print_partial_message " ⭐️ " "warnet" ": We installed Warnet in the virtual environment" "$BOLD"
164+
print_message "" "" ""
165+
print_message "" " Now, let's get the Warnet started..." ""
166+
print_message "" "" ""
167+
168+
just start
169+
just p &
170+
sleep 1
171+
warcli network start
172+
sleep 1
173+
while warcli network connected | grep -q "False"; do
174+
sleep 2
175+
done
176+
print_message "" "🥳" ""
177+
print_message "" "Run the following command to enter into the python virtual environment..." ""
178+
print_message "" " source .venv/bin/activate" "$BOLD"
179+
print_partial_message " After that, you can run " "warcli help" " to start running Warnet commands." "$BOLD"

0 commit comments

Comments
 (0)