run.sh: add trap

This commit is contained in:
E. S. 2024-07-09 20:29:02 +03:00
parent 372d499f62
commit 7eda20f3cc

5
run.sh
View File

@ -3,6 +3,10 @@
set -e
#set -x
deactivate_venv() {
[ -n "$VIRTUAL_ENV" ] && deactivate
}
configdir=$HOME/.config/tgschedpub
DIR="$(dirname "$(realpath "$0")")"
@ -13,6 +17,7 @@ install=0
if [ $install -eq 1 ]; then python3 -m venv .venv; fi
. ./.venv/bin/activate
trap deactivate_venv EXIT INT TERM
if [ $install -eq 1 ]; then pip install -r requirements.txt; fi
[ -d "$configidr" ] || {