2024-02-07 11:33:37 +00:00
|
|
|
#!/bin/ash
|
|
|
|
|
2021-08-17 13:10:57 +00:00
|
|
|
# exit when any command fails
|
|
|
|
set -e
|
|
|
|
|
2023-02-02 20:14:17 +00:00
|
|
|
# Required to suppress some git errors further down the line
|
2023-07-10 09:52:33 +00:00
|
|
|
if command -v git &> /dev/null; then
|
|
|
|
git config --global --add safe.directory /home/***
|
|
|
|
fi
|
2023-02-02 20:14:17 +00:00
|
|
|
|
2021-08-17 13:10:57 +00:00
|
|
|
# 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 from $INVENTREE_BACKEND_DIR/InvenTree/config_template.yml to $INVENTREE_CONFIG_FILE"
|
|
|
|
cp $INVENTREE_BACKEND_DIR/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
|
|
|
|
|
2022-12-30 11:55:24 +00:00
|
|
|
if test -d "$INVENTREE_PY_ENV"; then
|
|
|
|
# venv already exists
|
|
|
|
echo "Using Python virtual environment: ${INVENTREE_PY_ENV}"
|
|
|
|
else
|
|
|
|
# Setup a virtual environment (within the "data/env" directory)
|
|
|
|
echo "Running first time setup for python environment"
|
|
|
|
python3 -m venv ${INVENTREE_PY_ENV} --system-site-packages --upgrade-deps
|
|
|
|
fi
|
2021-08-17 13:10:57 +00:00
|
|
|
|
2022-12-30 11:55:24 +00:00
|
|
|
# Now activate the venv
|
|
|
|
source ${INVENTREE_PY_ENV}/bin/activate
|
2021-08-17 13:10:57 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
cd ${INVENTREE_HOME}
|
|
|
|
|
2021-08-17 23:52:27 +00:00
|
|
|
# Launch the CMD *after* the ENTRYPOINT completes
|
|
|
|
exec "$@"
|