diff --git a/src/teams_bot/pyinfra.py b/src/teams_bot/pyinfra.py index 4cec8b1..a22839a 100644 --- a/src/teams_bot/pyinfra.py +++ b/src/teams_bot/pyinfra.py @@ -32,7 +32,7 @@ def deploy_teams_bot(unix_user: str, bot_email: str, bot_passwd: str, dbdir: str server.shell( name="Compile teams-bot", commands=[ - f". .venv/bin/activate && cd /home/{unix_user}/teams-bot && pip install ." + f". .local/lib/teams-bot.venv/bin/activate && cd /home/{unix_user}/teams-bot && pip install ." ], _su_user=unix_user, _use_su_login=True, diff --git a/src/teams_bot/setup-venv.sh b/src/teams_bot/setup-venv.sh new file mode 100644 index 0000000..4c4a65b --- /dev/null +++ b/src/teams_bot/setup-venv.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +python3 -m venv ~/.local/lib/teams-bot.venv +source ~/.local/lib/teams-bot.venv/bin/activate +pip install -U pip wheel + diff --git a/src/teams_bot/teams-bot.profile b/src/teams_bot/teams-bot.profile new file mode 100644 index 0000000..4ed2638 --- /dev/null +++ b/src/teams_bot/teams-bot.profile @@ -0,0 +1,7 @@ +export XDG_RUNTIME_DIR="/run/user/$UID" +export DBUS_SESSION_BUS_ADDRESS="unix:path=${XDG_RUNTIME_DIR}/bus" +export NVM_DIR="$HOME/.nvm" +[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm if it exists +[ -s "$HOME/.cargo/env" ] && . "$HOME/.cargo/env" # This loads the cargo environment if it exists +export PATH=$PATH:$HOME/.local/bin + diff --git a/src/teams_bot/teams-bot.service.j2 b/src/teams_bot/teams-bot.service.j2 index 929421a..08ac6e6 100644 --- a/src/teams_bot/teams-bot.service.j2 +++ b/src/teams_bot/teams-bot.service.j2 @@ -2,7 +2,7 @@ Description=run deltachat teams-bot: {{ bot_email }} [Service] -ExecStart=/home/{{ unix_user }}/.venv/bin/teams-bot run -v +ExecStart=/home/{{ unix_user }}/.local/lib/teams-bot.venv/bin/teams-bot run -v EnvironmentFile=/home/{{ unix_user }}/.env Restart=on-failure RestartSec=5s