From ee46c007c5c918decf500f326a737b29b1772c74 Mon Sep 17 00:00:00 2001 From: mrhanky Date: Mon, 21 Aug 2017 18:17:13 +0200 Subject: [PATCH] Updated install instructions --- README.md | 31 ++++++++++++++++--------------- files/nxy-bot.service | 2 +- 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index 7273047..8e09b99 100644 --- a/README.md +++ b/README.md @@ -1,28 +1,29 @@ # Installation * Open shell as user nxy will run. These instructions will use ```nxy``` as user and ```/home/nxy``` as its home directory. * Install virtualenvwrapper (ideally system wide). -* Open shell as user ```nxy```, source virtualenvwrappers script +* Open shell as user ```nxy``` - ```sudo -u nxy -i``` - - ```source $(which virtualenvwrapper.sh)``` * Clone repo and change current dir - ```git clone https://gitfap.de/mrhanky/nxy.git``` - ```cd nxy``` -* Create virtualenv and install dependencies - - ```mkvirtualenv -a $PWD -r $PWD/requirements.txt nxy``` +* Create virtualenv, activate it and install dependencies + - ```python3 -m venv env``` + - ```source env/bin/active``` + - ```pip install -r nxy/requirements.txt``` * Create needed tables in the database: - ```psql -U < files/schema.sql``` -* Copy ```files/.env``` and insert values in ```.env``` (replace everything wrapped in < and >) - - ```cp files/.env .env``` +* Copy ```nxy/files/.env``` and insert values in ```.env``` (replace everything wrapped in < and >) + - ```cp nxy/files/.env .env``` - ```vim .env``` -* Copy ```files/config.json``` and modify it (setup ZNC etc.) - - ```cp files/config.json config.json``` +* Copy ```nxy/files/config.json``` and modify it (setup ZNC etc.) + - ```cp nxy/files/config.json config.json``` - ```vim config.json``` * If database is empty, import your database dump: - ```psql -U nxy -d nxy < /path/to/dump.sql``` -* Leave (auto) activated virtualenv and exit the bot's shell - - ```deactivate && exit``` -* Copy systemd unit and enable it (would recommend the ```/usr/local``` prefix). Don't forget to modify the systemd unit if your user and home directory are different! - - ```sudo mkdir -p /usr/local/lib/systemd/system``` - - ```sudo ln -fs /home/nxy/bot/files/nxy-bot.service /usr/local/lib/systemd/system``` - - ```sudo systemctl daemon-reload``` - - ```sudo systemctl enable --now nxy-bot.service``` +* Enable linger for nxy user (so the user unit starts on boot) + - ```sudo loginctl enable-linger nxy``` +* Link systemd unit, enable and run it + - ```mkdir -p $HOME/.config/systemd/user``` + - ```ln -fs $HOME/nxy/files/nxy-bot.service $HOME/.config/systemd/user``` + - ```systemctl --user daemon-reload``` + - ```systemctl --user enable --now nxy-bot.service``` diff --git a/files/nxy-bot.service b/files/nxy-bot.service index 88d51dd..99d18ab 100644 --- a/files/nxy-bot.service +++ b/files/nxy-bot.service @@ -6,7 +6,7 @@ After=network.target Type=simple Restart=always Environment=PYTHONPATH=%h/nxy -WorkingDirectory=/home/nxy/nxy +WorkingDirectory=/home/nxy ExecStart=/home/nxy/env/bin/python -m bot config.json [Install]