You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
887 B
Bash
35 lines
887 B
Bash
#!/usr/bin/env bash
|
|
set -e
|
|
|
|
# Copy config.ini.default if it exists and config.ini doesn't exist.
|
|
if [ -e config.ini.default ] && [ ! -e config.ini ]; then
|
|
cp config.ini.default config.ini
|
|
chmod a+w config.ini
|
|
fi
|
|
|
|
PYTHON=$(command -v python3)
|
|
VENV=venv
|
|
|
|
if [ -f "$PYTHON" ]; then
|
|
|
|
if [ ! -d $VENV ]; then
|
|
# Create a virtual environment if it doesn't exist.
|
|
$PYTHON -m venv $VENV
|
|
else
|
|
if [ -e $VENV/bin/python2 ]; then
|
|
# If a Python2 environment exists, delete it first
|
|
# before creating a new Python 3 virtual environment.
|
|
rm -r $VENV
|
|
$PYTHON -m venv $VENV
|
|
fi
|
|
fi
|
|
|
|
# Activate the virtual environment and install requirements.
|
|
# shellcheck disable=SC1090
|
|
. $VENV/bin/activate
|
|
pip3 install -r requirements.txt
|
|
|
|
else
|
|
>&2 echo "Cannot find Python 3. Please install it."
|
|
fi
|