From 15b839d9a7820a81b79e69aba4f0edbc1d8a4fb7 Mon Sep 17 00:00:00 2001 From: Steve Date: Tue, 21 Apr 2020 16:05:51 -0400 Subject: [PATCH] add sample config, makefile, service --- testbot/Makefile | 37 +++++++++++++++++++++++++++++++++++++ testbot/config.yaml.sample | 9 +++++++++ testbot/testbot.service | 13 +++++++++++++ 3 files changed, 59 insertions(+) create mode 100644 testbot/Makefile create mode 100644 testbot/config.yaml.sample create mode 100644 testbot/testbot.service diff --git a/testbot/Makefile b/testbot/Makefile new file mode 100644 index 0000000..bf51658 --- /dev/null +++ b/testbot/Makefile @@ -0,0 +1,37 @@ +PREFIX?=/usr/local +_INSTDIR=$(DESTDIR)$(PREFIX) +BINDIR?=$(_INSTDIR)/bin +GO?=go +GOFLAGS?= + +GOSRC!=find . -name '*.go' +GOSRC+=go.mod go.sum +RM?=rm -f + +testbot: $(GOSRC) + $(GO) build $(GOFLAGS) \ + -ldflags "-s -w" \ + -o $@ + +all: testbot + +install: all + mkdir -m755 -p $(BINDIR) /etc/testbot + install -m755 testbot $(BINDIR)/testbot + install -m644 config.yaml.sample /etc/testbot/ +service: all install + install -m644 testbot.service /etc/systemd/system/ +clean: + $(RM) testbot +RMDIR_IF_EMPTY:=sh -c '\ +if test -d $$0 && ! ls -1qA $$0 | grep -q . ; then \ + rmdir $$0; \ +fi' + +uninstall: + $(RM) $(BINDIR)/testbot + $(RM) /etc/systemd/system/testbot.service + ${RMDIR_IF_EMPTY} /etc/testbot + +.DEFAULT_GOAL := all +.PHONY: all install service uninstall clean diff --git a/testbot/config.yaml.sample b/testbot/config.yaml.sample new file mode 100644 index 0000000..bbc8ff7 --- /dev/null +++ b/testbot/config.yaml.sample @@ -0,0 +1,9 @@ +userid: "@testbot:saintnet.tech" +server: "matrix.saintnet.tech" +token: "token here" +name: "TestBot" +owner: "@stryan@saintnet.tech" +prefix: "!tb" +owm_api_key: "OpenWeatherMap API key" +lat: "39.004608" +long: "-76.875671" diff --git a/testbot/testbot.service b/testbot/testbot.service new file mode 100644 index 0000000..7d421b3 --- /dev/null +++ b/testbot/testbot.service @@ -0,0 +1,13 @@ +[Unit] +Description=Testing Matrix bot +After=network.target +StartLimitIntervalSec=0 +[Service] +Type=simple +Restart=always +RestartSec=1 +User=root +ExecStart=/usr/local/bin/testbot + +[Install] +WantedBy=multi-user.target