summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile78
1 files changed, 78 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..6fa385e
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,78 @@
+SSH_CONFIG ?= ssh.config
+
+.PHONY: run deploy fetchBotLogs registerBot listBots unregisterBot fetchThinkKey fetchTeamToken
+
+run:
+ PYTHONPATH=gen uv run uvicorn app.main:app --port $(PORT) --host 0.0.0.0
+
+deploy:
+ifndef TEAM
+ $(error TEAM is not set)
+endif
+ifndef NAME
+ $(error NAME is not set)
+endif
+ifndef PORT
+ $(error PORT is not set)
+endif
+ifeq ($(shell test "$(PORT)" -lt 8001 -o "$(PORT)" -gt 8003 2>/dev/null; echo $$?),0)
+ $(error PORT must be between 8001 and 8003)
+endif
+ ./deploy.sh $(TEAM) $(NAME) $(PORT) $(SSH_CONFIG)
+
+fetchBotLogs:
+ifndef TEAM
+ $(error TEAM is not set)
+endif
+ifndef PORT
+ $(error PORT is not set)
+endif
+ @ssh -F $(SSH_CONFIG) $(TEAM) "cat ~/hackathon/$(PORT)/server.log" && echo
+
+registerBot:
+ifndef NAME
+ $(error NAME is not set)
+endif
+ifndef TOKEN
+ $(error TOKEN is not set)
+endif
+ifndef PORT
+ $(error PORT is not set)
+endif
+ifeq ($(shell test "$(PORT)" -lt 8001 -o "$(PORT)" -gt 8003 2>/dev/null; echo $$?),0)
+ $(error PORT must be between 8001 and 8003)
+endif
+ @curl -s -X POST https://hackathon.evroc.dev/api/codenames.v1.GameService/RegisterBot \
+ -H "Content-Type: application/json" \
+ -H "Authorization: Bearer $(TOKEN)" \
+ -d '{"identityKey": "$(NAME)", "port": "$(PORT)"}'
+
+listBots:
+ @curl -s -X POST https://hackathon.evroc.dev/api/codenames.v1.GameService/ListBots \
+ -H "Content-Type: application/json" \
+ -d '{}'
+
+
+unregisterBot:
+ifndef TOKEN
+ $(error TOKEN is not set)
+endif
+ifndef BOT_ID
+ $(error BOT_ID is not set)
+endif
+ @curl -s -X POST https://hackathon.evroc.dev/api/codenames.v1.GameService/UnregisterBot \
+ -H "Authorization: Bearer $(TOKEN)" \
+ -H "Content-Type: application/json" \
+ -d '{"botId": "$(BOT_ID)"}'
+
+fetchThinkKey:
+ifndef TEAM
+ $(error TEAM is not set)
+endif
+ @ssh -F $(SSH_CONFIG) $(TEAM) "cat /etc/codenames/think_key" && echo
+
+fetchTeamToken:
+ifndef TEAM
+ $(error TEAM is not set)
+endif
+ @ssh -F $(SSH_CONFIG) $(TEAM) "cat /etc/codenames/game_key" && echo \ No newline at end of file