add sample config, makefile, service

This commit is contained in:
stryan 2020-04-21 16:05:51 -04:00
parent dff852ce65
commit 15b839d9a7
3 changed files with 59 additions and 0 deletions

37
testbot/Makefile Normal file
View File

@ -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

View File

@ -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"

13
testbot/testbot.service Normal file
View File

@ -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