2021-05-20 02:07:40 +00:00
|
|
|
# Installation
|
2017-08-22 17:56:59 +00:00
|
|
|
|
|
|
|
Open psql as user ```postgres```:
|
|
|
|
```sh
|
|
|
|
psql -U postgres
|
|
|
|
```
|
|
|
|
|
|
|
|
Create a user with password, allowed to login and a database:
|
|
|
|
```sql
|
|
|
|
CREATE ROLE nxy WITH ENCRYPTED PASSWORD 'your-password';
|
|
|
|
ALTER ROLE nxy LOGIN;
|
|
|
|
CREATE DATABASE nxy_prod OWNER nxy;
|
2019-03-31 18:32:44 +00:00
|
|
|
\c nxy_prod
|
|
|
|
CREATE EXTENSION citext;
|
2017-08-22 17:56:59 +00:00
|
|
|
\q
|
|
|
|
```
|
|
|
|
|
|
|
|
Apply database schema and optionally restore a dump:
|
|
|
|
```sh
|
2018-12-01 15:19:51 +00:00
|
|
|
psql -U nxy -d nxy_prod < nxy/files/schema.sql
|
|
|
|
psql -U nxy -d nxy_prod < path/to/dump.sql
|
2017-08-22 17:56:59 +00:00
|
|
|
```
|
|
|
|
|
|
|
|
Clone git repo, create virtual env, activate it and install dependencies:
|
|
|
|
```sh
|
|
|
|
git clone https://gitfap.de/mrhanky/nxy.git
|
|
|
|
python3 -m venv env
|
2018-08-13 22:18:44 +00:00
|
|
|
source env/bin/activate
|
2017-08-22 17:56:59 +00:00
|
|
|
pip install -U -r nxy/requirements.txt
|
|
|
|
```
|
|
|
|
|
|
|
|
Copy sample configs to ```$HOME``` and edit them:
|
|
|
|
```sh
|
|
|
|
cp nxy/files/{.env,config.json} .
|
|
|
|
vim .env config.json
|
|
|
|
```
|
|
|
|
|
2021-05-20 02:07:40 +00:00
|
|
|
## Running as Service
|
2017-09-05 19:22:28 +00:00
|
|
|
|
2017-08-22 18:33:28 +00:00
|
|
|
Enable linger for the bot user (so it starts at boot and keeps running), install and activate systemd unit:
|
2017-08-22 17:56:59 +00:00
|
|
|
```sh
|
|
|
|
sudo loginctl enable-linger nxy
|
|
|
|
mkdir -p $HOME/.config/systemd/user
|
|
|
|
ln -fs $HOME/nxy/files/nxy-bot.service $HOME/.config/systemd/user
|
|
|
|
systemctl --user enable --now nxy-bot.service
|
|
|
|
```
|
2017-08-22 18:27:52 +00:00
|
|
|
|
2017-08-22 18:33:28 +00:00
|
|
|
Install and activate timer for database dumps:
|
2017-08-22 18:27:52 +00:00
|
|
|
```sh
|
|
|
|
ln -fs $HOME/nxy/files/nxy-db-dump.{timer,service} $HOME/.config/systemd/user
|
|
|
|
systemctl --user enable --now nxy-db-dump.timer
|
|
|
|
```
|
2017-09-05 19:22:28 +00:00
|
|
|
|
2021-05-20 02:07:40 +00:00
|
|
|
## Running as Standalone in Development Mode
|
2017-09-05 19:22:28 +00:00
|
|
|
|
|
|
|
For development set the BOT_DEV variable:
|
|
|
|
|
|
|
|
```
|
|
|
|
export BOT_DEV=
|
|
|
|
```
|
|
|
|
|
|
|
|
Then add the current git repository to your python path:
|
|
|
|
|
|
|
|
```
|
|
|
|
export PYTHONPATH=<git repository>:$PYTHONPATH
|
|
|
|
```
|
|
|
|
|
|
|
|
Finally run nxy:
|
|
|
|
|
|
|
|
```
|
|
|
|
python3 -m bot
|
2018-08-13 22:18:44 +00:00
|
|
|
```
|