#!/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 "$@"