add run.sh
This commit is contained in:
parent
9a502d86fe
commit
28d47456de
32
run.sh
Executable file
32
run.sh
Executable file
@ -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 "$@"
|
Loading…
x
Reference in New Issue
Block a user