From 18d5b342ca1b3373d69e9a0920fa27969feeb6e3 Mon Sep 17 00:00:00 2001 From: Stefano Salvatori Date: Fri, 29 Mar 2019 07:01:27 +0200 Subject: [PATCH] add systemd service configuration --- contrib/README.md | 23 +++++++++++++++++++++++ contrib/zbot.default | 10 ++++++++++ contrib/zbot.service | 12 ++++++++++++ 3 files changed, 45 insertions(+) create mode 100644 contrib/README.md create mode 100644 contrib/zbot.default create mode 100644 contrib/zbot.service diff --git a/contrib/README.md b/contrib/README.md new file mode 100644 index 0000000..65efe38 --- /dev/null +++ b/contrib/README.md @@ -0,0 +1,23 @@ +# Create systemd service + +Copy zbot service definition. +``` +sudo cp zbot.service /etc/systemd/system/zbot.service +sudo cp zbot.default /etc/default/zbot +sudo chmod 664 /etc/systemd/system/zbot.service +``` + +Enable and start zbot service + +``` +sudo systemctl daemon-reload +sudo systemctl enable zbot +sudo systemctl start zbot +sudo systemctl status zbot +``` + +Create symlink + +```` +sudo ln -s /path/to//zbot-telegram-go-linux-amd64 /usr/local/bin/zbot +``` \ No newline at end of file diff --git a/contrib/zbot.default b/contrib/zbot.default new file mode 100644 index 0000000..c96e9f7 --- /dev/null +++ b/contrib/zbot.default @@ -0,0 +1,10 @@ +#!/bin/bash + +#ZBOT configuration + +ZBOT_TOKEN="" +ZBOT_LOG_LEVEL=debug +ZBOT_DATABASE_TYPE=sqlite +ZBOT_MODULES_PATH="/home/zbot/modules" +ZBOT_DISABLED_COMMANDS="/home/zbot/disabled_commands.json" +ZBOT_SQLITE_DATABASE="/home/zbot/db/database.db" \ No newline at end of file diff --git a/contrib/zbot.service b/contrib/zbot.service new file mode 100644 index 0000000..240d252 --- /dev/null +++ b/contrib/zbot.service @@ -0,0 +1,12 @@ +[Unit] +Description=Zbot as a Service + +[Service] +EnvironmentFile=/etc/default/zbot +ExecStart=/usr/local/bin/zbot +ExecStop=kill $(ps aux | grep '/usr/local/bin/zbot' | grep -v grep | awk '{print $2}') +User=zbot +Group=zbot + +[Install] +WantedBy=multi-user.target \ No newline at end of file