2024-04-05 19:06:25 +01:00
|
|
|
#!/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
|
|
|
|
|
2024-04-12 15:56:40 +01:00
|
|
|
# Check whether running docker desktop or minikube.
|
2024-04-05 19:06:25 +01:00
|
|
|
docker_info=$(docker info)
|
2024-04-12 15:48:49 +01:00
|
|
|
if grep -q "Operating System:.*Desktop" <<< "$docker_info"; then
|
2024-04-12 15:56:40 +01:00
|
|
|
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."
|
2024-04-05 19:06:25 +01:00
|
|
|
just startd
|
|
|
|
else
|
2024-04-15 16:50:21 +01:00
|
|
|
echo "Starting warnet for Minikube."
|
2024-04-05 19:06:25 +01:00
|
|
|
just start
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Port forward for warcli
|
|
|
|
echo "Port forwarding from kubernetes to warnet cluster for warcli (don't close this!)"
|
|
|
|
just p
|