Skip to content

Commit 311efca

Browse files
committed
add quick_start
make `shellcheck -x` happy
1 parent 0939d19 commit 311efca

File tree

2 files changed

+160
-0
lines changed

2 files changed

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

0 commit comments

Comments
 (0)