Nicolas Massé 6 years ago
parent
commit
2446c11727
  1. 40
      README.md
  2. 27
      configs/photo-bot.yaml
  3. 14
      init/photo-bot

40
README.md

@ -2,22 +2,13 @@
## Compilation ## Compilation
Fetch dependencies.
```sh
go get -u github.com/go-telegram-bot-api/telegram-bot-api
go get -u github.com/spf13/viper
go get -u gopkg.in/yaml.v2
go get -u github.com/rakyll/statik
```
Pack all web files Pack all web files
```sh ```sh
go generate go generate
``` ```
Compile for Raspberry PI. Compile for your target platform (example given for a Raspberry PI 3).
```sh ```sh
GOOS=linux GOARCH=arm64 go build -o photo-bot GOOS=linux GOARCH=arm64 go build -o photo-bot
@ -49,16 +40,9 @@ chown bot:bot /srv/photo-bot
scp photo-bot root@raspberry-pi.example.test:/opt/photo-bot/bin/ scp photo-bot root@raspberry-pi.example.test:/opt/photo-bot/bin/
``` ```
Create a file named `photo-bot.yaml` in `/opt/photo-bot/etc/`. Create a file named `photo-bot.yaml` in `/opt/photo-bot/etc/`, using the [provided config sample](configs/photo-bot.yaml) as a starting base.
```yaml **Note:** the Authentication and Encryption Keys can be created using `openssl rand -base64 32`
TelegramToken: "bot.token.here"
TelegramDebug: true
TargetDir: /srv/photo-bot
AuthorizedUsers:
- john
- jane
```
```sh ```sh
chown bot:bot /opt/photo-bot/etc/photo-bot.yaml chown bot:bot /opt/photo-bot/etc/photo-bot.yaml
@ -72,23 +56,7 @@ sudo -u bot /opt/photo-bot/bin/photo-bot
``` ```
Create the startup script in `/etc/init.d/photo-bot`. Create the startup script in `/etc/init.d/photo-bot`.
A sample init script is [provided in the init folder](init/photo-bot).
```sh
#!/bin/sh /etc/rc.common
# photo-bot
# Start late in the boot process
START=80
STOP=20
start() {
cd /opt/photo-bot/etc/ && start-stop-daemon -c bot -u bot -x /opt/photo-bot/bin/photo-bot -b -S
}
stop() {
start-stop-daemon -c bot -u bot -x /opt/photo-bot/bin/photo-bot -b -K
}
```
```sh ```sh
chmod 755 /etc/init.d/photo-bot chmod 755 /etc/init.d/photo-bot

27
configs/photo-bot.yaml

@ -0,0 +1,27 @@
TargetDir: /srv/photo-bot
LogFile: /srv/photo-bot/bot.log
WebInterface:
Listen: :8080
PublicURL: http://localhost:8080
OIDC:
DiscoveryUrl: https://accounts.google.com
ClientID: <YOUR_CLIENT_ID>.apps.googleusercontent.com
ClientSecret: <YOUR_CLIENT_SECRET>
GSuiteDomain: example.test
Scopes:
- profile
- email
Sessions:
EncryptionKey: # paste here the output of `openssl rand -base64 32`
AuthenticationKey: # paste here the output of `openssl rand -base64 32`
SecureCookie: false
Telegram:
TokenGenerator:
AuthenticationKey: # paste here the output of `openssl rand -base64 32`
Token: <YOUR_TELEGRAM_BOT_TOKEN>
Debug: true
AuthorizedUsers:
- john
- jane

14
init/photo-bot

@ -0,0 +1,14 @@
#!/bin/sh /etc/rc.common
# photo-bot
# Start late in the boot process
START=80
STOP=20
start() {
cd /opt/photo-bot/etc/ && start-stop-daemon -c bot -u bot -x /opt/photo-bot/bin/photo-bot -b -S
}
stop() {
start-stop-daemon -c bot -u bot -x /opt/photo-bot/bin/photo-bot -b -K
}
Loading…
Cancel
Save