mirror of
https://github.com/netbox-community/netbox.git
synced 2024-05-10 07:54:54 +00:00
Fixes #1253: Improved upgrade.sh to allow forcing Python2
This commit is contained in:
@ -52,6 +52,13 @@ Once the new code is in place, run the upgrade script (which may need to be run
|
||||
# ./upgrade.sh
|
||||
```
|
||||
|
||||
!!! warning
|
||||
The upgrade script will prefer Python3 and pip3 if both executables are available. To force it to use Python2 and pip, use the `-2` argument as below.
|
||||
|
||||
```no-highlight
|
||||
# ./upgrade.sh -2
|
||||
```
|
||||
|
||||
This script:
|
||||
|
||||
* Installs or upgrades any new required Python packages
|
||||
|
25
upgrade.sh
25
upgrade.sh
@ -5,6 +5,25 @@
|
||||
# Once the script completes, remember to restart the WSGI service (e.g.
|
||||
# gunicorn or uWSGI).
|
||||
|
||||
# Determine which version of Python/pip to use. Default to v3 (if available)
|
||||
# but allow the user to force v2.
|
||||
PYTHON="python3"
|
||||
PIP="pip3"
|
||||
type $PYTHON >/dev/null 2>&1 && type $PIP >/dev/null 2>&1 || PYTHON="python" PIP="pip"
|
||||
while getopts ":2" opt; do
|
||||
case $opt in
|
||||
2)
|
||||
PYTHON="python"
|
||||
PIP="pip"
|
||||
echo "Forcing Python/pip v2"
|
||||
;;
|
||||
\?)
|
||||
echo "Invalid option: -$OPTARG" >&2
|
||||
exit
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
# Optionally use sudo if not already root, and always prompt for password
|
||||
# before running the command
|
||||
PREFIX="sudo -k "
|
||||
@ -20,12 +39,6 @@ COMMAND="${PREFIX}find . -name \"*.pyc\" -delete"
|
||||
echo "Cleaning up stale Python bytecode ($COMMAND)..."
|
||||
eval $COMMAND
|
||||
|
||||
# Prefer python3/pip3
|
||||
PYTHON="python3"
|
||||
type $PYTHON >/dev/null 2>&1 || PYTHON="python"
|
||||
PIP="pip3"
|
||||
type $PIP >/dev/null 2>&1 || PIP="pip"
|
||||
|
||||
# Install any new Python packages
|
||||
COMMAND="${PREFIX}${PIP} install -r requirements.txt --upgrade"
|
||||
echo "Updating required Python packages ($COMMAND)..."
|
||||
|
Reference in New Issue
Block a user