add services

This commit is contained in:
fade 2022-08-25 19:34:01 -04:00
parent fe88a07676
commit f013670852
4 changed files with 53 additions and 8 deletions

1
.gitignore vendored
View file

@ -1,4 +1,3 @@
go.mod go.mod
go.sum go.sum
mastodon-group-bot
*.db *.db

View file

@ -1,11 +1,14 @@
# Mastodon group bot # Mastodon group bot
This is a bot which implements group functionality in Mastodon. This is a bot which implements group functionality in Mastodon.
## Features
* Repost toots
* Welcome message of new members
* Limit of toots per hour
* Admin commands
# Configuration # Configuration
The bot is configured in a JSON file that looks like this: The bot is configured in a JSON file that looks like this:
``` ```
{ {
"Server": "https://example.com", "Server": "https://example.com",
@ -20,17 +23,30 @@ The bot is configured in a JSON file that looks like this:
``` ```
# Building # Building
``` ```
go mod init mastodon-group-bot go mod init mastodon-group-bot
go mod tidy go mod tidy
go build go build
``` ```
# Usage # Setup services
For first copy config and binary
```
cp mastodon-group-bot /usr/bin/mastodon-group-bot
cp config.json /etc/mastodon-group-bot.json
```
## Systemd
```
cp ./services/systemd/mastodon-group-bot.service /etc/systemd/system/mastodon-group-bot.service
```
## OpenRC
```
cp ./services/openrc/mastodon-group-bot /etc/init.d/mastodon-group-bot
```
# Usage
``` ```
Usage of mastodon-group-bot: Usage of mastodon-group-bot:
-config string -config string

View file

@ -0,0 +1,18 @@
#!/sbin/openrc-run
name=$RC_SVCNAME
command="/usr/bin/$name"
command_args="-config"
cfgfile="/etc/$name.json"
pidfile="/run/$name.pid"
user="nobody:nobody"
description="Mastodon group bot which reposts toots"
start() {
ebegin "Starting $name"
start-stop-daemon -bm -S -u $user -p $pidfile -x $command -- $command_args $cfgfile
eend $?
}
stop() {
ebegin "Stopping $name"
start-stop-daemon -K -p $pidfile
eend $?
}

View file

@ -0,0 +1,12 @@
[Unit]
Description=Mastodon group bot which reposts toots
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
User=nobody
ExecStart=/usr/bin/mastodon-group-bot -config /etc/mastodon-group-bot.json
[Install]
WantedBy=multi-user.target