2021-04-01 13:40:47 +00:00
|
|
|
#!/bin/sh
|
|
|
|
|
2021-04-10 07:36:19 +00:00
|
|
|
# Create required directory structure (if it does not already exist)
|
|
|
|
if [[ ! -d "$INVENTREE_STATIC_ROOT" ]]; then
|
|
|
|
echo "Creating directory $INVENTREE_STATIC_ROOT"
|
2021-05-24 23:32:21 +00:00
|
|
|
mkdir -p $INVENTREE_STATIC_ROOT
|
2021-04-10 07:36:19 +00:00
|
|
|
fi
|
|
|
|
|
|
|
|
if [[ ! -d "$INVENTREE_MEDIA_ROOT" ]]; then
|
|
|
|
echo "Creating directory $INVENTREE_MEDIA_ROOT"
|
2021-05-24 23:32:21 +00:00
|
|
|
mkdir -p $INVENTREE_MEDIA_ROOT
|
2021-04-10 07:36:19 +00:00
|
|
|
fi
|
2021-04-07 13:46:03 +00:00
|
|
|
|
2021-04-10 07:36:19 +00:00
|
|
|
# Check if "config.yaml" has been copied into the correct location
|
|
|
|
if test -f "$INVENTREE_CONFIG_FILE"; then
|
|
|
|
echo "$INVENTREE_CONFIG_FILE exists - skipping"
|
|
|
|
else
|
|
|
|
echo "Copying config file to $INVENTREE_CONFIG_FILE"
|
2021-06-15 13:05:03 +00:00
|
|
|
cp $INVENTREE_HOME/InvenTree/config_template.yaml $INVENTREE_CONFIG_FILE
|
2021-04-01 13:40:47 +00:00
|
|
|
fi
|
|
|
|
|
2021-06-15 13:05:03 +00:00
|
|
|
# Setup a virtual environment (within the "dev" directory)
|
|
|
|
python3 -m venv ./dev/env
|
2021-05-12 10:53:50 +00:00
|
|
|
|
2021-06-15 13:05:03 +00:00
|
|
|
# Activate the virtual environment
|
|
|
|
source ./dev/env/bin/activate
|
2021-05-12 10:53:50 +00:00
|
|
|
|
|
|
|
echo "Installing required packages..."
|
2021-06-15 13:05:03 +00:00
|
|
|
pip install --no-cache-dir -U -r ${INVENTREE_HOME}/requirements.txt
|
2021-05-12 10:53:50 +00:00
|
|
|
|
2021-04-10 07:36:19 +00:00
|
|
|
echo "Starting InvenTree server..."
|
2021-04-07 12:27:55 +00:00
|
|
|
|
2021-04-01 13:40:47 +00:00
|
|
|
# Wait for the database to be ready
|
2021-06-15 13:05:03 +00:00
|
|
|
cd ${INVENTREE_HOME}/InvenTree
|
2021-07-02 03:07:42 +00:00
|
|
|
python3 manage.py wait_for_db
|
2021-04-01 13:40:47 +00:00
|
|
|
|
|
|
|
sleep 10
|
|
|
|
|
2021-05-12 11:15:53 +00:00
|
|
|
echo "Running InvenTree database migrations..."
|
2021-04-01 13:40:47 +00:00
|
|
|
|
|
|
|
# We assume at this stage that the database is up and running
|
|
|
|
# Ensure that the database schema are up to date
|
2021-07-02 03:07:42 +00:00
|
|
|
python3 manage.py check || exit 1
|
|
|
|
python3 manage.py migrate --noinput || exit 1
|
|
|
|
python3 manage.py migrate --run-syncdb || exit 1
|
|
|
|
python3 manage.py clearsessions || exit 1
|
2021-04-01 13:40:47 +00:00
|
|
|
|
2021-04-18 06:26:32 +00:00
|
|
|
# Launch a development server
|
2021-07-02 03:07:42 +00:00
|
|
|
python3 manage.py runserver ${INVENTREE_WEB_ADDR}:${INVENTREE_WEB_PORT}
|