2021-09-16 16:53:36 +02:00
|
|
|
--- a/upgrade.sh 2021-09-16 16:18:18.520099120 +0200
|
|
|
|
+++ b/upgrade.sh 2021-09-16 16:19:02.730460864 +0200
|
|
|
|
@@ -7,59 +7,6 @@
|
|
|
|
# Python 3.7 or later.
|
2021-05-08 16:31:21 +02:00
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
-VIRTUALENV="$(pwd -P)/venv"
|
2021-09-16 16:53:36 +02:00
|
|
|
-PYTHON="${PYTHON:-python3}"
|
2021-05-08 16:31:21 +02:00
|
|
|
-
|
|
|
|
-# Remove the existing virtual environment (if any)
|
|
|
|
-if [ -d "$VIRTUALENV" ]; then
|
|
|
|
- COMMAND="rm -rf ${VIRTUALENV}"
|
|
|
|
- echo "Removing old virtual environment..."
|
|
|
|
- eval $COMMAND
|
|
|
|
-else
|
|
|
|
- WARN_MISSING_VENV=1
|
|
|
|
-fi
|
|
|
|
-
|
|
|
|
-# Create a new virtual environment
|
2021-09-16 16:53:36 +02:00
|
|
|
-COMMAND="${PYTHON} -m venv ${VIRTUALENV}"
|
2021-05-08 16:31:21 +02:00
|
|
|
-echo "Creating a new virtual environment at ${VIRTUALENV}..."
|
|
|
|
-eval $COMMAND || {
|
|
|
|
- echo "--------------------------------------------------------------------"
|
|
|
|
- echo "ERROR: Failed to create the virtual environment. Check that you have"
|
|
|
|
- echo "the required system packages installed and the following path is"
|
|
|
|
- echo "writable: ${VIRTUALENV}"
|
|
|
|
- echo "--------------------------------------------------------------------"
|
|
|
|
- exit 1
|
|
|
|
-}
|
|
|
|
-
|
|
|
|
-# Activate the virtual environment
|
|
|
|
-source "${VIRTUALENV}/bin/activate"
|
|
|
|
-
|
|
|
|
-# Upgrade pip
|
|
|
|
-COMMAND="pip install --upgrade pip"
|
|
|
|
-echo "Updating pip ($COMMAND)..."
|
|
|
|
-eval $COMMAND || exit 1
|
|
|
|
-pip -V
|
|
|
|
-
|
|
|
|
-# Install necessary system packages
|
|
|
|
-COMMAND="pip install wheel"
|
|
|
|
-echo "Installing Python system packages ($COMMAND)..."
|
|
|
|
-eval $COMMAND || exit 1
|
|
|
|
-
|
|
|
|
-# Install required Python packages
|
|
|
|
-COMMAND="pip install -r requirements.txt"
|
|
|
|
-echo "Installing core dependencies ($COMMAND)..."
|
|
|
|
-eval $COMMAND || exit 1
|
|
|
|
-
|
|
|
|
-# Install optional packages (if any)
|
|
|
|
-if [ -s "local_requirements.txt" ]; then
|
|
|
|
- COMMAND="pip install -r local_requirements.txt"
|
|
|
|
- echo "Installing local dependencies ($COMMAND)..."
|
|
|
|
- eval $COMMAND || exit 1
|
|
|
|
-elif [ -f "local_requirements.txt" ]; then
|
|
|
|
- echo "Skipping local dependencies (local_requirements.txt is empty)"
|
|
|
|
-else
|
|
|
|
- echo "Skipping local dependencies (local_requirements.txt not found)"
|
|
|
|
-fi
|
|
|
|
|
2021-09-16 16:53:36 +02:00
|
|
|
# Test schema migrations integrity
|
|
|
|
COMMAND="python3 netbox/manage.py showmigrations"
|