2022-05-28 23:40:37 +00:00
|
|
|
#!/bin/bash
|
2021-08-17 13:10:57 +00:00
|
|
|
# exit when any command fails
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# Create required directory structure (if it does not already exist)
|
|
|
|
if [[ ! -d "$INVENTREE_STATIC_ROOT" ]]; then
|
|
|
|
echo "Creating directory $INVENTREE_STATIC_ROOT"
|
|
|
|
mkdir -p $INVENTREE_STATIC_ROOT
|
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d "$INVENTREE_MEDIA_ROOT" ]]; then
|
|
|
|
echo "Creating directory $INVENTREE_MEDIA_ROOT"
|
|
|
|
mkdir -p $INVENTREE_MEDIA_ROOT
|
|
|
|
fi
|
2022-10-16 13:09:31 +00:00
|
|
|
|
|
|
|
if [[ ! -d "$INVENTREE_BACKUP_DIR" ]]; then
|
|
|
|
echo "Creating directory $INVENTREE_BACKUP_DIR"
|
|
|
|
mkdir -p $INVENTREE_BACKUP_DIR
|
|
|
|
fi
|
2021-08-17 13:10:57 +00:00
|
|
|
|
|
|
|
# Check if "config.yaml" has been copied into the correct location
|
|
|
|
if test -f "$INVENTREE_CONFIG_FILE"; then
|
2022-12-08 12:06:02 +00:00
|
|
|
echo "Loading config file : $INVENTREE_CONFIG_FILE"
|
2021-08-17 13:10:57 +00:00
|
|
|
else
|
|
|
|
echo "Copying config file to $INVENTREE_CONFIG_FILE"
|
|
|
|
cp $INVENTREE_HOME/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Setup a python virtual environment
|
|
|
|
# This should be done on the *mounted* filesystem,
|
|
|
|
# so that the installed modules persist!
|
|
|
|
if [[ -n "$INVENTREE_PY_ENV" ]]; then
|
|
|
|
echo "Using Python virtual environment: ${INVENTREE_PY_ENV}"
|
|
|
|
# Setup a virtual environment (within the "dev" directory)
|
2021-12-20 13:34:23 +00:00
|
|
|
python3 -m venv ${INVENTREE_PY_ENV} --system-site-packages
|
2021-08-17 13:10:57 +00:00
|
|
|
|
|
|
|
# Activate the virtual environment
|
|
|
|
source ${INVENTREE_PY_ENV}/bin/activate
|
|
|
|
|
2021-08-17 23:52:27 +00:00
|
|
|
# Note: Python packages will have to be installed on first run
|
2022-04-20 14:01:11 +00:00
|
|
|
# e.g docker-compose run inventree-dev-server invoke update
|
2021-08-17 13:10:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd ${INVENTREE_HOME}
|
|
|
|
|
2021-11-26 09:43:01 +00:00
|
|
|
# Collect translation file stats
|
|
|
|
invoke translate-stats
|
|
|
|
|
2021-08-17 23:52:27 +00:00
|
|
|
# Launch the CMD *after* the ENTRYPOINT completes
|
|
|
|
exec "$@"
|