From 75c606c2342c6db852c25b16c1a160d5a051ead4 Mon Sep 17 00:00:00 2001 From: Sylvain Bellemare Date: Fri, 3 May 2024 00:31:16 -0400 Subject: [PATCH] Check if docker is installed --- hacking/Makefile | 17 ++++++++++++++++- hacking/scripts/check-docker.sh | 8 ++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 hacking/scripts/check-docker.sh diff --git a/hacking/Makefile b/hacking/Makefile index 58a9df17d..c013ba71b 100644 --- a/hacking/Makefile +++ b/hacking/Makefile @@ -1,5 +1,7 @@ VERBOSE ?= 0 COMPOSE_FILE ?= compose.yml +DOCKER_MISSING := $(shell ./scripts/check-docker.sh) +DOCKER_VERSION := $(shell docker -v) .DEFAULT_GOAL := help @@ -7,6 +9,9 @@ COMPOSE_FILE ?= compose.yml ##@ Local network management commands ##@ start: ##@ Start local network +ifeq ($(DOCKER_MISSING),1) + $(error Docker is not installed. Please install docker before proceeding. See https://docs.docker.com/engine/install/) +endif ifeq ($(VERBOSE),0) ./scripts/start_node.sh else @@ -14,6 +19,9 @@ else endif stop: ##@ Stop local network +ifeq ($(DOCKER_MISSING),1) + $(error Docker is not installed. Please install docker before proceeding. See https://docs.docker.com/engine/install/) +endif docker compose --file $(COMPOSE_FILE) down --volumes --remove-orphans @@ -51,10 +59,17 @@ help: ##@ (Default) Print listing of key targets with their descriptions printf " \033[34m%-27s\033[0m %s\n", $$1, $$2; \ }' -build: ## Build docker image used to run the local network and the attacks +build: check ## Build docker image used to run the local network and the attacks ## Only supported for the development mode with COMPOSE_FILE=dev.yml docker compose --file $(COMPOSE_FILE) build +check-docker: ##@ Check if docker is installed +ifeq ($(DOCKER_MISSING),1) + $(error Docker is not installed. Please install docker before proceeding. See https://docs.docker.com/engine/install/) +else + @echo $(DOCKER_VERSION) +endif + clean: -rm -rf \ adv_key \ diff --git a/hacking/scripts/check-docker.sh b/hacking/scripts/check-docker.sh new file mode 100755 index 000000000..c945017c4 --- /dev/null +++ b/hacking/scripts/check-docker.sh @@ -0,0 +1,8 @@ +#!/bin/bash + +if [ -x "$(command -v docker)" ]; +then + echo 0 +else + echo 1 +fi