Commands to use when Upgrading¶
This is a short list of commands that can be issued by the root user and the django-pbx user when upgrading your DjangoPBX installation.
In most cases an update can be achieved by fetching newer tags with git fetch –tags and a simple git checkout <TAG>, where <TAG> is a newer release tag. You MUST be logged in as the django-pbx user when issuing git commands. The git checkout will switch your repository to the tags version.
There will be occasions where a git checkout will identify a conflict. Conflicts happen when you have modified one or more of the files in or under the ~/pbx directory.
There may be some occasions when you may wish to backup your existing DjangoPBX, clone a whole new copy and then edit the new settings_local.py file putting the keys and passwords back in from the saved settings_local.py file.
mv ~/pbx ~/pbx_20240128
git clone --branch <TAG> --depth 1 --recurse-submodules https://codeberg.org/DjangoPBX/DjangoPBX.git pbx
These are the key lines in ~/pbx/pbx/setttings.py that you may need to edit. Do not run in production with DEBUG set to True.:
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'django-insecure-aaabbbcccdddeeefff9876543210'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
ALLOWED_HOSTS = ['*']
# Database
# https://docs.djangoproject.com/en/5.0/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'djangopbx',
'USER': 'djangopbx',
'PASSWORD': 'postgres-insecure-abcdef9876543210',
'HOST': '127.0.0.1',
'PORT': '5432'
},
'freeswitch': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': 'freeswitch',
'USER': 'freeswitch',
'PASSWORD': 'postgres-insecure-abcdef9876543210',
'HOST': '127.0.0.1',
'PORT': '5432'
}
}
# Uncomment for production
# SESSION_COOKIE_AGE = 3600
# SESSION_EXPIRE_AT_BROWSER_CLOSE = True
The Upgrade¶
Most of the time you can use the Generic Update script, If you use this you must be logged as root:
cd /home/django-pbx/pbx
./generic-update.sh
If you wish to do the steps manually then, you first need to check for new release tags. You must be logged in as the django-pbx user:
cd ~/pbx
git fetch --tags
Most of the time a simple git checkout –recurse-submodules <TAG> will suffice, where TAG is the newest release tag. You must be logged in as the django-pbx user:
cd ~/pbx
git checkout --recurse-submodules <TAG> (e.g. 0.9.3)
If you do encounter a conflict, it can be resolved by using git stash. Use git stash to save your local changes and then execute the git checkout. Then use git stash pop to get your stashed changes back.:
cd ~/pbx
git stash
git checkout --recurse-submodules <TAG> (e.g. 0.9.3)
git stash pop
The git commands update the DjangoPBX source code, but depending on what has changed, there may be some additional steps to take, but they are very simple to do.
If changes have been made to the database schema, you will need to apply those changes using the migrate tool:
cd ~/pbx
python3 manage.py migrate
If any static files for the webserver have been changed or added, for example a stylesheet or a new javascript library, you will need to ensure these get moved to the web server using the collectstatic tool:
cd ~/pbx
python3 manage.py collectstatic
Other DjangoPBX command line operations are detailed here: DjangoPBX Management Commands
Finally¶
Logged in as the root user, issue the follow commands:
uwsgi --reload /var/run/uwsgi/app/fs_config/pid
uwsgi --reload /var/run/uwsgi/app/djangopbx/pid