Newer
Older
#
# Run Script for AURA Engine
#
# Call with one of these parameters:
#
if [[ $* =~ ^(init|env|engine|core|lqs|test|recreate-database)$ ]]; then
# Check for the correct Python version (3.8+)
PYTHON_EXEC="python3"
echo "[ Using $(python3 -V) ]"
### Initializes the environment & installs dependencies ###
if [[ $mode == "init" ]]; then
mkdir -p logs
pip3 install -r requirements.txt
fi
/usr/bin/env $PYTHON_EXEC run.py --without-lqs
fi
### Runs Liquidsoap only ###
if [[ $mode == "lqs" ]]; then
lqs=$(/usr/bin/env $PYTHON_EXEC run.py --get-lqs-command)
### Runs Tests ###
if [[ $mode == "test" ]]; then
/usr/bin/env $PYTHON_EXEC -m unittest discover tests
fi
### CAUTION: This deletes everything in your database ###
if [[ $mode == "recreate-database" ]]; then
/usr/bin/env $PYTHON_EXEC run.py --recreate-database
# +++ DOCKER COMMANDS +++ #
if [[ $docker == "true" ]]; then
BASE_D=$(realpath "${BASH_SOURCE%/*}/")
### Runs Engine Core & Liquidsoap ###
if [[ $mode == "engine" ]]; then
exec sudo docker run \
--network="host" \
--name aura-engine \
--rm -d \
-v "$BASE_D/audio/source":/var/audio/source:ro \
-v "$BASE_D/audio/station":/var/audio/station:ro \
-v "$BASE_D/audio/playlist":/var/audio/playlist:ro \
-v "$BASE_D/config/docker":/etc/aura \
-v "/dev/snd":/dev/snd \
--privileged \
### Create Docker Image from local project ###
if [[ $mode == "build" ]]; then
### Pushes the latest Docker Image to Docker Hub ###
if [[ $mode == "push" ]]; then
exec sudo docker push autoradio/engine
fi