Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
138 changes: 85 additions & 53 deletions resources/scripts/quick_start.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/bash
set -euo pipefail

ERROR_CODE=0

is_cygwin_etal() {
uname -s | grep -qE "CYGWIN|MINGW|MSYS"
Expand All @@ -10,7 +11,7 @@ is_wsl() {
}
if is_cygwin_etal || is_wsl; then
echo "Quick start does not support Windows"
exit 1
ERROR_CODE=1
fi


Expand Down Expand Up @@ -44,48 +45,103 @@ print_partial_message() {
echo -e "${color}${pre_message}${format}${formatted_part}${RESET}${color}${post_message}${RESET}"
}

prompt_user() {
local prompt="$1"
tput bold # Make the prompt bold
echo "$prompt"
tput sgr0 # Reset formatting
}

print_message "" "" ""
print_message "" " ╭───────────────────────────────────╮" ""
print_message "" " │ Welcome to the Warnet Quickstart │" ""
print_message "" " ╰───────────────────────────────────╯" ""
print_message "" " ╭───────────────────────────╮" ""
print_message "" " │ Welcome to Warnet Setup │" ""
print_message "" " ╰───────────────────────────╯" ""
print_message "" "" ""
print_message "" " Let's find out if your system has what it takes to run Warnet..." ""
print_message "" "" ""

minikube_path=$(command -v minikube || true)
if [ -n "$minikube_path" ]; then
print_partial_message " ⭐️ Found " "minikube" ": $minikube_path " "$BOLD"
else
print_partial_message " 💥 Could not find " "minikube" ". Please follow this link to install it..." "$BOLD"
print_message "" " https://minikube.sigs.k8s.io/docs/start/" "$BOLD"
exit 127
prompt_user "Use [1] minikube (Default) or [2] docker-desktop? Enter 1 or 2: "
read -r choice

if [[ "$choice" == "1" || -z "$choice" ]]; then
choice=1
elif ! [[ "$choice" == "2" ]]; then
echo " Please enter 1 for minikube or 2 for docker-desktop."
exit 1
fi

kubectl_path=$(command -v kubectl || true)
if [ -n "$kubectl_path" ]; then
print_partial_message " ⭐️ Found " "kubectl" ": $kubectl_path " "$BOLD"
else
print_partial_message " 💥 Could not find " "kubectl" ". Please follow this link to install it..." "$BOLD"
print_message "" " https://kubernetes.io/docs/tasks/tools/" "$BOLD"
exit 127
if [[ "$choice" == "1" || -z "$choice" ]]; then
approach="minikube"
elif [[ "$choice" == "2" ]]; then
approach="docker-desktop"
fi

print_partial_message " ⭐️ You chose " ""$approach"" "." "$BOLD"

docker_path=$(command -v docker || true)
if [ -n "$docker_path" ]; then
print_partial_message " ⭐️ Found " "docker" ": $docker_path" "$BOLD"
else
print_partial_message " 💥 Could not find " "docker" ". Please follow this link to install Docker Engine..." "$BOLD"
print_message "" " https://docs.docker.com/engine/install/" "$BOLD"
exit 127
ERROR_CODE=127
fi

current_user=$(whoami)
if id -nG "$current_user" | grep -qw "docker"; then
print_partial_message " ⭐️ Found " "$current_user" " in the docker group" "$BOLD"
if [ -n "$docker_path" ]; then
current_context=$(docker context show)
if id -nG "$current_user" | grep -qw "docker"; then
print_partial_message " ⭐️ Found " "$current_user" " in the docker group" "$BOLD"
elif [ "$current_context" == "rootless" ]; then
print_message " " "⭐️ Docker is set to rootless" "$BOLD"
elif [[ "$(uname)" == "Darwin" ]]; then
print_message " " "⭐️ Found Docker on Darwin" "$BOLD"
else
print_partial_message " 💥 Could not find " "$current_user" " in the docker group. Please add it like this..." "$BOLD"
print_message "" " sudo usermod -aG docker $current_user && newgrp docker" "$BOLD"
ERROR_CODE=1
fi

if docker info >/dev/null 2>&1; then
print_partial_message " ⭐️" " Docker" " is running" "$BOLD"
else
print_message " " "💥 Docker is not running. Please start docker." "$BOLD"
ERROR_CODE=1
fi

if [[ "$approach" == "docker-desktop" && -n "$docker_path" ]]; then
if docker context ls | grep -q "docker-desktop"; then
print_message " ⭐️ Found " "Docker Desktop" "$BOLD"
else
print_partial_message " 💥 Could not find " "docker-desktop" ". Please follow this link to install it..." "$BOLD"
print_message "" " https://www.docker.com/products/docker-desktop/" "$BOLD"
ERROR_CODE=127
fi
fi
fi

if [[ "$approach" == "minikube" ]]; then
minikube_path=$(command -v minikube || true)
if [[ "$(uname)" == "Darwin" ]] && command -v minikube &> /dev/null && [[ "$(minikube version --short)" == "v1.33.1" ]]; then
print_partial_message " 💥 Could not find " "minikube version > 1.33.1" ". Please upgrade..." "$BOLD"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I saw this error too, I thought it was going to be OK to use docker desktop instead?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does docker context ls return?

Also, I have now added a check for Docker Desktop.

print_message "" " https://minikube.sigs.k8s.io/docs/start/" "$BOLD"
ERROR_CODE=127
elif [ -n "$minikube_path" ]; then
print_partial_message " ⭐️ Found " "minikube" ": $minikube_path " "$BOLD"
else
print_partial_message " 💥 Could not find " "minikube" ". Please follow this link to install it..." "$BOLD"
print_message "" " https://minikube.sigs.k8s.io/docs/start/" "$BOLD"
ERROR_CODE=127
fi
fi

kubectl_path=$(command -v kubectl || true)
if [ -n "$kubectl_path" ]; then
print_partial_message " ⭐️ Found " "kubectl" ": $kubectl_path " "$BOLD"
else
print_partial_message " 💥 Could not find " "$current_user" " in the docker group. Please add it like this..." "$BOLD"
print_message "" " sudo usermod -aG docker $current_user && newgrp docker" "$BOLD"
exit 1
print_partial_message " 💥 Could not find " "kubectl" ". Please follow this link to install it..." "$BOLD"
print_message "" " https://kubernetes.io/docs/tasks/tools/" "$BOLD"
ERROR_CODE=127
fi

helm_path=$(command -v helm || true)
Expand All @@ -94,7 +150,7 @@ if [ -n "$helm_path" ]; then
else
print_partial_message " 💥 Could not find " "helm" ". Please follow this link to install it..." "$BOLD"
print_message "" " https://helm.sh/docs/intro/install/" "$BOLD"
exit 127
ERROR_CODE=127
fi

just_path=$(command -v just || true)
Expand All @@ -103,34 +159,10 @@ if [ -n "$just_path" ]; then
else
print_partial_message " 💥 Could not find " "just" ". Please follow this link to install it..." "$BOLD"
print_message "" " https://github.com/casey/just?tab=readme-ov-file#pre-built-binaries" "$BOLD"
ERROR_CODE=127
fi

python_path=$(command -v python3 || true)
if [ -n "$python_path" ]; then
print_partial_message " ⭐️ Found " "python3" ": $python_path " "$BOLD"
else
print_partial_message " 💥 Could not find " "python3" ". Please follow this link to install it (or use your package manager)..." "$BOLD"
print_message "" " https://www.python.org/downloads/" "$BOLD"
exit 127
fi

if [ -n "$VIRTUAL_ENV" ]; then
print_partial_message " ⭐️ Running in virtual environment: " "$VIRTUAL_ENV" "$BOLD"
else
print_partial_message " 💥 Not running in a virtual environment. " "Please activate a venv before proceeding." "$BOLD"
exit 127
fi

bpf_status=$(grep CONFIG_BPF /boot/config-"$(uname -r)" || true)
if [ -n "$bpf_status" ]; then
config_bpf=$(echo "$bpf_status" | grep CONFIG_BPF=y)
if [ "$config_bpf" = "CONFIG_BPF=y" ]; then
print_partial_message " ⭐️ Found " "BPF" ": Berkeley Packet Filters appear enabled" "$BOLD"
else
print_partial_message " 💥 Could not find " "BPF" ". Please figure out how to enable Berkeley Packet Filters in your kernel." "$BOLD"
exit 1
fi
else
print_partial_message " 💥 Could not find " "BPF" ". Please figure out how to enable Berkeley Packet Filters in your kernel." "$BOLD"
exit 1
if [ $ERROR_CODE -ne 0 ]; then
print_message "" "There were errors in the setup process. Please fix them and try again." "$BOLD"
exit $ERROR_CODE
fi