mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Update upgrade script & instructions to better accomodate moving to a venv
This commit is contained in:
@ -85,6 +85,9 @@ This script:
|
|||||||
|
|
||||||
## Restart the NetBox Services
|
## Restart the NetBox Services
|
||||||
|
|
||||||
|
!!! warning
|
||||||
|
If you are upgrading from an installation that does not use a Python virtual environment, you'll need to update the systemd service files to reference the new Python and gunicorn executables before restarting the services. These are located in `/opt/netbox/venv/bin/`. See the example service files in `/opt/netbox/contrib/` for reference.
|
||||||
|
|
||||||
Finally, restart the gunicorn and RQ services:
|
Finally, restart the gunicorn and RQ services:
|
||||||
|
|
||||||
```no-highlight
|
```no-highlight
|
||||||
|
19
upgrade.sh
19
upgrade.sh
@ -10,12 +10,18 @@ if [ -d "$VIRTUALENV" ]; then
|
|||||||
COMMAND="rm -rf ${VIRTUALENV}"
|
COMMAND="rm -rf ${VIRTUALENV}"
|
||||||
echo "Removing old virtual environment..."
|
echo "Removing old virtual environment..."
|
||||||
eval $COMMAND
|
eval $COMMAND
|
||||||
|
else
|
||||||
|
WARN_MISSING_VENV=1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Create a new virtual environment
|
# Create a new virtual environment
|
||||||
COMMAND="/usr/bin/python3 -m venv ${VIRTUALENV}"
|
COMMAND="/usr/bin/python3 -m venv ${VIRTUALENV}"
|
||||||
echo "Creating a new virtual environment at ${VIRTUALENV}..."
|
echo "Creating a new virtual environment at ${VIRTUALENV}..."
|
||||||
eval $COMMAND
|
eval $COMMAND || (
|
||||||
|
echo "Failed to create the virtual environment. Check that you have the"
|
||||||
|
echo "required system packages installed."
|
||||||
|
exit 1
|
||||||
|
)
|
||||||
|
|
||||||
# Activate the virtual environment
|
# Activate the virtual environment
|
||||||
source "${VIRTUALENV}/bin/activate"
|
source "${VIRTUALENV}/bin/activate"
|
||||||
@ -45,6 +51,13 @@ COMMAND="python3 netbox/manage.py invalidate all"
|
|||||||
echo "Clearing cache data ($COMMAND)..."
|
echo "Clearing cache data ($COMMAND)..."
|
||||||
eval $COMMAND
|
eval $COMMAND
|
||||||
|
|
||||||
|
if [ WARN_MISSING_VENV ]; then
|
||||||
|
echo "No existing virtual environment was detected. A new one has been"
|
||||||
|
echo "created. Update your systemd service files to reflect the new"
|
||||||
|
echo "executables."
|
||||||
|
echo " Python: ${VIRTUALENV}/bin/python"
|
||||||
|
echo " gunicorn: ${VIRTUALENV}/bin/gunicorn"
|
||||||
|
fi
|
||||||
|
|
||||||
echo "Upgrade complete! Don't forget to restart the NetBox services:"
|
echo "Upgrade complete! Don't forget to restart the NetBox services:"
|
||||||
echo " sudo systemctl restart netbox"
|
echo " sudo systemctl restart netbox netbox-rq"
|
||||||
echo " sudo systemctl restart netbox-rq"
|
|
||||||
|
Reference in New Issue
Block a user