Commit 36f0ceb0 authored by Birin Sanchez's avatar Birin Sanchez

Add instructions to build Debian package with FPM. Move sample config

files. Increase version.
Signed-off-by: Birin Sanchez's avatarBirin Sanchez <>
parent e23f8536
......@@ -19,7 +19,7 @@ If the above command does not succeed you can check the details of the DB create
Modify the `reg_bases.ldif` to match your domain values and add the LDAP entries that will hold the groups and the people:
ldapadd -H ldap://localhost -D "cn=admin,dc=example,dc=com" -W -f ~/reg_bases.ldif
ldapadd -H ldap://localhost -D "cn=admin,dc=example,dc=com" -W -f /opt/purist/middleware_virtualenv/config_sample/ldap/reg_bases.ldif
This gives you a very basic LDAP environment suitable for development. Remember to set `AUTH_LDAP_START_TLS=False` in config.ini as this LDAP server has not been configured for TLS communication.
# Building a deb package #
This file details the steps that need to be taken to build a Debian
package. We used Debian Stretch to build the package but using any
other Debian based distribution should generate a valid package for
that distribution.
Install Ruby packages and configure the user environment for Ruby 2.4.0:
$ sudo apt-get install rbenv ruby-build
$ rbenv install 2.4.0
$ rbenv global 2.4.0
Install FPM gem:
$ rbenv exec gem install fpm
Install the tools needed to create a virtual environment and install
LDH from PyPI:
$ sudo apt-get install python3-pip virtualenv libsasl2-dev libldap2-dev libssl-dev
$ sudo pip3 install virtualenv-tools3
$ pip3 install --user setuptools
Now we can build a Debian package from the LDH version available in PyPI by running:
$ make debpypi
or we can build a Debian package with the sources available in our directory by running:
$ make debsource
After a successful execution you will get a `ldh-middleware_<VERSION>_amd64.deb` file.
......@@ -2,5 +2,5 @@ include *.md
recursive-include purist *.html
recursive-include limitmonitor *.html
recursive-include ldapregister *.html
graft conf
graft config_sample
graft docs
\ No newline at end of file
BUILD_DIR = ./build
DIST_DIR = ./dist
VIR_DIR = $(BUILD_DIR)/middleware_virtualenv
. PHONY : debsource
debsource : $(DIST_DIR)/ldh_middleware-?.?.?-py3-none-any.whl builddeb
debsource : PYTHON_PKG = $(DIST_DIR)/ldh_middleware-?.?.?-py3-none-any.whl
$(DIST_DIR)/ldh_middleware-?.?.?-py3-none-any.whl :
python3 sdist bdist_wheel
. PHONY : debpypi
debpypi : builddeb
debpypi : PYTHON_PKG = ldh_middleware
$(VIR_DIR)/bin/ldh_middleware :
virtualenv --python=python3 $(VIR_DIR) && . $(VIR_DIR)/bin/activate \
&& pip install $(PYTHON_PKG) && deactivate
cd $(VIR_DIR) && \
virtualenv-tools --update-path /opt/purist/middleware_virtualenv
.PHONY : builddeb
builddeb : LDH_VERSION = $(shell awk '/^Version:/ {print $$2}' \
builddeb : LDH_DESC = $(shell awk -F': ' '/^Summary:/ {print $$2}' \
builddeb : LDH_URL = $(shell awk '/^Home-page:/ {print $$2}' \
builddeb : $(VIR_DIR)/bin/ldh_middleware
rbenv exec fpm --vendor "Purism SPC" --maintainer \
--license AGPL-3.0-or-later --prefix /opt/purist/middleware_virtualenv \
--version "$(LDH_VERSION)" --description "$(LDH_DESC)" --url "$(LDH_URL)" \
--after-install bin/ \
--depends python3 --depends supervisor --depends uwsgi --depends nginx \
--depends uwsgi-emperor --depends uwsgi-plugin-python3 \
--chdir $(VIR_DIR) -s dir -t deb -n ldh_middleware .
clean :
rm -f ldh-middleware_*_amd64.deb
rm -rf $(BUILD_DIR) $(DIST_DIR) ldh_middleware.egg-info/
......@@ -74,9 +74,9 @@ Setup
* Copy sample config files to their respective locations:
cp $VIRTUAL_ENV/usr/share/ldh_middleware/conf/middleware/config.ini /etc/opt/purist/middleware/
cp $VIRTUAL_ENV/usr/share/ldh_middleware/conf/middleware/secret.ini /etc/opt/purist/middleware/
cp $VIRTUAL_ENV/usr/share/ldh_middleware/conf/middleware/link_profile.strict.yml /etc/opt/purist/middleware/
cp $VIRTUAL_ENV/config_sample/ldh_middleware/config.ini /etc/opt/purist/middleware/
cp $VIRTUAL_ENV/config_sample/ldh_middleware/secret.ini /etc/opt/purist/middleware/
cp $VIRTUAL_ENV/config_sample/ldh_middleware/link_profile.strict.yml /etc/opt/purist/middleware/
* Modify those files to fit your site needs. You will need to set `DEBUG_ALL_ACCESS=False` in config.ini if your OpenVPN is not fully configured. You can generate a good `DJANGO_SECRET_KEY` in secret.ini using the command `openssl rand -hex 48`.
* Run initial setup:
......@@ -94,7 +94,7 @@ Setup
sudo apt-get install supervisor
sudo cp /opt/purist/middleware_virtualenv/usr/share/ldh_middleware/conf/supervisor/purist_middleware_monitor.conf /etc/supervisor/conf.d/
sudo cp /opt/purist/middleware_virtualenv/config_sample/supervisor/purist_middleware_monitor.conf /etc/supervisor/conf.d/
sudo systemctl restart supervisor
......@@ -104,7 +104,7 @@ Setup
sudo apt-get install uwsgi uwsgi-emperor uwsgi-plugin-python3
sudo cp /opt/purist/middleware_virtualenv/usr/share/ldh_middleware/conf/uwsgi_emperor_vassals/purist_middleware.ini /etc/uwsgi-emperor/vassals/
sudo cp /opt/purist/middleware_virtualenv/config_sample/uwsgi_emperor_vassals/purist_middleware.ini /etc/uwsgi-emperor/vassals/
sudo chown www-data:www-data /var/log/uwsgi/app
sudo chown --recursive www-data:www-data /var/opt/purist
sudo systemctl restart uwsgi-emperor
......@@ -116,7 +116,7 @@ Setup
sudo apt-get install nginx
sudo cp /opt/purist/middleware_virtualenv/usr/share/ldh_middleware/conf/nginx/purist_middleware /etc/nginx/sites-available/
sudo cp /opt/purist/middleware_virtualenv/config_sample/nginx/purist_middleware /etc/nginx/sites-available/
* Modify `/etc/nginx/available_sites/purist_middleware` file changing `server_name` values accordingly. You will also need a working SSL certificate for your host. Once you have that enable the site:
LDH_DIRS="/opt/purist/middleware/ \
/opt/purist/middleware_virtualenv/ \
/etc/opt/purist/middleware/ \
/var/log/purist/middleware/ \
/var/opt/purist/middleware/static/ \
/var/opt/purist/brand/ \
for i in ${LDH_DIRS}; do
mkdir -p $i;
# Set www-data as owner of some dirs
chown www-data:www-data /var/log/uwsgi/app
chown --recursive www-data:www-data /var/opt/purist
name = ldh_middleware
version = 0.0.1
version = 0.0.2
description = A middleware application (with a user-facing web interface) for managing subscription-based accounts on a Liberty Deckplan Host (LDH).
license = AGPL-3.0-or-later
author = Purism SPC
......@@ -38,15 +38,15 @@ install_requires =
usr/share/ldh_middleware/conf/middleware =
usr/share/ldh_middleware/conf/nginx =
usr/share/ldh_middleware/conf/uwsgi_emperor_vassals =
usr/share/ldh_middleware/conf/supervisor =
usr/share/ldh_middleware/conf/ldap =
\ No newline at end of file
config_sample/ldh_middleware =
config_sample/nginx =
config_sample/uwsgi_emperor_vassals =
config_sample/supervisor =
config_sample/ldap =
\ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment