2017-07-04 13:22:20 +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;
|
|
|
|
\q
|
|
|
|
```
|
|
|
|
|
|
|
|
Apply database schema and optionally restore a dump:
|
|
|
|
```sh
|
|
|
|
psql -U nxy -U nxy_prod < nxy/files/schema.sql
|
|
|
|
psql -U nxy -U nxy_prod < path/to/dump.sql
|
|
|
|
```
|
|
|
|
|
|
|
|
Clone git repo, create virtual env, activate it and install dependencies:
|
|
|
|
```sh
|
|
|
|
git clone https://gitfap.de/mrhanky/nxy.git
|
|
|
|
python3 -m venv env
|
|
|
|
source env/bin/active
|
|
|
|
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
|
|
|
|
```
|
|
|
|
|
|
|
|
Enable linger for the bot user (so it starts at boot and keeps running) and install + activate systemd unit:
|
|
|
|
```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
|
|
|
|
|
|
|
Create directory for database dumps and activate timer:
|
|
|
|
```sh
|
|
|
|
ln -fs $HOME/nxy/files/nxy-db-dump.{timer,service} $HOME/.config/systemd/user
|
|
|
|
systemctl --user enable --now nxy-db-dump.timer
|
|
|
|
```
|