From 2446c11727dffbf16da31f8a0fb2db5a44f91ebd Mon Sep 17 00:00:00 2001 From: Nicolas MASSE Date: Sat, 9 May 2020 21:13:36 +0200 Subject: [PATCH] doc --- README.md | 40 ++++------------------------------------ configs/photo-bot.yaml | 27 +++++++++++++++++++++++++++ init/photo-bot | 14 ++++++++++++++ 3 files changed, 45 insertions(+), 36 deletions(-) create mode 100644 configs/photo-bot.yaml create mode 100644 init/photo-bot diff --git a/README.md b/README.md index 42cc1f8..70cdf98 100644 --- a/README.md +++ b/README.md @@ -2,22 +2,13 @@ ## 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 ```sh go generate ``` -Compile for Raspberry PI. +Compile for your target platform (example given for a Raspberry PI 3). ```sh 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/ ``` -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 -TelegramToken: "bot.token.here" -TelegramDebug: true -TargetDir: /srv/photo-bot -AuthorizedUsers: -- john -- jane -``` +**Note:** the Authentication and Encryption Keys can be created using `openssl rand -base64 32` ```sh 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`. - -```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 -} -``` +A sample init script is [provided in the init folder](init/photo-bot). ```sh chmod 755 /etc/init.d/photo-bot diff --git a/configs/photo-bot.yaml b/configs/photo-bot.yaml new file mode 100644 index 0000000..f2b8fb6 --- /dev/null +++ b/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: .apps.googleusercontent.com + ClientSecret: + 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: + Debug: true + AuthorizedUsers: + - john + - jane diff --git a/init/photo-bot b/init/photo-bot new file mode 100644 index 0000000..fe38447 --- /dev/null +++ b/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 +} \ No newline at end of file