#! /usr/bin/env bash # Get the runtime path of the bot ABS_PATH="$(readlink -f "$0")" RUN_DIR="$(dirname "$ABS_PATH")" # Relative paths to the virtual environment and main.py VENV='./venv/bin/activate' ENTRY='./blockbot.py' # cd into the bot's root path, set up the virtual environment, and run cd "$RUN_DIR" [ ! -f "$VENV" ] && echo "Virtual environment not found: ${VENV}" && cd - > /dev/null && exit 1 source "$VENV" # I don't know why this doesn't work without the "python3" call, but whatever python3 "$ENTRY" "$@" # Return code RETURN_CODE="$?" # Cleanup deactivate cd - > /dev/null exit "$RETURN_CODE"