2021-05-27 14:26:45 +02:00
|
|
|
--- a/upgrade.sh 2021-05-27 14:20:37.745680148 +0200
|
|
|
|
+++ b/upgrade.sh 2021-05-27 14:21:53.256311952 +0200
|
2021-05-27 14:23:37 +02:00
|
|
|
@@ -3,59 +3,6 @@
|
|
|
|
# its most recent release.
|
|
|
|
|
|
|
|
cd "$(dirname "$0")"
|
|
|
|
-VIRTUALENV="$(pwd -P)/venv"
|
|
|
|
-
|
|
|
|
-# 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
|
|
|
|
-COMMAND="/usr/bin/python3 -m venv ${VIRTUALENV}"
|
|
|
|
-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
|
|
|
|
-
|
|
|
|
# Apply any database migrations
|
|
|
|
COMMAND="python3 netbox/manage.py migrate"
|
|
|
|
echo "Applying database migrations ($COMMAND)..."
|
|
|
|
@@ -86,23 +33,5 @@
|
|
|
|
echo "Clearing cache data ($COMMAND)..."
|
|
|
|
eval $COMMAND || exit 1
|
|
|
|
|
|
|
|
-if [ -v WARN_MISSING_VENV ]; then
|
|
|
|
- echo "--------------------------------------------------------------------"
|
|
|
|
- echo "WARNING: No existing virtual environment was detected. A new one has"
|
|
|
|
- echo "been created. Update your systemd service files to reflect the new"
|
|
|
|
- echo "Python and gunicorn executables. (If this is a new installation,"
|
|
|
|
- echo "this warning can be ignored.)"
|
|
|
|
- echo ""
|
|
|
|
- echo "netbox.service ExecStart:"
|
|
|
|
- echo " ${VIRTUALENV}/bin/gunicorn"
|
|
|
|
- echo ""
|
|
|
|
- echo "netbox-rq.service ExecStart:"
|
|
|
|
- echo " ${VIRTUALENV}/bin/python"
|
|
|
|
- echo ""
|
|
|
|
- echo "After modifying these files, reload the systemctl daemon:"
|
|
|
|
- echo " > systemctl daemon-reload"
|
|
|
|
- echo "--------------------------------------------------------------------"
|
|
|
|
-fi
|
|
|
|
-
|
|
|
|
echo "Upgrade complete! Don't forget to restart the NetBox services:"
|
|
|
|
echo " > sudo systemctl restart netbox netbox-rq"
|