From 28d47456dec2939d1f640a0a093a46e52b442367 Mon Sep 17 00:00:00 2001 From: "E. S." Date: Tue, 9 Jul 2024 20:23:43 +0300 Subject: [PATCH] add run.sh --- run.sh | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100755 run.sh diff --git a/run.sh b/run.sh new file mode 100755 index 0000000..acad6da --- /dev/null +++ b/run.sh @@ -0,0 +1,32 @@ +#!/bin/sh + +set -e +#set -x + +deactivate_venv() { + [ -n "$VIRTUAL_ENV" ] && deactivate +} + +config_dir=$HOME/.config/tgschedpub + +DIR="$(dirname "$(realpath "$0")")" +cd "$DIR" + +install=0 +[ -d .venv ] || install=1 + +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 "$config_dir" ] || { + >&2 echo "error: config directory '$config_dir' does not exists" + exit 1 +} +[ -f "$config_dir/config.yaml" ] || { + >&2 echo "error: $config_dir/config.yaml does not exists" + exit 1 +} + +./tgschedpub.py "$@"