diff --git a/Makefile b/Makefile index 31246a6e87..0c773bfed4 100644 --- a/Makefile +++ b/Makefile @@ -1,3 +1,53 @@ +# Check if this is Windows +ifneq (,$(findstring WINDOWS,$(PATH))) +WINDOWS := True +endif + +# Set shell to cmd on windows +ifdef WINDOWS +SHELL := C:/Windows/System32/cmd.exe +endif + +# Don't use sudo on windows +SUDO := "sudo" +ifdef WINDOWS +SUDO := +endif + +# set home dir to user's home on windows running MINGW +ifdef MSYSTEM +HOME := $(subst \,/,$(HOME)) +endif + +# Get the root dir of this file +ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST)))) + +# Define the full path to this file +THIS_FILE := $(lastword $(MAKEFILE_LIST)) + +# Set docker-compose file selector for windows +ifneq (,$(findstring WINDOWS,$(PATH))) +DC_CONFIG=$(ROOT_DIR)/docker-compose-windows.yml +else +DC_CONFIG=$(ROOT_DIR)/docker-compose.yml +endif + +# Find or create a home for sensitive environment variables +# Check my secret place +CREDS=$(HOME)/.bash/.credentials +ifneq ("$(wildcard $(CREDS))","") +CREDENTIALS := $(CREDS) +else +# Check a normal place +CREDS=$(HOME)/.credentials +ifneq ("$(wildcard $(CREDS))","") +CREDENTIALS := $(CREDS) +else +$(info $(shell "mkdir" $(CREDS))) +endif +endif + +# To use arguments with make execute: make -- ARGS = $(filter-out $@,$(MAKECMDGOALS)) MAKEFLAGS += --silent @@ -9,68 +59,69 @@ list: ############################# list-strategies: - sudo docker-compose exec server zenbot list-strategies $(ARGS) + docker-compose exec server zenbot list-strategies $(ARGS) list-selectors: - sudo docker-compose exec server zenbot list-selectors $(ARGS) + docker-compose exec server zenbot list-selectors $(ARGS) backfill: - sudo docker-compose exec server zenbot backfill $(ARGS) + docker-compose exec server zenbot backfill $(ARGS) sim: - sudo docker-compose exec server zenbot sim $(ARGS) + docker-compose exec server zenbot sim $(ARGS) trade: - sudo docker-compose exec server zenbot trade $(ARGS) + docker-compose exec server zenbot trade $(ARGS) paper: - sudo docker-compose exec server zenbot trade --paper $(ARGS) + docker-compose exec server zenbot trade --paper $(ARGS) balance: - sudo docker-compose exec server zenbot balance $(ARGS) + docker-compose exec server zenbot balance $(ARGS) buy: - sudo docker-compose exec server zenbot buy $(ARGS) + docker-compose exec server zenbot buy $(ARGS) sell: - sudo docker-compose exec server zenbot sell $(ARGS) + docker-compose exec server zenbot sell $(ARGS) zenbot: - sudo docker-compose exec server zenbot $(ARGS) + docker-compose exec server zenbot $(ARGS) ############################# # Docker machine states ############################# up: - sudo docker-compose up -d + $(SUDO) docker-compose --file=$(DC_CONFIG) up start: - sudo docker-compose start + docker-compose start stop: - sudo docker-compose stop + docker-compose stop state: - sudo docker-compose ps + docker-compose ps rebuild: - sudo docker-compose stop - sudo docker-compose pull - sudo docker-compose rm --force server - sudo docker-compose rm --force mongodb - sudo docker-compose rm --force adminmongo - sudo docker-compose build --no-cache - sudo docker-compose up -d --force-recreate + $(SUDO) docker-compose stop + $(SUDO) docker-compose pull + $(SUDO) docker-compose rm --force server + $(SUDO) docker-compose rm --force mongodb + -$(SUDO) docker-compose rm --force adminmongo + $(SUDO) docker-compose build --no-cache + $(SUDO) docker-compose --file=$(DC_CONFIG) up -d --force-recreate + shell: - sudo docker-compose exec server /bin/sh + docker-compose exec server /bin/sh shellw: docker exec -it -u root $$(docker-compose ps -q server) /bin/sh logs: - sudo docker-compose logs $(ARGS) + docker-compose logs $(ARGS) ############################# # Argument fix workaround