From 766b22aebf144ff74901e7f3c7329c342e87386f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 13 Jun 2013 16:30:19 +0200 Subject: [PATCH 01/81] debian: initial import --- README.Debian | 6 ++ README.source | 9 +++ apache-example | 20 ++++++ changelog | 5 ++ compat | 1 + control | 21 +++++++ copyright | 38 ++++++++++++ docs | 1 + init.d | 161 +++++++++++++++++++++++++++++++++++++++++++++++++ install | 2 + postinst | 32 ++++++++++ postrm | 14 +++++ pyversions | 1 + rules | 25 ++++++++ 14 files changed, 336 insertions(+) create mode 100644 README.Debian create mode 100644 README.source create mode 100644 apache-example create mode 100644 changelog create mode 100644 compat create mode 100644 control create mode 100644 copyright create mode 100644 docs create mode 100755 init.d create mode 100644 install create mode 100644 postinst create mode 100644 postrm create mode 100644 pyversions create mode 100755 rules diff --git a/README.Debian b/README.Debian new file mode 100644 index 00000000..b09f5f0c --- /dev/null +++ b/README.Debian @@ -0,0 +1,6 @@ +passerelle for Debian +--------------------- + +# passerelle_manage.py syncdb + + -- Jérôme Schneider Fri, 10 May 2013 10:08:45 +0200 diff --git a/README.source b/README.source new file mode 100644 index 00000000..d809ee19 --- /dev/null +++ b/README.source @@ -0,0 +1,9 @@ +passerelle for Debian +--------------------- + + + + + + diff --git a/apache-example b/apache-example new file mode 100644 index 00000000..f8e64723 --- /dev/null +++ b/apache-example @@ -0,0 +1,20 @@ + + ServerAdmin webmaster@example.com + ServerName passerelle.example.com + + Alias /passerelle/static /usr/share/passerelle/static + + + Order deny,allow + Allow from all + + + ProxyPass /passerelle/static ! + ProxyPass / http://127.0.0.1:8091 + ProxyPassReverse / http://127.0.0.1:8091 + + LogLevel warn + ErrorLog /var/log/apache2/error.log + CustomLog /var/log/apache2/access.log combined + + diff --git a/changelog b/changelog new file mode 100644 index 00000000..246700dc --- /dev/null +++ b/changelog @@ -0,0 +1,5 @@ +passerelle (0.2.12.g828e940-1) unstable; urgency=low + + * Initial release ... + + -- Jérôme Schneider Thu, 13 Jun 2013 12:29:42 +0200 diff --git a/compat b/compat new file mode 100644 index 00000000..45a4fb75 --- /dev/null +++ b/compat @@ -0,0 +1 @@ +8 diff --git a/control b/control new file mode 100644 index 00000000..4bc41aec --- /dev/null +++ b/control @@ -0,0 +1,21 @@ +Source: passerelle +Section: python +Priority: optional +Maintainer: Jérôme Schneider +Build-Depends: debhelper (>= 8.0.0), + python-django (>= 1.5.0), + python-setuptools +Standards-Version: 3.9.4 +Homepage: https://dev.entrouvert.org/projects/passerelle + +Package: passerelle +Architecture: all +Depends: ${python:Depends}, + ${misc:Depends}, + gunicorn (>= 0.14), + python-django (>= 1.5.0), + python-django-jsonresponse, + python-django-model-utils, + python-setuptools +Description: Passerelle provides an uniform access to multiple data sources and services. + Passerelle provides an uniform access to multiple data sources and services. diff --git a/copyright b/copyright new file mode 100644 index 00000000..27af9527 --- /dev/null +++ b/copyright @@ -0,0 +1,38 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: passerelle +Source: + +Files: * +Copyright: + +License: + + + . + + +# If you want to use GPL v2 or later for the /debian/* files use +# the following clauses, or change it to suit. Delete these two lines +Files: debian/* +Copyright: 2013 Jérôme Schneider +License: GPL-2+ + This package is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + . + This package is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + . + You should have received a copy of the GNU General Public License + along with this program. If not, see + . + On Debian systems, the complete text of the GNU General + Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". + +# Please also look if there are files or directories which have a +# different copyright/license attached and list them here. +# Please avoid to pick license terms that are more restrictive than the +# packaged work, as it may make Debian's contributions unacceptable upstream. diff --git a/docs b/docs new file mode 100644 index 00000000..4414fc1e --- /dev/null +++ b/docs @@ -0,0 +1 @@ +requirements.txt diff --git a/init.d b/init.d new file mode 100755 index 00000000..2d2e394a --- /dev/null +++ b/init.d @@ -0,0 +1,161 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: passerelle +# Required-Start: $network $local_fs +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: Passerelle provides an uniform access to multiple data sources and services +# Description: Passerelle provides an uniform access to multiple data sources and services. +### END INIT INFO + +# Author: Jérôme Schneider + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC=passerelle +NAME=passerelle +DAEMON=/usr/bin/gunicorn +PIDFILE=/var/run/passerelle/$NAME.pid +LOG_DIR=/var/log/passerelle +SCRIPTNAME=/etc/init.d/$NAME + +USER=passerelle +GROUP=passerelle + +DAEMON_ARGS="--pid $PIDFILE \ +--user $USER --group $GROUP \ +--daemon \ +--access-logfile $LOG_DIR/gunicorn-access.log \ +--log-file $LOG_DIR/gunicorn-error.log \ +--bind=127.0.0.1:8091 \ +--workers=10 \ +--worker-class=sync \ +--timeout=60 \ +passerelle.wsgi:application" + +# Exit if the package is not installed +[ -x $DAEMON ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + +# Load the VERBOSE setting and other rcS variables +. /lib/init/vars.sh + +# Define LSB log_* functions. +# Depend on lsb-base (>= 3.0-6) to ensure that this file is present. +. /lib/lsb/init-functions + +# +# Function that starts the daemon/service +# +do_start() +{ + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 +} + +# +# Function that stops the daemon/service +# +do_stop() +{ + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" +} + +# +# Function that sends a SIGHUP to the daemon/service +# +do_reload() { + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 +} + +case "$1" in + start) + log_daemon_msg "Starting $DESC " "$NAME" + do_start + case "$?" in + 0|1) log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac + ;; + stop) + log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac + ;; + status) + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; + #reload|force-reload) + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + #log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #log_end_msg $? + #;; + restart|force-reload) + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; + *) + #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; +esac + diff --git a/install b/install new file mode 100644 index 00000000..d2503c61 --- /dev/null +++ b/install @@ -0,0 +1,2 @@ +debian/local_settings.py /etc/passerelle/ +debian/apache-example /etc/passerelle/ diff --git a/postinst b/postinst new file mode 100644 index 00000000..f5e43f8f --- /dev/null +++ b/postinst @@ -0,0 +1,32 @@ +#! /bin/sh + +set -e + +case "$1" in + configure) + if ! getent passwd passerelle >/dev/null; then + adduser --disabled-password --quiet --system \ + --no-create-home\ + --gecos "Passerelle software user" --group passerelle + chown passerelle:passerelle /var/run/passerelle + chown passerelle:passerelle /var/log/passerelle + chown -R passerelle:passerelle /var/lib/passerelle + fi + /usr/bin/passerelle_manage.py collectstatic --noinput --link + ;; + reconfigure) + /usr/bin/passerelle_manage.py collectstatic --noinput --link + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + diff --git a/postrm b/postrm new file mode 100644 index 00000000..612f99b4 --- /dev/null +++ b/postrm @@ -0,0 +1,14 @@ +#!/bin/sh +# postrm script for passerelle +# +# see: dh_installdeb(1) + +set -e + +case "$1" in purge) + deluser --quiet --system passerelle > /dev/null || true + ;; + +esac + +exit 0 diff --git a/pyversions b/pyversions new file mode 100644 index 00000000..7fd77934 --- /dev/null +++ b/pyversions @@ -0,0 +1 @@ +2.6-2.7 diff --git a/rules b/rules new file mode 100755 index 00000000..563b94b6 --- /dev/null +++ b/rules @@ -0,0 +1,25 @@ +#!/usr/bin/make -f +# -*- makefile -*- +# Sample debian/rules that uses debhelper. +# This file was originally written by Joey Hess and Craig Small. +# As a special exception, when this file is copied by dh-make into a +# dh-make output file, you may use that output file without restriction. +# This special exception was added by Craig Small in version 0.37 of dh-make. + +# Uncomment this to turn on verbose mode. +#export DH_VERBOSE=1 + +BUILD_DIR := 'debian/passerelle' + +%: + dh $@ + +override_dh_install: + dh_install + ln -s $(BUILD_DIR) /etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python2.6/dist-packages/passerelle/ + install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle + install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle/media + install -d -m 0755 $(BUILD_DIR)/var/run/passerelle + install -d -m 0755 $(BUILD_DIR)/var/log/passerelle + install -d -m 0755 $(BUILD_DIR)/usr/share/passerelle/static + From 6d89f0887d72eb2aa5d67c5bafee30cb26ff667a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Sat, 15 Jun 2013 11:30:10 +0200 Subject: [PATCH 02/81] debian: cleaning debian folder --- README.Debian | 2 +- README.source | 9 --------- apache-example | 4 ++-- changelog | 12 ++++++++++++ copyright | 20 -------------------- postinst | 5 +++-- rules | 4 ++-- 7 files changed, 20 insertions(+), 36 deletions(-) delete mode 100644 README.source diff --git a/README.Debian b/README.Debian index b09f5f0c..c198bf0a 100644 --- a/README.Debian +++ b/README.Debian @@ -1,6 +1,6 @@ passerelle for Debian --------------------- -# passerelle_manage.py syncdb +# su passerelle -p -c 'passerelle_manage.py syncdb' -- Jérôme Schneider Fri, 10 May 2013 10:08:45 +0200 diff --git a/README.source b/README.source deleted file mode 100644 index d809ee19..00000000 --- a/README.source +++ /dev/null @@ -1,9 +0,0 @@ -passerelle for Debian ---------------------- - - - - - - diff --git a/apache-example b/apache-example index f8e64723..21fa8ac6 100644 --- a/apache-example +++ b/apache-example @@ -10,8 +10,8 @@ ProxyPass /passerelle/static ! - ProxyPass / http://127.0.0.1:8091 - ProxyPassReverse / http://127.0.0.1:8091 + ProxyPass / http://127.0.0.1:8091/ + ProxyPassReverse / http://127.0.0.1:8091/ LogLevel warn ErrorLog /var/log/apache2/error.log diff --git a/changelog b/changelog index 246700dc..87faa87c 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,15 @@ +passerelle (0.2.12.g828e940-3) unstable; urgency=low + + * debian: cleaning package + + -- Jérôme Schneider Fri, 14 Jun 2013 16:00:47 +0200 + +passerelle (0.2.12.g828e940-2) unstable; urgency=low + + * debian: fix apache example + + -- Jérôme Schneider Thu, 13 Jun 2013 16:56:40 +0200 + passerelle (0.2.12.g828e940-1) unstable; urgency=low * Initial release ... diff --git a/copyright b/copyright index 27af9527..8c175a44 100644 --- a/copyright +++ b/copyright @@ -1,18 +1,3 @@ -Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ -Upstream-Name: passerelle -Source: - -Files: * -Copyright: - -License: - - - . - - -# If you want to use GPL v2 or later for the /debian/* files use -# the following clauses, or change it to suit. Delete these two lines Files: debian/* Copyright: 2013 Jérôme Schneider License: GPL-2+ @@ -31,8 +16,3 @@ License: GPL-2+ . On Debian systems, the complete text of the GNU General Public License version 2 can be found in "/usr/share/common-licenses/GPL-2". - -# Please also look if there are files or directories which have a -# different copyright/license attached and list them here. -# Please avoid to pick license terms that are more restrictive than the -# packaged work, as it may make Debian's contributions unacceptable upstream. diff --git a/postinst b/postinst index f5e43f8f..d04281de 100644 --- a/postinst +++ b/postinst @@ -6,11 +6,12 @@ case "$1" in configure) if ! getent passwd passerelle >/dev/null; then adduser --disabled-password --quiet --system \ - --no-create-home\ + --no-create-home --home /var/lib/passerelle \ --gecos "Passerelle software user" --group passerelle chown passerelle:passerelle /var/run/passerelle chown passerelle:passerelle /var/log/passerelle - chown -R passerelle:passerelle /var/lib/passerelle + chown passerelle:passerelle /var/lib/passerelle + chown passerelle:passerelle /var/lib/passerelle/media fi /usr/bin/passerelle_manage.py collectstatic --noinput --link ;; diff --git a/rules b/rules index 563b94b6..cde14f50 100755 --- a/rules +++ b/rules @@ -12,11 +12,11 @@ BUILD_DIR := 'debian/passerelle' %: - dh $@ + dh $@ --with python2 override_dh_install: dh_install - ln -s $(BUILD_DIR) /etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python2.6/dist-packages/passerelle/ + ln -s $(BUILD_DIR)/etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python2.6/dist-packages/passerelle/ install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle/media install -d -m 0755 $(BUILD_DIR)/var/run/passerelle From bf2b28b648d4161a8fb4189a4afe45733f6256a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Sat, 15 Jun 2013 11:43:48 +0200 Subject: [PATCH 03/81] debian: merge to last master commit and add python-soa --- README.Debian | 4 +++- changelog | 6 ++++++ control | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.Debian b/README.Debian index c198bf0a..b22c44bc 100644 --- a/README.Debian +++ b/README.Debian @@ -1,6 +1,8 @@ passerelle for Debian --------------------- -# su passerelle -p -c 'passerelle_manage.py syncdb' +To install the database please use the following command:: + + # su passerelle -p -c 'passerelle_manage.py syncdb' -- Jérôme Schneider Fri, 10 May 2013 10:08:45 +0200 diff --git a/changelog b/changelog index 87faa87c..33817100 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +passerelle (0.2.21.g6b65b40-1) stable; urgency=low + + * merge to last upstream commit + + -- Jérôme Schneider Sat, 15 Jun 2013 11:34:05 +0200 + passerelle (0.2.12.g828e940-3) unstable; urgency=low * debian: cleaning package diff --git a/control b/control index 4bc41aec..573c91d3 100644 --- a/control +++ b/control @@ -17,5 +17,6 @@ Depends: ${python:Depends}, python-django-jsonresponse, python-django-model-utils, python-setuptools +Recommends: python-soappy Description: Passerelle provides an uniform access to multiple data sources and services. Passerelle provides an uniform access to multiple data sources and services. From 4748f14da560204c11653a6b2ab7720fabdb894e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Sun, 16 Jun 2013 18:41:14 +0200 Subject: [PATCH 04/81] debian: add missing local_settings.py and fix bad local_settings.py link --- changelog | 6 ++++++ local_settings.py | 51 +++++++++++++++++++++++++++++++++++++++++++++++ rules | 2 +- 3 files changed, 58 insertions(+), 1 deletion(-) create mode 100644 local_settings.py diff --git a/changelog b/changelog index 33817100..8cc66d9d 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +passerelle (0.2.21.g6b65b40-2) stable; urgency=low + + * fix new local_settings link + + -- Jérôme Schneider Sun, 16 Jun 2013 18:40:34 +0200 + passerelle (0.2.21.g6b65b40-1) stable; urgency=low * merge to last upstream commit diff --git a/local_settings.py b/local_settings.py new file mode 100644 index 00000000..711de172 --- /dev/null +++ b/local_settings.py @@ -0,0 +1,51 @@ +DEBUG = False +TEMPLATE_DEBUG = DEBUG + +# traceback recipients if DEBUG=False +ADMINS = ( +# ('root', 'root@localhost'), +# ('admin passerelle', 'admin-passerelle@domaine.com'), +) +MANAGERS = ADMINS + +# we're behind a pile of reverse-proxies... +# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts +ALLOWED_HOSTS = ['*'] + +# Local time zone for this installation. Choices can be found here: +# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name +# although not all choices may be available on all operating systems. +# In a Windows environment this must be set to your system time zone. +TIME_ZONE = 'Europe/Paris' + +# Language code for this installation. All choices can be found here: +# http://www.i18nguy.com/unicode/language-identifiers.html +LANGUAGE_CODE = 'fr-fr' + +# +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': '/var/lib/passerelle/passerelle.db', + } +} + +INSTALLED_APPS = ( + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.sessions', + 'django.contrib.sites', + 'django.contrib.messages', + 'django.contrib.staticfiles', + 'django.contrib.admin', + 'passerelle.datasources', +# 'solis', +# 'clicrdv', +# 'gdc', +) + +MEDIA_ROOT = '/var/lib/passerelle/media' +MEDIA_URL = '/passerelle/media/' + +STATIC_ROOT = '/usr/share/passerelle/static' +STATIC_URL = '/passerelle/static/' diff --git a/rules b/rules index cde14f50..a2ae6844 100755 --- a/rules +++ b/rules @@ -16,7 +16,7 @@ BUILD_DIR := 'debian/passerelle' override_dh_install: dh_install - ln -s $(BUILD_DIR)/etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python2.6/dist-packages/passerelle/ + ln -s /etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python2.6/dist-packages/passerelle/ install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle/media install -d -m 0755 $(BUILD_DIR)/var/run/passerelle From f94d15d76a6dcefa13eef0463cf8883912fe06d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Mon, 17 Jun 2013 16:13:20 +0200 Subject: [PATCH 05/81] debian: update INSTALLED_APPS and add python-django-south dependency --- changelog | 7 +++++++ control | 1 + local_settings.py | 10 +++++++++- 3 files changed, 17 insertions(+), 1 deletion(-) diff --git a/changelog b/changelog index 8cc66d9d..8f9e3f85 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,10 @@ +passerelle (0.2.21.g6b65b40-3) stable; urgency=low + + * update INSTALLED_APPS in local_settings.py + * add python-django-south dependency + + -- Jérôme Schneider Sun, 16 Jun 2013 19:56:43 +0200 + passerelle (0.2.21.g6b65b40-2) stable; urgency=low * fix new local_settings link diff --git a/control b/control index 573c91d3..cf5aa5e3 100644 --- a/control +++ b/control @@ -16,6 +16,7 @@ Depends: ${python:Depends}, python-django (>= 1.5.0), python-django-jsonresponse, python-django-model-utils, + python-django-south, python-setuptools Recommends: python-soappy Description: Passerelle provides an uniform access to multiple data sources and services. diff --git a/local_settings.py b/local_settings.py index 711de172..34502b8e 100644 --- a/local_settings.py +++ b/local_settings.py @@ -37,13 +37,21 @@ INSTALLED_APPS = ( 'django.contrib.sites', 'django.contrib.messages', 'django.contrib.staticfiles', + # Uncomment the next line to enable the admin: 'django.contrib.admin', + # Uncomment the next line to enable admin documentation: + # 'django.contrib.admindocs', + 'south', + 'passerelle.base', 'passerelle.datasources', -# 'solis', + 'passerelle.repost', # 'clicrdv', # 'gdc', +# 'solis', +# 'makorepost', ) + MEDIA_ROOT = '/var/lib/passerelle/media' MEDIA_URL = '/passerelle/media/' From 99305b5ea793de0bdebd3fe3f223610b0486396c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Mon, 17 Jun 2013 19:43:26 +0200 Subject: [PATCH 06/81] debian: move static to /var/lib/passerelle/static and update to last commit --- apache-example | 2 +- changelog | 8 ++++++++ local_settings.py | 6 ++++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/apache-example b/apache-example index 21fa8ac6..e4227f75 100644 --- a/apache-example +++ b/apache-example @@ -2,7 +2,7 @@ ServerAdmin webmaster@example.com ServerName passerelle.example.com - Alias /passerelle/static /usr/share/passerelle/static + Alias /passerelle/static /var/lib/passerelle/static Order deny,allow diff --git a/changelog b/changelog index 8f9e3f85..6aa217b4 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,11 @@ +passerelle (0.2.27.gd2a8e52-1) stable; urgency=low + + * merge to last master commit + * update INSTALLED_APPS in local_settings.py + * move static to /var/lib/passerelle/static + + -- Jérôme Schneider Mon, 17 Jun 2013 19:38:50 +0200 + passerelle (0.2.21.g6b65b40-3) stable; urgency=low * update INSTALLED_APPS in local_settings.py diff --git a/local_settings.py b/local_settings.py index 34502b8e..2f452b5d 100644 --- a/local_settings.py +++ b/local_settings.py @@ -45,15 +45,17 @@ INSTALLED_APPS = ( 'passerelle.base', 'passerelle.datasources', 'passerelle.repost', + 'passerelle.messages', # 'clicrdv', # 'gdc', # 'solis', # 'makorepost', +# 'choosit', ) - MEDIA_ROOT = '/var/lib/passerelle/media' MEDIA_URL = '/passerelle/media/' -STATIC_ROOT = '/usr/share/passerelle/static' +STATIC_ROOT = '/var/lib/passerelle/static' STATIC_URL = '/passerelle/static/' + From 03e310978204023738e6f0d45ed15e12667ce918 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 18 Jun 2013 11:49:42 +0200 Subject: [PATCH 07/81] debian: merge to last debian commit --- changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog b/changelog index 6aa217b4..165fb095 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +passerelle (0.2-29-gb8547fd-1) stable; urgency=low + + * merge to last master commit + + -- Jérôme Schneider Tue, 18 Jun 2013 11:48:15 +0200 + passerelle (0.2.27.gd2a8e52-1) stable; urgency=low * merge to last master commit From 55227c60aef8928cd6171ece48df4a0891416e0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 18 Jun 2013 11:53:12 +0200 Subject: [PATCH 08/81] debian: depends on python-django-south >= 0.8 and fix changelog --- changelog | 8 +++++++- control | 2 +- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/changelog b/changelog index 165fb095..a79785c8 100644 --- a/changelog +++ b/changelog @@ -1,4 +1,10 @@ -passerelle (0.2-29-gb8547fd-1) stable; urgency=low +passerelle (0.2.29.gb8547fd-2) stable; urgency=low + + * debian: depends on python-django-south >= 0.8 + + -- Jérôme Schneider Tue, 18 Jun 2013 11:51:56 +0200 + +passerelle (0.2.29.gb8547fd-1) stable; urgency=low * merge to last master commit diff --git a/control b/control index cf5aa5e3..c8658689 100644 --- a/control +++ b/control @@ -16,7 +16,7 @@ Depends: ${python:Depends}, python-django (>= 1.5.0), python-django-jsonresponse, python-django-model-utils, - python-django-south, + python-django-south (>= 0.8), python-django-south (<< 0.9), python-setuptools Recommends: python-soappy Description: Passerelle provides an uniform access to multiple data sources and services. From cccc7a6da08a3c64d122959ee81690296f70189d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 20 Jun 2013 12:01:21 +0200 Subject: [PATCH 09/81] debian: merge with the master --- changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog b/changelog index a79785c8..a00fca76 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +passerelle (0.2.34.ged4ed8a-1) stable; urgency=low + + * update to last mmaster commit + + -- Jérôme Schneider Thu, 20 Jun 2013 12:00:25 +0200 + passerelle (0.2.29.gb8547fd-2) stable; urgency=low * debian: depends on python-django-south >= 0.8 From 888d22a76d757d3dd81f9b7f8f11b612ba118e07 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 20 Jun 2013 15:59:19 +0200 Subject: [PATCH 10/81] debian: update to last master commit --- changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog b/changelog index a00fca76..91973507 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +passerelle (0.2.35.g040e1e3-1) stable; urgency=low + + * update to last mmaster commit + + -- Jérôme Schneider Thu, 20 Jun 2013 15:53:52 +0200 + passerelle (0.2.34.ged4ed8a-1) stable; urgency=low * update to last mmaster commit From b8112a5074f31fa86172b68502bd2d7b3ea53186 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 20 Jun 2013 16:27:03 +0200 Subject: [PATCH 11/81] debian: fix local_settings --- changelog | 6 ++++++ local_settings.py | 1 + 2 files changed, 7 insertions(+) diff --git a/changelog b/changelog index 91973507..77a24a4f 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +passerelle (0.2.35.g040e1e3-2) stable; urgency=low + + * fix local_settings.py + + -- Jérôme Schneider Thu, 20 Jun 2013 16:27:27 +0200 + passerelle (0.2.35.g040e1e3-1) stable; urgency=low * update to last mmaster commit diff --git a/local_settings.py b/local_settings.py index 2f452b5d..0ea8690c 100644 --- a/local_settings.py +++ b/local_settings.py @@ -46,6 +46,7 @@ INSTALLED_APPS = ( 'passerelle.datasources', 'passerelle.repost', 'passerelle.messages', + 'passerelle.register', # 'clicrdv', # 'gdc', # 'solis', From fe563c565046c8a4c47da42e7ed9d44b93d6d7ad Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 13 Aug 2013 10:47:35 +0200 Subject: [PATCH 12/81] Update to last master commit --- changelog | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/changelog b/changelog index 77a24a4f..d214eab7 100644 --- a/changelog +++ b/changelog @@ -1,3 +1,9 @@ +passerelle (0.2.51.g24f717a-1) stable; urgency=low + + * update to last mmaster commit + + -- Jérôme Schneider Tue, 13 Aug 2013 10:47:34 +0200 + passerelle (0.2.35.g040e1e3-2) stable; urgency=low * fix local_settings.py From 85946c2b7ebfb652c3a9cae55541165033cb3a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 13 Aug 2013 10:52:12 +0200 Subject: [PATCH 13/81] debian: remove docs file and use 3.0 source format --- docs | 1 - source/format | 1 + 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 100644 docs create mode 100644 source/format diff --git a/docs b/docs deleted file mode 100644 index 4414fc1e..00000000 --- a/docs +++ /dev/null @@ -1 +0,0 @@ -requirements.txt diff --git a/source/format b/source/format new file mode 100644 index 00000000..163aaf8d --- /dev/null +++ b/source/format @@ -0,0 +1 @@ +3.0 (quilt) From 24d9e4888dafdfb9d3adf8658190c12c0c08a21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 13 Aug 2013 11:36:16 +0200 Subject: [PATCH 14/81] debian: fix rules for Debian Wheezy --- rules | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/rules b/rules index a2ae6844..25606951 100755 --- a/rules +++ b/rules @@ -16,7 +16,9 @@ BUILD_DIR := 'debian/passerelle' override_dh_install: dh_install - ln -s /etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python2.6/dist-packages/passerelle/ + for ver in $(shell pyversions -vr); do \ + ln -s /etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/passerelle/; \ + done install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle/media install -d -m 0755 $(BUILD_DIR)/var/run/passerelle From 2712a71c6d4e2da37db13d2bfa52fb051d276c35 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 7 Oct 2013 22:52:41 +0200 Subject: [PATCH 15/81] debian: add manage command to the init.d script --- control | 3 ++- init.d | 8 ++++++++ install | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) diff --git a/control b/control index c8658689..f3c9e357 100644 --- a/control +++ b/control @@ -17,7 +17,8 @@ Depends: ${python:Depends}, python-django-jsonresponse, python-django-model-utils, python-django-south (>= 0.8), python-django-south (<< 0.9), - python-setuptools + python-setuptools, + sudo Recommends: python-soappy Description: Passerelle provides an uniform access to multiple data sources and services. Passerelle provides an uniform access to multiple data sources and services. diff --git a/init.d b/init.d index 2d2e394a..c153dd52 100755 --- a/init.d +++ b/init.d @@ -152,6 +152,14 @@ case "$1" in ;; esac ;; + manage) + shift + if [ $(id -un) != 'passerelle' ]; then + sudo -E -u wcsinstd python /usr/lib/$NAME/manage.py "$@" + else + python /usr/lib/$NAME/manage.py "$@" + fi + ;; *) #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 diff --git a/install b/install index d2503c61..23b38343 100644 --- a/install +++ b/install @@ -1,2 +1,3 @@ debian/local_settings.py /etc/passerelle/ debian/apache-example /etc/passerelle/ +passerelle_manage.py /usr/lib/passerelle/manage.py From 2cde357827fb81de1adc921292a611db96604095 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 7 Oct 2013 23:01:29 +0200 Subject: [PATCH 16/81] debian: run migrations in postinst --- postinst | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/postinst b/postinst index d04281de..0a670340 100644 --- a/postinst +++ b/postinst @@ -13,10 +13,17 @@ case "$1" in chown passerelle:passerelle /var/lib/passerelle chown passerelle:passerelle /var/lib/passerelle/media fi - /usr/bin/passerelle_manage.py collectstatic --noinput --link + /etc/init.d/passerelle manage collectstatic --noinput --link + + /etc/init.d/passerelle manage syncdb + # test if queue migrations are initialized + if ! /etc/init.d/passerelle manage migrate --list queue | grep 0001 | grep '\*' >/dev/null; then + /etc/init.d/passerelle manage migrate --fake queue 0001 + fi + /etc/init.d/passerelle manage migrate ;; reconfigure) - /usr/bin/passerelle_manage.py collectstatic --noinput --link + /etc/init.d/passerelle manage collectstatic --noinput --link ;; abort-upgrade|abort-remove|abort-deconfigure) From f18cc4913c63f67dd80326b466dcf2b8d8d6a99f Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 7 Oct 2013 23:23:18 +0200 Subject: [PATCH 17/81] debian: move passerelle_manage.py in rules instead of copying it using the install file --- install | 1 - rules | 2 ++ 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/install b/install index 23b38343..d2503c61 100644 --- a/install +++ b/install @@ -1,3 +1,2 @@ debian/local_settings.py /etc/passerelle/ debian/apache-example /etc/passerelle/ -passerelle_manage.py /usr/lib/passerelle/manage.py diff --git a/rules b/rules index 25606951..f689ce71 100755 --- a/rules +++ b/rules @@ -24,4 +24,6 @@ override_dh_install: install -d -m 0755 $(BUILD_DIR)/var/run/passerelle install -d -m 0755 $(BUILD_DIR)/var/log/passerelle install -d -m 0755 $(BUILD_DIR)/usr/share/passerelle/static + install -d -m 0755 $(BUILD_DIR)/usr/lib/passerelle/ + mv $(BUILD_DIR)/usr/bin/passerelle_manage.py $(BUILD_DIR)/usr/lib/passerelle From f4c1efb24e449173b16678669c5ff64970331f88 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 7 Oct 2013 23:27:21 +0200 Subject: [PATCH 18/81] debian: rename passerelle_manage.py to manage.py for uniformity --- rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules b/rules index f689ce71..1be87417 100755 --- a/rules +++ b/rules @@ -25,5 +25,5 @@ override_dh_install: install -d -m 0755 $(BUILD_DIR)/var/log/passerelle install -d -m 0755 $(BUILD_DIR)/usr/share/passerelle/static install -d -m 0755 $(BUILD_DIR)/usr/lib/passerelle/ - mv $(BUILD_DIR)/usr/bin/passerelle_manage.py $(BUILD_DIR)/usr/lib/passerelle + mv $(BUILD_DIR)/usr/bin/passerelle_manage.py $(BUILD_DIR)/usr/lib/passerelle/manage.py From eccc3dc83de45515a8015871eda93c4164a4b58b Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 7 Oct 2013 23:33:59 +0200 Subject: [PATCH 19/81] debian: fix wrong user in init.d manage command --- init.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.d b/init.d index c153dd52..e16c269c 100755 --- a/init.d +++ b/init.d @@ -155,7 +155,7 @@ case "$1" in manage) shift if [ $(id -un) != 'passerelle' ]; then - sudo -E -u wcsinstd python /usr/lib/$NAME/manage.py "$@" + sudo -E -u passerelle python /usr/lib/$NAME/manage.py "$@" else python /usr/lib/$NAME/manage.py "$@" fi From 7713b286bee7f2c0964120bf27d758c34df08e4f Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 7 Oct 2013 23:42:03 +0200 Subject: [PATCH 20/81] debian: apply migration when launching the daemon --- init.d | 9 +++++++++ postinst | 7 ------- 2 files changed, 9 insertions(+), 7 deletions(-) diff --git a/init.d b/init.d index e16c269c..ef7ae2fc 100755 --- a/init.d +++ b/init.d @@ -51,6 +51,15 @@ passerelle.wsgi:application" # do_start() { + # Do migrations + $SCRIPTNAME manage syncdb + # test if queue migrations are initialized + if $SCRIPTNAME manage migrate --list | grep '^ queue'; then + if ! $SCRIPTNAME manage migrate --list queue | grep 0001 | grep '\*' >/dev/null; then + $SCRIPTNAME manage migrate --fake queue 0001 + fi + fi + $SCRIPTNAME manage migrate # Return # 0 if daemon has been started # 1 if daemon was already running diff --git a/postinst b/postinst index 0a670340..3ec12d07 100644 --- a/postinst +++ b/postinst @@ -14,13 +14,6 @@ case "$1" in chown passerelle:passerelle /var/lib/passerelle/media fi /etc/init.d/passerelle manage collectstatic --noinput --link - - /etc/init.d/passerelle manage syncdb - # test if queue migrations are initialized - if ! /etc/init.d/passerelle manage migrate --list queue | grep 0001 | grep '\*' >/dev/null; then - /etc/init.d/passerelle manage migrate --fake queue 0001 - fi - /etc/init.d/passerelle manage migrate ;; reconfigure) /etc/init.d/passerelle manage collectstatic --noinput --link From 22c3090a8d27ea188b844b550ad2848499945fb6 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 8 Oct 2013 10:46:09 +0200 Subject: [PATCH 21/81] debian/init.d: remove verbose output, do not preserve environement when running management script and set homedir to passerelle user's homedir --- init.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.d b/init.d index ef7ae2fc..3e8f8ff1 100755 --- a/init.d +++ b/init.d @@ -54,7 +54,7 @@ do_start() # Do migrations $SCRIPTNAME manage syncdb # test if queue migrations are initialized - if $SCRIPTNAME manage migrate --list | grep '^ queue'; then + if $SCRIPTNAME manage migrate --list | grep '^ queue' >/dev/null; then if ! $SCRIPTNAME manage migrate --list queue | grep 0001 | grep '\*' >/dev/null; then $SCRIPTNAME manage migrate --fake queue 0001 fi @@ -164,7 +164,7 @@ case "$1" in manage) shift if [ $(id -un) != 'passerelle' ]; then - sudo -E -u passerelle python /usr/lib/$NAME/manage.py "$@" + sudo -H -u passerelle python /usr/lib/$NAME/manage.py "$@" else python /usr/lib/$NAME/manage.py "$@" fi From c772179921ec3ca1b5e7b9d39d3a38557871dea6 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 9 Oct 2013 15:14:48 +0200 Subject: [PATCH 22/81] debian: add python-mako to recommends --- control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control b/control index f3c9e357..3ae738e0 100644 --- a/control +++ b/control @@ -19,6 +19,6 @@ Depends: ${python:Depends}, python-django-south (>= 0.8), python-django-south (<< 0.9), python-setuptools, sudo -Recommends: python-soappy +Recommends: python-soappy, python-mako Description: Passerelle provides an uniform access to multiple data sources and services. Passerelle provides an uniform access to multiple data sources and services. From f28b93e22b2b33489bdd61e5ddb912d68596c015 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Wed, 9 Oct 2013 15:15:47 +0200 Subject: [PATCH 23/81] debian: in init.d remove too smart for me migration testing code --- init.d | 6 ------ 1 file changed, 6 deletions(-) diff --git a/init.d b/init.d index 3e8f8ff1..6dc1fad1 100755 --- a/init.d +++ b/init.d @@ -53,12 +53,6 @@ do_start() { # Do migrations $SCRIPTNAME manage syncdb - # test if queue migrations are initialized - if $SCRIPTNAME manage migrate --list | grep '^ queue' >/dev/null; then - if ! $SCRIPTNAME manage migrate --list queue | grep 0001 | grep '\*' >/dev/null; then - $SCRIPTNAME manage migrate --fake queue 0001 - fi - fi $SCRIPTNAME manage migrate # Return # 0 if daemon has been started From 71a3e459f9d9ca103bac3fb608f04abf9f87b18d Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Wed, 9 Oct 2013 16:32:45 +0200 Subject: [PATCH 24/81] debian: add python-sqlalchemy in recommends --- control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control b/control index 3ae738e0..304183af 100644 --- a/control +++ b/control @@ -19,6 +19,6 @@ Depends: ${python:Depends}, python-django-south (>= 0.8), python-django-south (<< 0.9), python-setuptools, sudo -Recommends: python-soappy, python-mako +Recommends: python-soappy, python-mako, python-sqlalchemy Description: Passerelle provides an uniform access to multiple data sources and services. Passerelle provides an uniform access to multiple data sources and services. From 5d31f37810e5a68d0aa4e55b7f975ebd36de7fca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Fri, 29 Nov 2013 10:22:40 +0100 Subject: [PATCH 25/81] control: move python-mako from Recommends to Depends Closes #3745 --- control | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/control b/control index 304183af..568ee8cb 100644 --- a/control +++ b/control @@ -16,9 +16,10 @@ Depends: ${python:Depends}, python-django (>= 1.5.0), python-django-jsonresponse, python-django-model-utils, + python-mako, python-django-south (>= 0.8), python-django-south (<< 0.9), python-setuptools, sudo -Recommends: python-soappy, python-mako, python-sqlalchemy +Recommends: python-soappy, python-sqlalchemy Description: Passerelle provides an uniform access to multiple data sources and services. Passerelle provides an uniform access to multiple data sources and services. From 619236ff3dd7ac28e8deff1b0538e1a6bdb11f24 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Wed, 19 Mar 2014 16:51:09 +0100 Subject: [PATCH 26/81] fix init.d * bind to a socket file * create /run/passerelle on each start * use gunicorn --name option * start "only" 5 workers * use --noinput option for syncdb/migrate --- init.d | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/init.d b/init.d index 6dc1fad1..b89bf74e 100755 --- a/init.d +++ b/init.d @@ -12,26 +12,17 @@ # Author: Jérôme Schneider PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC=passerelle +DESC=Passerelle NAME=passerelle DAEMON=/usr/bin/gunicorn -PIDFILE=/var/run/passerelle/$NAME.pid +RUN_DIR=/var/run/passerelle +PIDFILE=$RUN_DIR/$NAME.pid LOG_DIR=/var/log/passerelle SCRIPTNAME=/etc/init.d/$NAME +SOCKFILE=$RUN_DIR/$NAME.sock -USER=passerelle -GROUP=passerelle - -DAEMON_ARGS="--pid $PIDFILE \ ---user $USER --group $GROUP \ ---daemon \ ---access-logfile $LOG_DIR/gunicorn-access.log \ ---log-file $LOG_DIR/gunicorn-error.log \ ---bind=127.0.0.1:8091 \ ---workers=10 \ ---worker-class=sync \ ---timeout=60 \ -passerelle.wsgi:application" +USER=$NAME +GROUP=$NAME # Exit if the package is not installed [ -x $DAEMON ] || exit 0 @@ -39,6 +30,14 @@ passerelle.wsgi:application" # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME +DAEMON_ARGS="--pid $PIDFILE \ + --daemon --bind=unix:$SOCKFILE \ + --user $USER --group $GROUP \ + --access-logfile $LOG_DIR/gunicorn-access.log \ + --log-file $LOG_DIR/gunicorn-error.log \ + --workers=5 --worker-class=sync --timeout=60 \ + --name $NAME passerelle.wsgi:application" + # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh @@ -46,18 +45,25 @@ passerelle.wsgi:application" # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +# Create run directory (pid, sock, etc.) +if [ ! -d $RUN_DIR ]; then + install -d -m 755 -o $USER -g $GROUP $RUN_DIR +fi + # # Function that starts the daemon/service # do_start() { - # Do migrations - $SCRIPTNAME manage syncdb - $SCRIPTNAME manage migrate # Return # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started + + # Do migrations + $SCRIPTNAME manage syncdb --noinput + $SCRIPTNAME manage migrate --noinput + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --exec $DAEMON -- \ From 4fc89904c5910b801b29077e6c9dc5064bb39ff3 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Wed, 19 Mar 2014 16:52:49 +0100 Subject: [PATCH 27/81] postinst: don't create /var/run it's created by init.d --- postinst | 1 - 1 file changed, 1 deletion(-) diff --git a/postinst b/postinst index 3ec12d07..1957bae3 100644 --- a/postinst +++ b/postinst @@ -8,7 +8,6 @@ case "$1" in adduser --disabled-password --quiet --system \ --no-create-home --home /var/lib/passerelle \ --gecos "Passerelle software user" --group passerelle - chown passerelle:passerelle /var/run/passerelle chown passerelle:passerelle /var/log/passerelle chown passerelle:passerelle /var/lib/passerelle chown passerelle:passerelle /var/lib/passerelle/media From 359cd9a440018bcd621e85d39385c97e6f100902 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Wed, 19 Mar 2014 16:53:34 +0100 Subject: [PATCH 28/81] remove useless and bad apache-example --- apache-example | 20 -------------------- 1 file changed, 20 deletions(-) delete mode 100644 apache-example diff --git a/apache-example b/apache-example deleted file mode 100644 index e4227f75..00000000 --- a/apache-example +++ /dev/null @@ -1,20 +0,0 @@ - - ServerAdmin webmaster@example.com - ServerName passerelle.example.com - - Alias /passerelle/static /var/lib/passerelle/static - - - Order deny,allow - Allow from all - - - ProxyPass /passerelle/static ! - ProxyPass / http://127.0.0.1:8091/ - ProxyPassReverse / http://127.0.0.1:8091/ - - LogLevel warn - ErrorLog /var/log/apache2/error.log - CustomLog /var/log/apache2/access.log combined - - From 21256ca3233d26fa8730cbddde151097351cbce4 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Wed, 19 Mar 2014 16:54:03 +0100 Subject: [PATCH 29/81] don't install removed apache-example... --- install | 1 - 1 file changed, 1 deletion(-) diff --git a/install b/install index d2503c61..f4d0b320 100644 --- a/install +++ b/install @@ -1,2 +1 @@ debian/local_settings.py /etc/passerelle/ -debian/apache-example /etc/passerelle/ From d249d98cea5ce5f06894451b508149fa1b757eb6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 8 Jul 2014 14:13:39 +0200 Subject: [PATCH 30/81] debian/control: add a recommend on python-phpserialize --- control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control b/control index 568ee8cb..32fa15bf 100644 --- a/control +++ b/control @@ -20,6 +20,6 @@ Depends: ${python:Depends}, python-django-south (>= 0.8), python-django-south (<< 0.9), python-setuptools, sudo -Recommends: python-soappy, python-sqlalchemy +Recommends: python-soappy, python-sqlalchemy, python-phpserialize Description: Passerelle provides an uniform access to multiple data sources and services. Passerelle provides an uniform access to multiple data sources and services. From c094e98054c20f078bf613347e47055dbbf47ed1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Tue, 8 Jul 2014 14:14:26 +0200 Subject: [PATCH 31/81] debian/control: add dependency on python-gadjo --- control | 1 + 1 file changed, 1 insertion(+) diff --git a/control b/control index 32fa15bf..ae16516d 100644 --- a/control +++ b/control @@ -19,6 +19,7 @@ Depends: ${python:Depends}, python-mako, python-django-south (>= 0.8), python-django-south (<< 0.9), python-setuptools, + python-gadjo, sudo Recommends: python-soappy, python-sqlalchemy, python-phpserialize Description: Passerelle provides an uniform access to multiple data sources and services. From 47c9c78c94a39d3bd4c2fcedf55209baaee51a10 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Mon, 28 Jul 2014 11:46:38 +0000 Subject: [PATCH 32/81] debian/pyversions: only 2.7 (i.e. wheezy-only package) --- pyversions | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyversions b/pyversions index 7fd77934..1effb003 100644 --- a/pyversions +++ b/pyversions @@ -1 +1 @@ -2.6-2.7 +2.7 From 94b49948b805ef8078d9455bb9abd95c0d7744af Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Mon, 28 Jul 2014 11:59:49 +0000 Subject: [PATCH 33/81] debian: remove useless pyversions --- pyversions | 1 - 1 file changed, 1 deletion(-) delete mode 100644 pyversions diff --git a/pyversions b/pyversions deleted file mode 100644 index 1effb003..00000000 --- a/pyversions +++ /dev/null @@ -1 +0,0 @@ -2.7 From ed09868de440601274951b3fc4aac700ae46a302 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 18 Sep 2014 11:32:38 +0200 Subject: [PATCH 34/81] pydist-overrides: fixing dependenciens on jsonfield It's python-jsonfield and not python-django-jsonfield --- pydist-overrides | 1 + 1 file changed, 1 insertion(+) create mode 100644 pydist-overrides diff --git a/pydist-overrides b/pydist-overrides new file mode 100644 index 00000000..970cfa2a --- /dev/null +++ b/pydist-overrides @@ -0,0 +1 @@ +jsonfield python-django-jsonfield From 366928f70bc52e4b8c10a8c63c4bfb080bf4ba85 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 15 Sep 2014 10:13:51 +0200 Subject: [PATCH 35/81] Handle multi-tenant in debian packaging --- default | 1 + init.d | 36 +++++++++++++++++++++++++++--------- rules | 2 ++ 3 files changed, 30 insertions(+), 9 deletions(-) create mode 100644 default diff --git a/default b/default new file mode 100644 index 00000000..4350c8d7 --- /dev/null +++ b/default @@ -0,0 +1 @@ +# export TENANT_BASE=/var/lib/passerelle/tenants/ diff --git a/init.d b/init.d index b89bf74e..f6fb938f 100755 --- a/init.d +++ b/init.d @@ -61,8 +61,14 @@ do_start() # 2 if daemon could not be started # Do migrations - $SCRIPTNAME manage syncdb --noinput - $SCRIPTNAME manage migrate --noinput + if [ "x$TENANT_BASE" != "x" ]; then + $SCRIPTNAME create-schemas + $SCRIPTNAME manage sync_schema --noinput + $SCRIPTNAME manage migrate_schema --noinput + else + $SCRIPTNAME manage syncdb --noinput + $SCRIPTNAME manage migrate --noinput + fi start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 @@ -161,13 +167,25 @@ case "$1" in ;; esac ;; - manage) - shift - if [ $(id -un) != 'passerelle' ]; then - sudo -H -u passerelle python /usr/lib/$NAME/manage.py "$@" - else - python /usr/lib/$NAME/manage.py "$@" - fi + manage) + shift + if [ $(id -un) != 'passerelle' ]; then + sudo -H -u passerelle python /usr/lib/$NAME/manage.py "$@" + else + python /usr/lib/$NAME/manage.py "$@" + fi + ;; + create-schema) + shift + TENANT=$1 + log_daemon_msg "Creating tenant" "$TENANT" + if [ "x$TENANT_BASE" == "x" ]; then + log_end_msg 1 + else + TENANT_DIR="$TENANT_BASE/$TENANT/" + mkdir "$TENANT_DIR" "$TENANT_DIR/media/" "$TENANT_DIR/static" "$TENANT_DIR/templates" + $SCRIPTNAME manage create_schema + fi ;; *) #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 diff --git a/rules b/rules index 1be87417..d914188e 100755 --- a/rules +++ b/rules @@ -20,10 +20,12 @@ override_dh_install: ln -s /etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/passerelle/; \ done install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle + install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle/tenants install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle/media install -d -m 0755 $(BUILD_DIR)/var/run/passerelle install -d -m 0755 $(BUILD_DIR)/var/log/passerelle install -d -m 0755 $(BUILD_DIR)/usr/share/passerelle/static install -d -m 0755 $(BUILD_DIR)/usr/lib/passerelle/ + install -m 0755 debian/default $(BUILD_DIR)/etc/default/passerelle mv $(BUILD_DIR)/usr/bin/passerelle_manage.py $(BUILD_DIR)/usr/lib/passerelle/manage.py From 95040ec773eb797b29b00fcfe7119af98ba5d08c Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 16 Sep 2014 11:55:52 +0200 Subject: [PATCH 36/81] Reformat init.d --- init.d | 216 ++++++++++++++++++++++++++++----------------------------- 1 file changed, 108 insertions(+), 108 deletions(-) diff --git a/init.d b/init.d index f6fb938f..2d09f78c 100755 --- a/init.d +++ b/init.d @@ -55,26 +55,26 @@ fi # do_start() { - # Return - # 0 if daemon has been started - # 1 if daemon was already running - # 2 if daemon could not be started + # Return + # 0 if daemon has been started + # 1 if daemon was already running + # 2 if daemon could not be started - # Do migrations - if [ "x$TENANT_BASE" != "x" ]; then - $SCRIPTNAME create-schemas - $SCRIPTNAME manage sync_schema --noinput - $SCRIPTNAME manage migrate_schema --noinput - else - $SCRIPTNAME manage syncdb --noinput - $SCRIPTNAME manage migrate --noinput - fi - - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ - || return 1 - start-stop-daemon --start --quiet --exec $DAEMON -- \ - $DAEMON_ARGS \ - || return 2 + # Do migrations + if [ "x$TENANT_BASE" != "x" ]; then + $SCRIPTNAME create_schema + $SCRIPTNAME manage sync_schema --noinput + $SCRIPTNAME manage migrate_schema --noinput + else + $SCRIPTNAME manage syncdb --noinput + $SCRIPTNAME manage migrate --noinput + fi + + start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ + || return 1 + start-stop-daemon --start --quiet --exec $DAEMON -- \ + $DAEMON_ARGS \ + || return 2 } # @@ -82,38 +82,38 @@ do_start() # do_stop() { - # Return - # 0 if daemon has been stopped - # 1 if daemon was already stopped - # 2 if daemon could not be stopped - # other if a failure occurred - start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE - RETVAL="$?" - [ "$RETVAL" = 2 ] && return 2 - # Wait for children to finish too if this is a daemon that forks - # and if the daemon is only ever run from this initscript. - # If the above conditions are not satisfied then add some other code - # that waits for the process to drop all resources that could be - # needed by services started subsequently. A last resort is to - # sleep for some time. - start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON - [ "$?" = 2 ] && return 2 - # Many daemons don't delete their pidfiles when they exit. - rm -f $PIDFILE - return "$RETVAL" + # Return + # 0 if daemon has been stopped + # 1 if daemon was already stopped + # 2 if daemon could not be stopped + # other if a failure occurred + start-stop-daemon --stop --quiet --retry=TERM/30/KILL/5 --pidfile $PIDFILE + RETVAL="$?" + [ "$RETVAL" = 2 ] && return 2 + # Wait for children to finish too if this is a daemon that forks + # and if the daemon is only ever run from this initscript. + # If the above conditions are not satisfied then add some other code + # that waits for the process to drop all resources that could be + # needed by services started subsequently. A last resort is to + # sleep for some time. + start-stop-daemon --stop --quiet --oknodo --retry=0/30/KILL/5 --exec $DAEMON + [ "$?" = 2 ] && return 2 + # Many daemons don't delete their pidfiles when they exit. + rm -f $PIDFILE + return "$RETVAL" } # # Function that sends a SIGHUP to the daemon/service # do_reload() { - # - # If the daemon can reload its configuration without - # restarting (for example, when it is sent a SIGHUP), - # then implement that here. - # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME - return 0 + # + # If the daemon can reload its configuration without + # restarting (for example, when it is sent a SIGHUP), + # then implement that here. + # + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + return 0 } case "$1" in @@ -121,76 +121,76 @@ case "$1" in log_daemon_msg "Starting $DESC " "$NAME" do_start case "$?" in - 0|1) log_end_msg 0 ;; - 2) log_end_msg 1 ;; - esac + 0|1) log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac ;; stop) - log_daemon_msg "Stopping $DESC" "$NAME" - do_stop - case "$?" in - 0|1) log_end_msg 0 ;; - 2) log_end_msg 1 ;; - esac - ;; + log_daemon_msg "Stopping $DESC" "$NAME" + do_stop + case "$?" in + 0|1) log_end_msg 0 ;; + 2) log_end_msg 1 ;; + esac + ;; status) - status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? - ;; + status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? + ;; #reload|force-reload) - # - # If do_reload() is not implemented then leave this commented out - # and leave 'force-reload' as an alias for 'restart'. - # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; + # + # If do_reload() is not implemented then leave this commented out + # and leave 'force-reload' as an alias for 'restart'. + # + #log_daemon_msg "Reloading $DESC" "$NAME" + #do_reload + #log_end_msg $? + #;; restart|force-reload) - # - # If the "reload" option is implemented then remove the - # 'force-reload' alias - # - log_daemon_msg "Restarting $DESC" "$NAME" - do_stop - case "$?" in - 0|1) - do_start - case "$?" in - 0) log_end_msg 0 ;; - 1) log_end_msg 1 ;; # Old process is still running - *) log_end_msg 1 ;; # Failed to start - esac - ;; - *) - # Failed to stop - log_end_msg 1 - ;; - esac - ;; + # + # If the "reload" option is implemented then remove the + # 'force-reload' alias + # + log_daemon_msg "Restarting $DESC" "$NAME" + do_stop + case "$?" in + 0|1) + do_start + case "$?" in + 0) log_end_msg 0 ;; + 1) log_end_msg 1 ;; # Old process is still running + *) log_end_msg 1 ;; # Failed to start + esac + ;; + *) + # Failed to stop + log_end_msg 1 + ;; + esac + ;; manage) - shift - if [ $(id -un) != 'passerelle' ]; then - sudo -H -u passerelle python /usr/lib/$NAME/manage.py "$@" - else - python /usr/lib/$NAME/manage.py "$@" - fi - ;; + shift + if [ $(id -un) != 'passerelle' ]; then + sudo -H -u passerelle python /usr/lib/$NAME/manage.py "$@" + else + python /usr/lib/$NAME/manage.py "$@" + fi + ;; create-schema) - shift - TENANT=$1 - log_daemon_msg "Creating tenant" "$TENANT" - if [ "x$TENANT_BASE" == "x" ]; then - log_end_msg 1 - else - TENANT_DIR="$TENANT_BASE/$TENANT/" - mkdir "$TENANT_DIR" "$TENANT_DIR/media/" "$TENANT_DIR/static" "$TENANT_DIR/templates" - $SCRIPTNAME manage create_schema - fi - ;; + shift + TENANT=$1 + log_daemon_msg "Creating tenant" "$TENANT" + if [ "x$TENANT_BASE" == "x" ]; then + log_end_msg 1 + else + TENANT_DIR="$TENANT_BASE/$TENANT/" + mkdir "$TENANT_DIR" "$TENANT_DIR/media/" "$TENANT_DIR/static" "$TENANT_DIR/templates" + $SCRIPTNAME manage create_schema + fi + ;; *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 - exit 3 - ;; + #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + exit 3 + ;; esac From 2fd547f4b509b940a42ed8286d3abde37cf85fb8 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 16 Sep 2014 12:04:54 +0200 Subject: [PATCH 37/81] In init.d reformat DAEMON_ARGS to uniformize with other projects --- init.d | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/init.d b/init.d index 2d09f78c..9de68d45 100755 --- a/init.d +++ b/init.d @@ -31,12 +31,16 @@ GROUP=$NAME [ -r /etc/default/$NAME ] && . /etc/default/$NAME DAEMON_ARGS="--pid $PIDFILE \ - --daemon --bind=unix:$SOCKFILE \ - --user $USER --group $GROUP \ - --access-logfile $LOG_DIR/gunicorn-access.log \ - --log-file $LOG_DIR/gunicorn-error.log \ - --workers=5 --worker-class=sync --timeout=60 \ - --name $NAME passerelle.wsgi:application" +--user $USER --group $GROUP \ +--daemon \ +--access-logfile $LOG_DIR/gunicorn-access.log \ +--log-file $LOG_DIR/gunicorn-error.log \ +--bind=unix:$SOCKFILE +--workers=10 \ +--worker-class=sync \ +--timeout=60 \ +--name $NAME +passerelle.wsgi:application" # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh From d4cf6ed999d6201c4436d43e83537bd8793e85e5 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 16 Sep 2014 12:05:44 +0200 Subject: [PATCH 38/81] Refactor migration and static files collections into their own functions in init.d --- init.d | 34 +++++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/init.d b/init.d index 9de68d45..75af5351 100755 --- a/init.d +++ b/init.d @@ -63,17 +63,6 @@ do_start() # 0 if daemon has been started # 1 if daemon was already running # 2 if daemon could not be started - - # Do migrations - if [ "x$TENANT_BASE" != "x" ]; then - $SCRIPTNAME create_schema - $SCRIPTNAME manage sync_schema --noinput - $SCRIPTNAME manage migrate_schema --noinput - else - $SCRIPTNAME manage syncdb --noinput - $SCRIPTNAME manage migrate --noinput - fi - start-stop-daemon --start --quiet --pidfile $PIDFILE --exec $DAEMON --test > /dev/null \ || return 1 start-stop-daemon --start --quiet --exec $DAEMON -- \ @@ -120,9 +109,30 @@ do_reload() { return 0 } +do_migrate() { + log_action_msg "Applying new migrations .." + if [ "x$TENANT_BASE" != "x" ]; then + su $USER -p -c "python /usr/lib/$NAME/manage.py create_schema" + su $USER -p -c "python /usr/lib/$NAME/manage.py sync_schema --noinput" + su $USER -p -c "python /usr/lib/$NAME/manage.py migrate_schema --noinput" + else + su $USER -p -c "python /usr/lib/$NAME/manage.py syncdb --migrate --noinput" + fi + log_action_msg ".. done" +} + +do_collectstatic() { + log_action_msg "Collect static files.." + su $USER -p -c "python /usr/lib/$NAME/manage.py collectstatic --noinput" + log_action_msg ".. done" +} + + case "$1" in start) log_daemon_msg "Starting $DESC " "$NAME" + do_migrate + do_collectstatic do_start case "$?" in 0|1) log_end_msg 0 ;; @@ -155,6 +165,8 @@ case "$1" in # 'force-reload' alias # log_daemon_msg "Restarting $DESC" "$NAME" + do_migrate + do_collectstatic do_stop case "$?" in 0|1) From d1cd660977ce28865515db6172c71a672b3b253c Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 16 Sep 2014 12:06:38 +0200 Subject: [PATCH 39/81] Activate reloading in init.d --- init.d | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/init.d b/init.d index 75af5351..13a3e8cc 100755 --- a/init.d +++ b/init.d @@ -150,15 +150,15 @@ case "$1" in status) status_of_proc "$DAEMON" "$NAME" && exit 0 || exit $? ;; - #reload|force-reload) + reload|force-reload) # # If do_reload() is not implemented then leave this commented out # and leave 'force-reload' as an alias for 'restart'. # - #log_daemon_msg "Reloading $DESC" "$NAME" - #do_reload - #log_end_msg $? - #;; + log_daemon_msg "Reloading $DESC" "$NAME" + do_reload + log_end_msg $? + ;; restart|force-reload) # # If the "reload" option is implemented then remove the @@ -204,8 +204,7 @@ case "$1" in fi ;; *) - #echo "Usage: $SCRIPTNAME {start|stop|restart|reload|force-reload}" >&2 - echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2 + echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2 exit 3 ;; esac From db95fa5c8d184aa5251ead1c1f113fdb37dcabc6 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Tue, 16 Sep 2014 12:07:57 +0200 Subject: [PATCH 40/81] In create-schema action add a failure message when TENANT_BASE is not defined --- init.d | 1 + 1 file changed, 1 insertion(+) diff --git a/init.d b/init.d index 13a3e8cc..cddba1b8 100755 --- a/init.d +++ b/init.d @@ -196,6 +196,7 @@ case "$1" in TENANT=$1 log_daemon_msg "Creating tenant" "$TENANT" if [ "x$TENANT_BASE" == "x" ]; then + log_failure_msg "TENANT_BASE is not set in /etc/default/$NAME" log_end_msg 1 else TENANT_DIR="$TENANT_BASE/$TENANT/" From d5639732edb83c84c0d1b83578fe5a8bd391a412 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 12:29:02 +0200 Subject: [PATCH 41/81] Use debian/dirs to create directories --- dirs | 7 +++++++ rules | 8 -------- 2 files changed, 7 insertions(+), 8 deletions(-) create mode 100644 dirs diff --git a/dirs b/dirs new file mode 100644 index 00000000..1489c6c4 --- /dev/null +++ b/dirs @@ -0,0 +1,7 @@ +/etc/default +/var/lib/passerelle +/var/lib/passerelle/tenants +/var/lib/passerelle/media +/var/log/passerelle +/usr/share/passerelle/static +/usr/lib/passerelle diff --git a/rules b/rules index d914188e..2ff1bcf5 100755 --- a/rules +++ b/rules @@ -19,13 +19,5 @@ override_dh_install: for ver in $(shell pyversions -vr); do \ ln -s /etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/passerelle/; \ done - install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle - install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle/tenants - install -d -m 0755 $(BUILD_DIR)/var/lib/passerelle/media - install -d -m 0755 $(BUILD_DIR)/var/run/passerelle - install -d -m 0755 $(BUILD_DIR)/var/log/passerelle - install -d -m 0755 $(BUILD_DIR)/usr/share/passerelle/static - install -d -m 0755 $(BUILD_DIR)/usr/lib/passerelle/ - install -m 0755 debian/default $(BUILD_DIR)/etc/default/passerelle mv $(BUILD_DIR)/usr/bin/passerelle_manage.py $(BUILD_DIR)/usr/lib/passerelle/manage.py From 2fc38dd270e93a84577d4b838e554abed36ba2e4 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 14:27:04 +0200 Subject: [PATCH 42/81] Fix typo in django command names in init.d --- init.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.d b/init.d index cddba1b8..af262b55 100755 --- a/init.d +++ b/init.d @@ -113,8 +113,8 @@ do_migrate() { log_action_msg "Applying new migrations .." if [ "x$TENANT_BASE" != "x" ]; then su $USER -p -c "python /usr/lib/$NAME/manage.py create_schema" - su $USER -p -c "python /usr/lib/$NAME/manage.py sync_schema --noinput" - su $USER -p -c "python /usr/lib/$NAME/manage.py migrate_schema --noinput" + su $USER -p -c "python /usr/lib/$NAME/manage.py sync_schemas --noinput --traceback" + su $USER -p -c "python /usr/lib/$NAME/manage.py migrate_schemas --noinput --traceback" else su $USER -p -c "python /usr/lib/$NAME/manage.py syncdb --migrate --noinput" fi From f3e5bd7b6f84c71216a44b26566ae3feb97f8eed Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 14:27:34 +0200 Subject: [PATCH 43/81] Pass unmodified environment to sudo when running the manager --- init.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.d b/init.d index af262b55..644e39f7 100755 --- a/init.d +++ b/init.d @@ -186,7 +186,7 @@ case "$1" in manage) shift if [ $(id -un) != 'passerelle' ]; then - sudo -H -u passerelle python /usr/lib/$NAME/manage.py "$@" + sudo -E -H -u passerelle python /usr/lib/$NAME/manage.py "$@" else python /usr/lib/$NAME/manage.py "$@" fi From 36324d4368d8e7c56359cfa96b5e2908658400a6 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 14:32:54 +0200 Subject: [PATCH 44/81] When creating a new schema make passerelle owner of the media/ directory --- init.d | 1 + 1 file changed, 1 insertion(+) diff --git a/init.d b/init.d index 644e39f7..a4e49b47 100755 --- a/init.d +++ b/init.d @@ -201,6 +201,7 @@ case "$1" in else TENANT_DIR="$TENANT_BASE/$TENANT/" mkdir "$TENANT_DIR" "$TENANT_DIR/media/" "$TENANT_DIR/static" "$TENANT_DIR/templates" + chown $USER:$GROUP "$TENANT_DIR/media/" $SCRIPTNAME manage create_schema fi ;; From bdab059a5e650dbe8e3b296287f8a696b5faf6bc Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 14:39:00 +0200 Subject: [PATCH 45/81] Obtain schema using get_tenant_by_domain and rename create-schema action to create-tenant --- init.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.d b/init.d index a4e49b47..f702b946 100755 --- a/init.d +++ b/init.d @@ -191,9 +191,9 @@ case "$1" in python /usr/lib/$NAME/manage.py "$@" fi ;; - create-schema) + create-tenant) shift - TENANT=$1 + TENANT=`su $USER -p -c "python /usr/lib/$NAME/manage.py get_tenant_by_domain \"$1\""` log_daemon_msg "Creating tenant" "$TENANT" if [ "x$TENANT_BASE" == "x" ]; then log_failure_msg "TENANT_BASE is not set in /etc/default/$NAME" From 409b2494f26af87ed0ad766cd502d0df9a45fe41 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 14:56:00 +0200 Subject: [PATCH 46/81] Reformat and use more variables to uniformize with hobo --- init.d | 42 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/init.d b/init.d index f702b946..3186f375 100755 --- a/init.d +++ b/init.d @@ -15,33 +15,34 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC=Passerelle NAME=passerelle DAEMON=/usr/bin/gunicorn -RUN_DIR=/var/run/passerelle +RUN_DIR=/var/run/$NAME PIDFILE=$RUN_DIR/$NAME.pid -LOG_DIR=/var/log/passerelle +LOG_DIR=/var/log/$NAME SCRIPTNAME=/etc/init.d/$NAME +MANAGE_SCRIPT=/usr/lib/$NAME/manage.py SOCKFILE=$RUN_DIR/$NAME.sock USER=$NAME GROUP=$NAME -# Exit if the package is not installed -[ -x $DAEMON ] || exit 0 - -# Read configuration variable file if it is present -[ -r /etc/default/$NAME ] && . /etc/default/$NAME - DAEMON_ARGS="--pid $PIDFILE \ --user $USER --group $GROUP \ --daemon \ --access-logfile $LOG_DIR/gunicorn-access.log \ --log-file $LOG_DIR/gunicorn-error.log \ ---bind=unix:$SOCKFILE +--bind=unix:$SOCKFILE \ --workers=10 \ --worker-class=sync \ --timeout=60 \ ---name $NAME +--name $NAME \ passerelle.wsgi:application" +# Exit if the package is not installed +[ -x $DAEMON ] || exit 0 + +# Read configuration variable file if it is present +[ -r /etc/default/$NAME ] && . /etc/default/$NAME + # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh @@ -49,7 +50,7 @@ passerelle.wsgi:application" # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions -# Create run directory (pid, sock, etc.) +# Create /run directory if [ ! -d $RUN_DIR ]; then install -d -m 755 -o $USER -g $GROUP $RUN_DIR fi @@ -112,22 +113,21 @@ do_reload() { do_migrate() { log_action_msg "Applying new migrations .." if [ "x$TENANT_BASE" != "x" ]; then - su $USER -p -c "python /usr/lib/$NAME/manage.py create_schema" - su $USER -p -c "python /usr/lib/$NAME/manage.py sync_schemas --noinput --traceback" - su $USER -p -c "python /usr/lib/$NAME/manage.py migrate_schemas --noinput --traceback" + su $USER -p -c "python $MANAGE_SCRIPT create_schema" + su $USER -p -c "python $MANAGE_SCRIPT sync_schemas --noinput --traceback" + su $USER -p -c "python $MANAGE_SCRIPT migrate_schemas --noinput --traceback" else - su $USER -p -c "python /usr/lib/$NAME/manage.py syncdb --migrate --noinput" + su $USER -p -c "python $MANAGE_SCRIPT syncdb --migrate --noinput" fi log_action_msg ".. done" } do_collectstatic() { log_action_msg "Collect static files.." - su $USER -p -c "python /usr/lib/$NAME/manage.py collectstatic --noinput" + su $USER -p -c "python $MANAGE_SCRIPT collectstatic --noinput" log_action_msg ".. done" } - case "$1" in start) log_daemon_msg "Starting $DESC " "$NAME" @@ -185,15 +185,15 @@ case "$1" in ;; manage) shift - if [ $(id -un) != 'passerelle' ]; then - sudo -E -H -u passerelle python /usr/lib/$NAME/manage.py "$@" + if [ $(id -un) != "$USER" ]; then + sudo -E -H -u $USER python $MANAGE_SCRIPT "$@" else - python /usr/lib/$NAME/manage.py "$@" + python $MANAGE_SCRIPT "$@" fi ;; create-tenant) shift - TENANT=`su $USER -p -c "python /usr/lib/$NAME/manage.py get_tenant_by_domain \"$1\""` + TENANT=`su $USER -p -c "python $MANAGE_SCRIPT get_tenant_by_domain \"$1\""` log_daemon_msg "Creating tenant" "$TENANT" if [ "x$TENANT_BASE" == "x" ]; then log_failure_msg "TENANT_BASE is not set in /etc/default/$NAME" From efc3f1e1a8ae6d41d6b038237a3a575e123daa38 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 14:56:28 +0200 Subject: [PATCH 47/81] Do a collectstatic and apply migration when reloading --- init.d | 2 ++ 1 file changed, 2 insertions(+) diff --git a/init.d b/init.d index 3186f375..5c25a3ef 100755 --- a/init.d +++ b/init.d @@ -156,6 +156,8 @@ case "$1" in # and leave 'force-reload' as an alias for 'restart'. # log_daemon_msg "Reloading $DESC" "$NAME" + do_collectstatic + do_migrate do_reload log_end_msg $? ;; From 505bd45188fc23ece6ebccb75616b21515744d20 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 14:56:55 +0200 Subject: [PATCH 48/81] When restarting do collectstatic and apply migrations between stop and start --- init.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.d b/init.d index 5c25a3ef..beeaf665 100755 --- a/init.d +++ b/init.d @@ -167,11 +167,11 @@ case "$1" in # 'force-reload' alias # log_daemon_msg "Restarting $DESC" "$NAME" - do_migrate - do_collectstatic do_stop case "$?" in 0|1) + do_migrate + do_collectstatic do_start case "$?" in 0) log_end_msg 0 ;; From 6c42b8ac0c5be1d54fb8b8b9f09b299cec21ccc7 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Thu, 18 Sep 2014 15:26:08 +0200 Subject: [PATCH 49/81] Remove --traceback option when syncing/migrating schemas --- init.d | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/init.d b/init.d index beeaf665..e24329c4 100755 --- a/init.d +++ b/init.d @@ -114,8 +114,8 @@ do_migrate() { log_action_msg "Applying new migrations .." if [ "x$TENANT_BASE" != "x" ]; then su $USER -p -c "python $MANAGE_SCRIPT create_schema" - su $USER -p -c "python $MANAGE_SCRIPT sync_schemas --noinput --traceback" - su $USER -p -c "python $MANAGE_SCRIPT migrate_schemas --noinput --traceback" + su $USER -p -c "python $MANAGE_SCRIPT sync_schemas --noinput" + su $USER -p -c "python $MANAGE_SCRIPT migrate_schemas --noinput" else su $USER -p -c "python $MANAGE_SCRIPT syncdb --migrate --noinput" fi From dea4e97759d80726aac51fcfc1f646d71257ac22 Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Fri, 19 Sep 2014 16:15:28 +0200 Subject: [PATCH 50/81] Allow to override the --bind option to gunicorn --- init.d | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/init.d b/init.d index e24329c4..f7db0e97 100755 --- a/init.d +++ b/init.d @@ -20,29 +20,29 @@ PIDFILE=$RUN_DIR/$NAME.pid LOG_DIR=/var/log/$NAME SCRIPTNAME=/etc/init.d/$NAME MANAGE_SCRIPT=/usr/lib/$NAME/manage.py -SOCKFILE=$RUN_DIR/$NAME.sock +BIND=unix:$RUN_DIR/$NAME.sock USER=$NAME GROUP=$NAME -DAEMON_ARGS="--pid $PIDFILE \ ---user $USER --group $GROUP \ ---daemon \ ---access-logfile $LOG_DIR/gunicorn-access.log \ ---log-file $LOG_DIR/gunicorn-error.log \ ---bind=unix:$SOCKFILE \ ---workers=10 \ ---worker-class=sync \ ---timeout=60 \ ---name $NAME \ -passerelle.wsgi:application" - # Exit if the package is not installed [ -x $DAEMON ] || exit 0 # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME +DAEMON_ARGS=${DAEMON_ARGS:-"--pid $PIDFILE \ +--user $USER --group $GROUP \ +--daemon \ +--access-logfile $LOG_DIR/gunicorn-access.log \ +--log-file $LOG_DIR/gunicorn-error.log \ +--bind=$BIND \ +--workers=10 \ +--worker-class=sync \ +--timeout=60 \ +--name $NAME \ +passerelle.wsgi:application"} + # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh From 85c73a3509cace52de10819452cd17289755f6ca Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 13:49:38 +0200 Subject: [PATCH 51/81] Adapt to new settings organization (#5593) --- README.Debian | 8 ------ config.py | 7 ++++++ control | 12 ++++----- debian_config.py | 13 ++++++++++ default | 8 +++++- init.d | 21 +++++++++++++--- install | 4 ++- local_settings.py | 62 ----------------------------------------------- passerelle-manage | 3 +++ postrm | 14 ----------- rules | 5 +--- 11 files changed, 57 insertions(+), 100 deletions(-) delete mode 100644 README.Debian create mode 100644 config.py create mode 100644 debian_config.py delete mode 100644 local_settings.py create mode 100644 passerelle-manage delete mode 100644 postrm diff --git a/README.Debian b/README.Debian deleted file mode 100644 index b22c44bc..00000000 --- a/README.Debian +++ /dev/null @@ -1,8 +0,0 @@ -passerelle for Debian ---------------------- - -To install the database please use the following command:: - - # su passerelle -p -c 'passerelle_manage.py syncdb' - - -- Jérôme Schneider Fri, 10 May 2013 10:08:45 +0200 diff --git a/config.py b/config.py new file mode 100644 index 00000000..7825858e --- /dev/null +++ b/config.py @@ -0,0 +1,7 @@ +# Configuration for passerelle. +# This file is sourced by "execfile" from /usr/lib/passerelle/debian_config.py + +#TIME_ZONE = 'Europe/Paris' +#LANGUAGE_CODE = 'fr-fr' + + diff --git a/control b/control index ae16516d..0dff98f1 100644 --- a/control +++ b/control @@ -3,7 +3,7 @@ Section: python Priority: optional Maintainer: Jérôme Schneider Build-Depends: debhelper (>= 8.0.0), - python-django (>= 1.5.0), + python-django, python-setuptools Standards-Version: 3.9.4 Homepage: https://dev.entrouvert.org/projects/passerelle @@ -12,15 +12,15 @@ Package: passerelle Architecture: all Depends: ${python:Depends}, ${misc:Depends}, - gunicorn (>= 0.14), - python-django (>= 1.5.0), + gunicorn, + python-django, python-django-jsonresponse, python-django-model-utils, - python-mako, - python-django-south (>= 0.8), python-django-south (<< 0.9), + python-django-south, python-setuptools, python-gadjo, sudo -Recommends: python-soappy, python-sqlalchemy, python-phpserialize +Recommends: python-soappy, python-phpserialize +Suggests: python-sqlalchemy, python-mako Description: Passerelle provides an uniform access to multiple data sources and services. Passerelle provides an uniform access to multiple data sources and services. diff --git a/debian_config.py b/debian_config.py new file mode 100644 index 00000000..283718f7 --- /dev/null +++ b/debian_config.py @@ -0,0 +1,13 @@ +from django.conf.settings import * +import os + +ETC_DIR = '/etc/passerelle' +VAR_DIR = '/var/lib/passerelle' +RUN_DIR = '/var/run/passerelle' +STATIC_ROOT = os.path.join(VAR_DIR, 'collected-static') +STATICFILES_DIRS = (os.path.join(VAR_DIR, 'static'),) + STATICFILES_DIRS +TEMPLATE_DIRS = (os.path.join(VAR_DIR, 'templates'),) + TEMPLATE_DIRS +LOCALE_PATHS = (os.path.join(VAR_DIR, 'locale'),) + LOCALE_PATHS +TENANT_BASE = os.path.join(VAR_DIR, 'tenants') + +execfile(os.path.join(ETC_DIR, 'config.py')) diff --git a/default b/default index 4350c8d7..0b22c24f 100644 --- a/default +++ b/default @@ -1 +1,7 @@ -# export TENANT_BASE=/var/lib/passerelle/tenants/ +# Default settings for passerelle. This file is sourced by /bin/sh from +# /etc/init.d/passerelle. + +# Settings flavor +DJANGO_SETTINGS_MODULE=passerelle.settings +# for multitenant mode, use : +# DJANGO_SETTINGS_MODULE=passerelle.tenant_settings diff --git a/init.d b/init.d index f7db0e97..043250c1 100755 --- a/init.d +++ b/init.d @@ -19,8 +19,13 @@ RUN_DIR=/var/run/$NAME PIDFILE=$RUN_DIR/$NAME.pid LOG_DIR=/var/log/$NAME SCRIPTNAME=/etc/init.d/$NAME -MANAGE_SCRIPT=/usr/lib/$NAME/manage.py BIND=unix:$RUN_DIR/$NAME.sock +WORKERS=5 +TIMEOUT=10 + +MANAGE_SCRIPT=/usr/lib/$NAME/manage.py +DJANGO_SETTINGS_MODULE=passerelle.settings +DJANGO_CONFIG_FILE=/usr/lib/$NAME/debian_config.py USER=$NAME GROUP=$NAME @@ -37,9 +42,9 @@ DAEMON_ARGS=${DAEMON_ARGS:-"--pid $PIDFILE \ --access-logfile $LOG_DIR/gunicorn-access.log \ --log-file $LOG_DIR/gunicorn-error.log \ --bind=$BIND \ ---workers=10 \ +--workers=$WORKERS \ --worker-class=sync \ ---timeout=60 \ +--timeout=$TIMEOUT \ --name $NAME \ passerelle.wsgi:application"} @@ -55,6 +60,14 @@ if [ ! -d $RUN_DIR ]; then install -d -m 755 -o $USER -g $GROUP $RUN_DIR fi +# environment for wsgi & settings +export DJANGO_SETTINGS_MODULE +export DJANGO_CONFIG_FILE +# multitenant mode +if [ "x$DJANGO_SETTINGS_MODULE" != "xpasserelle.tenant_settings" ]; then + TENANT_BASE=/var/lib/$NAME/tenants +fi + # # Function that starts the daemon/service # @@ -198,7 +211,7 @@ case "$1" in TENANT=`su $USER -p -c "python $MANAGE_SCRIPT get_tenant_by_domain \"$1\""` log_daemon_msg "Creating tenant" "$TENANT" if [ "x$TENANT_BASE" == "x" ]; then - log_failure_msg "TENANT_BASE is not set in /etc/default/$NAME" + log_failure_msg "multitenant mode not set in /etc/default/$NAME" log_end_msg 1 else TENANT_DIR="$TENANT_BASE/$TENANT/" diff --git a/install b/install index f4d0b320..d6a0fec9 100644 --- a/install +++ b/install @@ -1 +1,3 @@ -debian/local_settings.py /etc/passerelle/ +debian/passerelle-manage /usr/bin +debian/debian_config.py /usr/lib/passerelle +debian/config.py /etc/passerelle diff --git a/local_settings.py b/local_settings.py deleted file mode 100644 index 0ea8690c..00000000 --- a/local_settings.py +++ /dev/null @@ -1,62 +0,0 @@ -DEBUG = False -TEMPLATE_DEBUG = DEBUG - -# traceback recipients if DEBUG=False -ADMINS = ( -# ('root', 'root@localhost'), -# ('admin passerelle', 'admin-passerelle@domaine.com'), -) -MANAGERS = ADMINS - -# we're behind a pile of reverse-proxies... -# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts -ALLOWED_HOSTS = ['*'] - -# Local time zone for this installation. Choices can be found here: -# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name -# although not all choices may be available on all operating systems. -# In a Windows environment this must be set to your system time zone. -TIME_ZONE = 'Europe/Paris' - -# Language code for this installation. All choices can be found here: -# http://www.i18nguy.com/unicode/language-identifiers.html -LANGUAGE_CODE = 'fr-fr' - -# -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': '/var/lib/passerelle/passerelle.db', - } -} - -INSTALLED_APPS = ( - 'django.contrib.auth', - 'django.contrib.contenttypes', - 'django.contrib.sessions', - 'django.contrib.sites', - 'django.contrib.messages', - 'django.contrib.staticfiles', - # Uncomment the next line to enable the admin: - 'django.contrib.admin', - # Uncomment the next line to enable admin documentation: - # 'django.contrib.admindocs', - 'south', - 'passerelle.base', - 'passerelle.datasources', - 'passerelle.repost', - 'passerelle.messages', - 'passerelle.register', -# 'clicrdv', -# 'gdc', -# 'solis', -# 'makorepost', -# 'choosit', -) - -MEDIA_ROOT = '/var/lib/passerelle/media' -MEDIA_URL = '/passerelle/media/' - -STATIC_ROOT = '/var/lib/passerelle/static' -STATIC_URL = '/passerelle/static/' - diff --git a/passerelle-manage b/passerelle-manage new file mode 100644 index 00000000..f861a728 --- /dev/null +++ b/passerelle-manage @@ -0,0 +1,3 @@ +#!/bin/sh + +/etc/init.d/passerelle manage "$@" diff --git a/postrm b/postrm deleted file mode 100644 index 612f99b4..00000000 --- a/postrm +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/sh -# postrm script for passerelle -# -# see: dh_installdeb(1) - -set -e - -case "$1" in purge) - deluser --quiet --system passerelle > /dev/null || true - ;; - -esac - -exit 0 diff --git a/rules b/rules index 2ff1bcf5..bfa4903a 100755 --- a/rules +++ b/rules @@ -16,8 +16,5 @@ BUILD_DIR := 'debian/passerelle' override_dh_install: dh_install - for ver in $(shell pyversions -vr); do \ - ln -s /etc/passerelle/local_settings.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/passerelle/; \ - done - mv $(BUILD_DIR)/usr/bin/passerelle_manage.py $(BUILD_DIR)/usr/lib/passerelle/manage.py + mv $(BUILD_DIR)/usr/bin/manage.py $(BUILD_DIR)/usr/lib/passerelle/manage.py From b5a1437136f09de429b056c1f3abd7e19ac91337 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 16:31:47 +0200 Subject: [PATCH 52/81] smart passerelle-manage --- passerelle-manage | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) mode change 100644 => 100755 passerelle-manage diff --git a/passerelle-manage b/passerelle-manage old mode 100644 new mode 100755 index f861a728..27e4b726 --- a/passerelle-manage +++ b/passerelle-manage @@ -1,3 +1,21 @@ #!/bin/sh -/etc/init.d/passerelle manage "$@" +NAME=passerelle + +if test $(id -un) != "$NAME" +then + echo "error: must use $0 with user ${NAME}" + exit 1 +fi + +MANAGE_OPTIONS="--config=/usr/lib/${NAME}/debian_config.py" + +. /etc/default/$NAME +if test x"${DJANGO_SETTINGS_MODULE}" = "xpasserelle.tenant_settings" +then + MANAGE_OPTIONS="${MANAGE_OPTIONS} --multitenant" +fi + +echo python /usr/lib/$NAME/manage.py ${MANAGE_OPTIONS} "$@" +python /usr/lib/$NAME/manage.py ${MANAGE_OPTIONS} "$@" + From 16014db87e2c67601ddfcedbd33a355f356d3f4c Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 16:32:49 +0200 Subject: [PATCH 53/81] add SECRET_KEY = 'ChangeMe' in config.py --- config.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/config.py b/config.py index 7825858e..a6b0185e 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,7 @@ # Configuration for passerelle. -# This file is sourced by "execfile" from /usr/lib/passerelle/debian_config.py +# This file is sourced by "execfile" from /usr/lib/passerelle/debian_config.py + +SECRET_KEY = 'ChangeMe' #TIME_ZONE = 'Europe/Paris' #LANGUAGE_CODE = 'fr-fr' - - From 2ed8f343b8bd60dc175ca4fc41950ed6c0c881e7 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 16:33:41 +0200 Subject: [PATCH 54/81] debian_config.py is loaded by execfile: no import needed --- debian_config.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/debian_config.py b/debian_config.py index 283718f7..91a5452b 100644 --- a/debian_config.py +++ b/debian_config.py @@ -1,4 +1,5 @@ -from django.conf.settings import * +# This file is sourced by "execfile" from passerelle.settings + import os ETC_DIR = '/etc/passerelle' From d7c61acc7a3048026873130a5da493b358b56467 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 16:34:16 +0200 Subject: [PATCH 55/81] fix debian/dirs --- dirs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dirs b/dirs index 1489c6c4..a8b6d2b6 100644 --- a/dirs +++ b/dirs @@ -1,7 +1,9 @@ /etc/default +/etc/passerelle /var/lib/passerelle /var/lib/passerelle/tenants /var/lib/passerelle/media +/var/lib/passerelle/static /var/log/passerelle /usr/share/passerelle/static /usr/lib/passerelle From 7b6442dfb520a323ec7e9d1bb9ad468b131d0af9 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 16:35:00 +0200 Subject: [PATCH 56/81] fix manage.py calls in postinst --- postinst | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/postinst b/postinst index 1957bae3..de2ea04b 100644 --- a/postinst +++ b/postinst @@ -2,20 +2,26 @@ set -e +MANAGE="python /usr/lib/passerelle/manage.py --config=/usr/lib/passerelle/debian_config.py" + case "$1" in configure) + + # make sure the administrative user exists if ! getent passwd passerelle >/dev/null; then adduser --disabled-password --quiet --system \ --no-create-home --home /var/lib/passerelle \ --gecos "Passerelle software user" --group passerelle - chown passerelle:passerelle /var/log/passerelle - chown passerelle:passerelle /var/lib/passerelle - chown passerelle:passerelle /var/lib/passerelle/media fi - /etc/init.d/passerelle manage collectstatic --noinput --link + # ensure dirs ownership + chown passerelle:passerelle /var/log/passerelle + chown passerelle:passerelle /var/lib/passerelle + chown passerelle:passerelle /var/lib/passerelle/media + # populate /var/lib/passerelle/collected-static + $MANAGE collectstatic --noinput --link ;; reconfigure) - /etc/init.d/passerelle manage collectstatic --noinput --link + $MANAGE collectstatic --noinput --link ;; abort-upgrade|abort-remove|abort-deconfigure) From 91db31f15d18743a4279f044c4d9db99825d5af3 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 16:43:55 +0200 Subject: [PATCH 57/81] remove manage from init.d (first step) --- init.d | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/init.d b/init.d index 043250c1..3899da76 100755 --- a/init.d +++ b/init.d @@ -23,9 +23,9 @@ BIND=unix:$RUN_DIR/$NAME.sock WORKERS=5 TIMEOUT=10 -MANAGE_SCRIPT=/usr/lib/$NAME/manage.py DJANGO_SETTINGS_MODULE=passerelle.settings DJANGO_CONFIG_FILE=/usr/lib/$NAME/debian_config.py +MANAGE_SCRIPT="python /usr/lib/$NAME/manage.py --config=$DJANGO_CONFIG_FILE" USER=$NAME GROUP=$NAME @@ -126,18 +126,18 @@ do_reload() { do_migrate() { log_action_msg "Applying new migrations .." if [ "x$TENANT_BASE" != "x" ]; then - su $USER -p -c "python $MANAGE_SCRIPT create_schema" - su $USER -p -c "python $MANAGE_SCRIPT sync_schemas --noinput" - su $USER -p -c "python $MANAGE_SCRIPT migrate_schemas --noinput" + su $USER -p -c "$MANAGE_SCRIPT --multitenant create_schema" + su $USER -p -c "$MANAGE_SCRIPT --multitenant sync_schemas --noinput" + su $USER -p -c "$MANAGE_SCRIPT --multitenant migrate_schemas --noinput" else - su $USER -p -c "python $MANAGE_SCRIPT syncdb --migrate --noinput" + su $USER -p -c "$MANAGE_SCRIPT syncdb --migrate --noinput" fi log_action_msg ".. done" } do_collectstatic() { log_action_msg "Collect static files.." - su $USER -p -c "python $MANAGE_SCRIPT collectstatic --noinput" + su $USER -p -c "$MANAGE_SCRIPT collectstatic --noinput --link" log_action_msg ".. done" } @@ -198,26 +198,18 @@ case "$1" in ;; esac ;; - manage) - shift - if [ $(id -un) != "$USER" ]; then - sudo -E -H -u $USER python $MANAGE_SCRIPT "$@" - else - python $MANAGE_SCRIPT "$@" - fi - ;; create-tenant) - shift - TENANT=`su $USER -p -c "python $MANAGE_SCRIPT get_tenant_by_domain \"$1\""` - log_daemon_msg "Creating tenant" "$TENANT" if [ "x$TENANT_BASE" == "x" ]; then log_failure_msg "multitenant mode not set in /etc/default/$NAME" log_end_msg 1 + shift + TENANT=`su $USER -p -c "$MANAGE_SCRIPT --multitenant get_tenant_by_domain \"$1\""` + log_daemon_msg "Creating tenant" "$TENANT" else TENANT_DIR="$TENANT_BASE/$TENANT/" mkdir "$TENANT_DIR" "$TENANT_DIR/media/" "$TENANT_DIR/static" "$TENANT_DIR/templates" chown $USER:$GROUP "$TENANT_DIR/media/" - $SCRIPTNAME manage create_schema + su $USER -p -c "$MANAGE_SCRIPT --multitenant create_schema" fi ;; *) From f3bcef1589ae7ae1f1c422d8eb7c83fafec01841 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 16:58:25 +0200 Subject: [PATCH 58/81] debian/control: depends on python-requests --- control | 1 + 1 file changed, 1 insertion(+) diff --git a/control b/control index 0dff98f1..204b3fc8 100644 --- a/control +++ b/control @@ -17,6 +17,7 @@ Depends: ${python:Depends}, python-django-jsonresponse, python-django-model-utils, python-django-south, + python-requests, python-setuptools, python-gadjo, sudo From 5bb12774ddb5dd331268e0e2a2733ab5a4571391 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 17:04:12 +0200 Subject: [PATCH 59/81] config.py: sqlite3 DATABASES by default --- config.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index a6b0185e..fc99de09 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,29 @@ # Configuration for passerelle. # This file is sourced by "execfile" from /usr/lib/passerelle/debian_config.py -SECRET_KEY = 'ChangeMe' +SECRET_KEY = 'ChangeMeNow' + +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.sqlite3', + 'NAME': '/var/lib/passerelle/passerelle.sqlite3', + } +} + +# postgresql : +#DATABASES = { +# 'default': { +# 'ENGINE': 'django.db.backends.postgresql_psycopg2' +# 'NAME': 'passerelle', +# # if needed : +# 'USER': 'user', +# 'PASSWORD': 'password', +# 'HOST': 'localhost', +# 'PORT': '5432', +# } +#} + #TIME_ZONE = 'Europe/Paris' #LANGUAGE_CODE = 'fr-fr' + From 77b77c02fd728e7e55093da869d985994aea382d Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 17:10:29 +0200 Subject: [PATCH 60/81] init.d: fix multitenant detection Conclusion: I'm tired. --- init.d | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/init.d b/init.d index 3899da76..b6f1183d 100755 --- a/init.d +++ b/init.d @@ -64,8 +64,9 @@ fi export DJANGO_SETTINGS_MODULE export DJANGO_CONFIG_FILE # multitenant mode -if [ "x$DJANGO_SETTINGS_MODULE" != "xpasserelle.tenant_settings" ]; then +if [ "x$DJANGO_SETTINGS_MODULE" = "xpasserelle.tenant_settings" ]; then TENANT_BASE=/var/lib/$NAME/tenants + MANAGE_SCRIPT="$MANAGE_SCRIPT --multitenant" fi # @@ -126,9 +127,9 @@ do_reload() { do_migrate() { log_action_msg "Applying new migrations .." if [ "x$TENANT_BASE" != "x" ]; then - su $USER -p -c "$MANAGE_SCRIPT --multitenant create_schema" - su $USER -p -c "$MANAGE_SCRIPT --multitenant sync_schemas --noinput" - su $USER -p -c "$MANAGE_SCRIPT --multitenant migrate_schemas --noinput" + su $USER -p -c "$MANAGE_SCRIPT create_schema" + su $USER -p -c "$MANAGE_SCRIPT sync_schemas --noinput" + su $USER -p -c "$MANAGE_SCRIPT migrate_schemas --noinput" else su $USER -p -c "$MANAGE_SCRIPT syncdb --migrate --noinput" fi @@ -203,13 +204,13 @@ case "$1" in log_failure_msg "multitenant mode not set in /etc/default/$NAME" log_end_msg 1 shift - TENANT=`su $USER -p -c "$MANAGE_SCRIPT --multitenant get_tenant_by_domain \"$1\""` + TENANT=`su $USER -p -c "$MANAGE_SCRIPT get_tenant_by_domain \"$1\""` log_daemon_msg "Creating tenant" "$TENANT" else TENANT_DIR="$TENANT_BASE/$TENANT/" mkdir "$TENANT_DIR" "$TENANT_DIR/media/" "$TENANT_DIR/static" "$TENANT_DIR/templates" chown $USER:$GROUP "$TENANT_DIR/media/" - su $USER -p -c "$MANAGE_SCRIPT --multitenant create_schema" + su $USER -p -c "$MANAGE_SCRIPT create_schema" fi ;; *) From c06e8707125815eb68d66ff7fb16e7374ad73695 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 22:03:29 +0200 Subject: [PATCH 61/81] use /run instead of /var/run --- debian_config.py | 2 +- init.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/debian_config.py b/debian_config.py index 91a5452b..80ad8719 100644 --- a/debian_config.py +++ b/debian_config.py @@ -4,7 +4,7 @@ import os ETC_DIR = '/etc/passerelle' VAR_DIR = '/var/lib/passerelle' -RUN_DIR = '/var/run/passerelle' +RUN_DIR = '/run/passerelle' STATIC_ROOT = os.path.join(VAR_DIR, 'collected-static') STATICFILES_DIRS = (os.path.join(VAR_DIR, 'static'),) + STATICFILES_DIRS TEMPLATE_DIRS = (os.path.join(VAR_DIR, 'templates'),) + TEMPLATE_DIRS diff --git a/init.d b/init.d index b6f1183d..d8ee694a 100755 --- a/init.d +++ b/init.d @@ -15,7 +15,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin DESC=Passerelle NAME=passerelle DAEMON=/usr/bin/gunicorn -RUN_DIR=/var/run/$NAME +RUN_DIR=/run/$NAME PIDFILE=$RUN_DIR/$NAME.pid LOG_DIR=/var/log/$NAME SCRIPTNAME=/etc/init.d/$NAME From 65b44ddfd9021e3a53ef70347cbb78a0b0e40c67 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 2 Oct 2014 23:28:42 +0200 Subject: [PATCH 62/81] add details and comments in config.py --- config.py | 38 ++++++++++++++++++++++++++++++++------ 1 file changed, 32 insertions(+), 6 deletions(-) diff --git a/config.py b/config.py index fc99de09..55f2ead0 100644 --- a/config.py +++ b/config.py @@ -1,7 +1,35 @@ # Configuration for passerelle. +# You can override Passerelle default settings here + +# Passerelle is a Django application: for the full list of settings and their +# values, see https://docs.djangoproject.com/en/1.7/ref/settings/ +# For more information on settings see +# https://docs.djangoproject.com/en/1.7/topics/settings/ + +# WARNING! Quick-start development settings unsuitable for production! +# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ + # This file is sourced by "execfile" from /usr/lib/passerelle/debian_config.py -SECRET_KEY = 'ChangeMeNow' + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = '!!-Change-Me-Now-!!' + +# SECURITY WARNING: don't run with debug turned on in production! +DEBUG = True +TEMPLATE_DEBUG = True + +ADMINS = ( + # ('User 1', 'watchdog@domain.com'), + # ('User 2', 'janitor@domain.com'), +) + +# ALLOWED_HOSTS must be correct in production! +# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts +ALLOWED_HOSTS = [ + 'passerelle.domain.com', + 'passerelle.domain.com.', +] DATABASES = { 'default': { @@ -10,7 +38,7 @@ DATABASES = { } } -# postgresql : +# for a postgresql database: #DATABASES = { # 'default': { # 'ENGINE': 'django.db.backends.postgresql_psycopg2' @@ -23,7 +51,5 @@ DATABASES = { # } #} - -#TIME_ZONE = 'Europe/Paris' -#LANGUAGE_CODE = 'fr-fr' - +LANGUAGE_CODE = 'fr-fr' +TIME_ZONE = 'Europe/Paris' From a9442b99908c79cb607d81f49b4f774aa5768326 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Mon, 6 Oct 2014 16:41:01 +0200 Subject: [PATCH 63/81] debian package enable multitenant by default (#5634) --- config.py | 40 +++++++++++++++------------------------- control | 5 +++-- debian_config.py | 8 ++++++++ default | 7 ------- init.d | 2 +- passerelle-manage | 22 ++++++++++++---------- 6 files changed, 39 insertions(+), 45 deletions(-) delete mode 100644 default diff --git a/config.py b/config.py index 55f2ead0..e9cd1f1b 100644 --- a/config.py +++ b/config.py @@ -16,40 +16,30 @@ SECRET_KEY = '!!-Change-Me-Now-!!' # SECURITY WARNING: don't run with debug turned on in production! -DEBUG = True -TEMPLATE_DEBUG = True +DEBUG = False +TEMPLATE_DEBUG = False ADMINS = ( - # ('User 1', 'watchdog@domain.com'), - # ('User 2', 'janitor@domain.com'), + # ('User 1', 'watchdog@example.net'), + # ('User 2', 'janitor@example.net'), ) # ALLOWED_HOSTS must be correct in production! # See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts ALLOWED_HOSTS = [ - 'passerelle.domain.com', - 'passerelle.domain.com.', + 'passerelle.example.net', + 'passerelle.example.net.', + '.passerelle.example.net', + '.passerelle.example.net.', ] -DATABASES = { - 'default': { - 'ENGINE': 'django.db.backends.sqlite3', - 'NAME': '/var/lib/passerelle/passerelle.sqlite3', - } -} - -# for a postgresql database: -#DATABASES = { -# 'default': { -# 'ENGINE': 'django.db.backends.postgresql_psycopg2' -# 'NAME': 'passerelle', -# # if needed : -# 'USER': 'user', -# 'PASSWORD': 'password', -# 'HOST': 'localhost', -# 'PORT': '5432', -# } -#} +# Passerelle use a postgresql database +# Default: a local database named "passerelle" +# DATABASES['default']['name'] = 'passerelle' +# DATABASES['default']['user'] = 'passerelle' +# DATABASES['default']['password'] = '******' +# DATABASES['default']['host'] = 'localhost' +# DATABASES['default']['port'] = '5432' LANGUAGE_CODE = 'fr-fr' TIME_ZONE = 'Europe/Paris' diff --git a/control b/control index 204b3fc8..613bf520 100644 --- a/control +++ b/control @@ -12,11 +12,12 @@ Package: passerelle Architecture: all Depends: ${python:Depends}, ${misc:Depends}, + python-entrouvert; gunicorn, - python-django, + python-django (< 1.7), + python-django-south, python-django-jsonresponse, python-django-model-utils, - python-django-south, python-requests, python-setuptools, python-gadjo, diff --git a/debian_config.py b/debian_config.py index 80ad8719..961c14f0 100644 --- a/debian_config.py +++ b/debian_config.py @@ -5,10 +5,18 @@ import os ETC_DIR = '/etc/passerelle' VAR_DIR = '/var/lib/passerelle' RUN_DIR = '/run/passerelle' + STATIC_ROOT = os.path.join(VAR_DIR, 'collected-static') STATICFILES_DIRS = (os.path.join(VAR_DIR, 'static'),) + STATICFILES_DIRS TEMPLATE_DIRS = (os.path.join(VAR_DIR, 'templates'),) + TEMPLATE_DIRS LOCALE_PATHS = (os.path.join(VAR_DIR, 'locale'),) + LOCALE_PATHS TENANT_BASE = os.path.join(VAR_DIR, 'tenants') +DATABASES = { + 'default': { + 'ENGINE': 'django.db.backends.postgresql_psycopg2' + 'NAME': 'passerelle', + } +} + execfile(os.path.join(ETC_DIR, 'config.py')) diff --git a/default b/default deleted file mode 100644 index 0b22c24f..00000000 --- a/default +++ /dev/null @@ -1,7 +0,0 @@ -# Default settings for passerelle. This file is sourced by /bin/sh from -# /etc/init.d/passerelle. - -# Settings flavor -DJANGO_SETTINGS_MODULE=passerelle.settings -# for multitenant mode, use : -# DJANGO_SETTINGS_MODULE=passerelle.tenant_settings diff --git a/init.d b/init.d index d8ee694a..24976dc2 100755 --- a/init.d +++ b/init.d @@ -23,7 +23,7 @@ BIND=unix:$RUN_DIR/$NAME.sock WORKERS=5 TIMEOUT=10 -DJANGO_SETTINGS_MODULE=passerelle.settings +DJANGO_SETTINGS_MODULE=passerelle.tenant_settings DJANGO_CONFIG_FILE=/usr/lib/$NAME/debian_config.py MANAGE_SCRIPT="python /usr/lib/$NAME/manage.py --config=$DJANGO_CONFIG_FILE" diff --git a/passerelle-manage b/passerelle-manage index 27e4b726..a2b6711e 100755 --- a/passerelle-manage +++ b/passerelle-manage @@ -1,21 +1,23 @@ #!/bin/sh NAME=passerelle +MANAGE="/usr/lib/$NAME/manage.py --multitenant --config=/usr/lib/${NAME}/debian_config.py" -if test $(id -un) != "$NAME" +# check user +if test x$1 = x"--forceuser" then - echo "error: must use $0 with user ${NAME}" - exit 1 + shift +elif test $(id -un) != "$NAME" +then + echo "error: must use $0 with user ${NAME}" + exit 1 fi -MANAGE_OPTIONS="--config=/usr/lib/${NAME}/debian_config.py" - -. /etc/default/$NAME -if test x"${DJANGO_SETTINGS_MODULE}" = "xpasserelle.tenant_settings" +if test $# -eq 0 then - MANAGE_OPTIONS="${MANAGE_OPTIONS} --multitenant" + python ${MANAGE} help + exit 1 fi -echo python /usr/lib/$NAME/manage.py ${MANAGE_OPTIONS} "$@" -python /usr/lib/$NAME/manage.py ${MANAGE_OPTIONS} "$@" +python ${MANAGE} "$@" From 99d011319f207acbaa89cb10a9339b4846df7907 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Mon, 6 Oct 2014 22:50:49 +0200 Subject: [PATCH 64/81] SECRET_KEY created in /etc/passerelle/secret --- config.py | 2 +- postinst | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/config.py b/config.py index e9cd1f1b..86013fee 100644 --- a/config.py +++ b/config.py @@ -13,7 +13,7 @@ # SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = '!!-Change-Me-Now-!!' +SECRET_KEY = file('/etc/passerelle/secret').read() # SECURITY WARNING: don't run with debug turned on in production! DEBUG = False diff --git a/postinst b/postinst index de2ea04b..12bdf842 100644 --- a/postinst +++ b/postinst @@ -17,6 +17,14 @@ case "$1" in chown passerelle:passerelle /var/log/passerelle chown passerelle:passerelle /var/lib/passerelle chown passerelle:passerelle /var/lib/passerelle/media + # create a secret file + SECRET_FILE=/etc/passerelle/secret + if [ ! -f $SECRET_FILE ]; then + echo -n "Generating Django secret..." >&2 + cat /dev/urandom | tr -dc [:alnum:]-_\!\%\^:\; | head -c70 > $SECRET_FILE + chown root:passerelle $SECRET_FILE + chmod 0440 $SECRET_FILE + fi # populate /var/lib/passerelle/collected-static $MANAGE collectstatic --noinput --link ;; From 93cc7d6362a7bccac41fdd5648f6e8ed5cd849b1 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Tue, 7 Oct 2014 20:57:29 +0200 Subject: [PATCH 65/81] fix debian/control --- control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control b/control index 613bf520..51396fb5 100644 --- a/control +++ b/control @@ -12,7 +12,7 @@ Package: passerelle Architecture: all Depends: ${python:Depends}, ${misc:Depends}, - python-entrouvert; + python-entrouvert, gunicorn, python-django (< 1.7), python-django-south, From ae39b88ed86539a5523fe331193f5caa85966e4e Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Tue, 7 Oct 2014 20:57:58 +0200 Subject: [PATCH 66/81] debian/control: don't depends on sudo --- control | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/control b/control index 51396fb5..dc4d7d09 100644 --- a/control +++ b/control @@ -20,8 +20,7 @@ Depends: ${python:Depends}, python-django-model-utils, python-requests, python-setuptools, - python-gadjo, - sudo + python-gadjo Recommends: python-soappy, python-phpserialize Suggests: python-sqlalchemy, python-mako Description: Passerelle provides an uniform access to multiple data sources and services. From 25dc14f7f66a24f120d3a091642306100f0a0e82 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 9 Oct 2014 13:49:02 +0200 Subject: [PATCH 67/81] fix debian_config.py --- debian_config.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debian_config.py b/debian_config.py index 961c14f0..f298714e 100644 --- a/debian_config.py +++ b/debian_config.py @@ -14,8 +14,8 @@ TENANT_BASE = os.path.join(VAR_DIR, 'tenants') DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2' - 'NAME': 'passerelle', + 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'NAME': 'passerelle' } } From 113c29e410c147910730302a3f292d398d6f04a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Fri, 17 Oct 2014 17:52:55 +0200 Subject: [PATCH 68/81] init.d: remove create-tenant which doesn't work Create tenant will be added in djommon (#5199) --- init.d | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/init.d b/init.d index 24976dc2..2469de53 100755 --- a/init.d +++ b/init.d @@ -199,20 +199,6 @@ case "$1" in ;; esac ;; - create-tenant) - if [ "x$TENANT_BASE" == "x" ]; then - log_failure_msg "multitenant mode not set in /etc/default/$NAME" - log_end_msg 1 - shift - TENANT=`su $USER -p -c "$MANAGE_SCRIPT get_tenant_by_domain \"$1\""` - log_daemon_msg "Creating tenant" "$TENANT" - else - TENANT_DIR="$TENANT_BASE/$TENANT/" - mkdir "$TENANT_DIR" "$TENANT_DIR/media/" "$TENANT_DIR/static" "$TENANT_DIR/templates" - chown $USER:$GROUP "$TENANT_DIR/media/" - su $USER -p -c "$MANAGE_SCRIPT create_schema" - fi - ;; *) echo "Usage: $SCRIPTNAME {start|stop|status|restart|reload|force-reload}" >&2 exit 3 From f0e7894d91715c59fab8f93d1911a95a03c846ff Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Fri, 17 Oct 2014 18:00:52 +0200 Subject: [PATCH 69/81] postinst: ensure /var/lib/passerelle/tenants is owend by passerelle --- postinst | 1 + 1 file changed, 1 insertion(+) diff --git a/postinst b/postinst index 12bdf842..1bbe2900 100644 --- a/postinst +++ b/postinst @@ -17,6 +17,7 @@ case "$1" in chown passerelle:passerelle /var/log/passerelle chown passerelle:passerelle /var/lib/passerelle chown passerelle:passerelle /var/lib/passerelle/media + chown passerelle:passerelle /var/lib/passerelle/tenants # create a secret file SECRET_FILE=/etc/passerelle/secret if [ ! -f $SECRET_FILE ]; then From 4022ba011af940137fa3e59ddfec8d9662486183 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Mon, 20 Oct 2014 11:28:28 +0200 Subject: [PATCH 70/81] debian_config.py: add TENANT_TEMPLATE_DIRS which is mandatory Closes #5771 --- debian_config.py | 1 + 1 file changed, 1 insertion(+) diff --git a/debian_config.py b/debian_config.py index f298714e..9adccbc9 100644 --- a/debian_config.py +++ b/debian_config.py @@ -11,6 +11,7 @@ STATICFILES_DIRS = (os.path.join(VAR_DIR, 'static'),) + STATICFILES_DIRS TEMPLATE_DIRS = (os.path.join(VAR_DIR, 'templates'),) + TEMPLATE_DIRS LOCALE_PATHS = (os.path.join(VAR_DIR, 'locale'),) + LOCALE_PATHS TENANT_BASE = os.path.join(VAR_DIR, 'tenants') +TENANT_TEMPLATE_DIRS = (TENANT_BASE,) DATABASES = { 'default': { From c01e76f71aefef1950c17e1589a6fff26b791318 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Wed, 11 Mar 2015 19:39:06 +0100 Subject: [PATCH 71/81] multitenant-only packaging (#5634) --- README.Debian | 21 +++++++++ changelog | 79 +-------------------------------- config.py | 45 ------------------- control | 36 ++++++++++----- copyright | 2 +- debian_config.py | 82 ++++++++++++++++++++++++++++++----- dirs | 9 ---- nginx-example.conf | 39 +++++++++++++++++ passerelle-manage | 5 ++- passerelle.dirs | 5 +++ passerelle.docs | 2 + init.d => passerelle.init | 33 +++++--------- install => passerelle.install | 2 +- passerelle.postinst | 45 +++++++++++++++++++ postinst | 47 -------------------- python-passerelle.dirs | 1 + python-passerelle.docs | 2 + python-passerelle.install | 1 + rules | 10 +---- settings.py | 55 +++++++++++++++++++++++ 20 files changed, 286 insertions(+), 235 deletions(-) create mode 100644 README.Debian delete mode 100644 config.py delete mode 100644 dirs create mode 100644 nginx-example.conf create mode 100644 passerelle.dirs create mode 100644 passerelle.docs rename init.d => passerelle.init (82%) rename install => passerelle.install (65%) create mode 100644 passerelle.postinst delete mode 100644 postinst create mode 100644 python-passerelle.dirs create mode 100644 python-passerelle.docs create mode 100644 python-passerelle.install create mode 100644 settings.py diff --git a/README.Debian b/README.Debian new file mode 100644 index 00000000..94c637f7 --- /dev/null +++ b/README.Debian @@ -0,0 +1,21 @@ +Passerelle server for Debian +============================ + +Create a tenant +--------------- + + $ passerelle-manage create_tenant foo.passerelle.example.org + +Configure nginx +--------------- + +1. Copy /usr/share/doc/passerelle/nginx-example.conf to /etc/nginx/sites-available/passerelle.conf: + # cp /usr/share/doc/passerelle/nginx-example.conf /etc/nginx/sites-available/passerelle.conf + +2. Edit /etc/nginx/sites-available/passerelle.conf + +3. Enable nginx passerelle site: + # ln -s ../sites-available/passerelle.conf /etc/nginx/sites-enabled/ + +4. Reload nginx: + # service nginx restart diff --git a/changelog b/changelog index d214eab7..c8ff47b4 100644 --- a/changelog +++ b/changelog @@ -1,80 +1,5 @@ -passerelle (0.2.51.g24f717a-1) stable; urgency=low +passerelle (0.0-1) unstable; urgency=low - * update to last mmaster commit - - -- Jérôme Schneider Tue, 13 Aug 2013 10:47:34 +0200 - -passerelle (0.2.35.g040e1e3-2) stable; urgency=low - - * fix local_settings.py - - -- Jérôme Schneider Thu, 20 Jun 2013 16:27:27 +0200 - -passerelle (0.2.35.g040e1e3-1) stable; urgency=low - - * update to last mmaster commit - - -- Jérôme Schneider Thu, 20 Jun 2013 15:53:52 +0200 - -passerelle (0.2.34.ged4ed8a-1) stable; urgency=low - - * update to last mmaster commit - - -- Jérôme Schneider Thu, 20 Jun 2013 12:00:25 +0200 - -passerelle (0.2.29.gb8547fd-2) stable; urgency=low - - * debian: depends on python-django-south >= 0.8 - - -- Jérôme Schneider Tue, 18 Jun 2013 11:51:56 +0200 - -passerelle (0.2.29.gb8547fd-1) stable; urgency=low - - * merge to last master commit - - -- Jérôme Schneider Tue, 18 Jun 2013 11:48:15 +0200 - -passerelle (0.2.27.gd2a8e52-1) stable; urgency=low - - * merge to last master commit - * update INSTALLED_APPS in local_settings.py - * move static to /var/lib/passerelle/static - - -- Jérôme Schneider Mon, 17 Jun 2013 19:38:50 +0200 - -passerelle (0.2.21.g6b65b40-3) stable; urgency=low - - * update INSTALLED_APPS in local_settings.py - * add python-django-south dependency - - -- Jérôme Schneider Sun, 16 Jun 2013 19:56:43 +0200 - -passerelle (0.2.21.g6b65b40-2) stable; urgency=low - - * fix new local_settings link - - -- Jérôme Schneider Sun, 16 Jun 2013 18:40:34 +0200 - -passerelle (0.2.21.g6b65b40-1) stable; urgency=low - - * merge to last upstream commit - - -- Jérôme Schneider Sat, 15 Jun 2013 11:34:05 +0200 - -passerelle (0.2.12.g828e940-3) unstable; urgency=low - - * debian: cleaning package - - -- Jérôme Schneider Fri, 14 Jun 2013 16:00:47 +0200 - -passerelle (0.2.12.g828e940-2) unstable; urgency=low - - * debian: fix apache example - - -- Jérôme Schneider Thu, 13 Jun 2013 16:56:40 +0200 - -passerelle (0.2.12.g828e940-1) unstable; urgency=low - - * Initial release ... + * Initial release -- Jérôme Schneider Thu, 13 Jun 2013 12:29:42 +0200 diff --git a/config.py b/config.py deleted file mode 100644 index 86013fee..00000000 --- a/config.py +++ /dev/null @@ -1,45 +0,0 @@ -# Configuration for passerelle. -# You can override Passerelle default settings here - -# Passerelle is a Django application: for the full list of settings and their -# values, see https://docs.djangoproject.com/en/1.7/ref/settings/ -# For more information on settings see -# https://docs.djangoproject.com/en/1.7/topics/settings/ - -# WARNING! Quick-start development settings unsuitable for production! -# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ - -# This file is sourced by "execfile" from /usr/lib/passerelle/debian_config.py - - -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = file('/etc/passerelle/secret').read() - -# SECURITY WARNING: don't run with debug turned on in production! -DEBUG = False -TEMPLATE_DEBUG = False - -ADMINS = ( - # ('User 1', 'watchdog@example.net'), - # ('User 2', 'janitor@example.net'), -) - -# ALLOWED_HOSTS must be correct in production! -# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts -ALLOWED_HOSTS = [ - 'passerelle.example.net', - 'passerelle.example.net.', - '.passerelle.example.net', - '.passerelle.example.net.', -] - -# Passerelle use a postgresql database -# Default: a local database named "passerelle" -# DATABASES['default']['name'] = 'passerelle' -# DATABASES['default']['user'] = 'passerelle' -# DATABASES['default']['password'] = '******' -# DATABASES['default']['host'] = 'localhost' -# DATABASES['default']['port'] = '5432' - -LANGUAGE_CODE = 'fr-fr' -TIME_ZONE = 'Europe/Paris' diff --git a/control b/control index dc4d7d09..66e627e6 100644 --- a/control +++ b/control @@ -1,27 +1,39 @@ Source: passerelle Section: python Priority: optional -Maintainer: Jérôme Schneider +Maintainer: Thomas NOËL Build-Depends: debhelper (>= 8.0.0), - python-django, - python-setuptools -Standards-Version: 3.9.4 + python-django (>= 1.7), + python-setuptools (>= 0.6b3), + python-all (>= 2.6.6-3) +Standards-Version: 3.9.6 Homepage: https://dev.entrouvert.org/projects/passerelle +X-Python-Version: >= 2.7 -Package: passerelle +Package: python-passerelle Architecture: all Depends: ${python:Depends}, ${misc:Depends}, - python-entrouvert, - gunicorn, - python-django (< 1.7), - python-django-south, + python-django (>= 1.7), + python-gadjo python-django-jsonresponse, python-django-model-utils, python-requests, python-setuptools, - python-gadjo + python-django-jsonfield, Recommends: python-soappy, python-phpserialize Suggests: python-sqlalchemy, python-mako -Description: Passerelle provides an uniform access to multiple data sources and services. - Passerelle provides an uniform access to multiple data sources and services. +Description: Uniform access to multiple data sources and services (Python module) + +Package: passerelle +Architecture: all +Depends: ${misc:Depends}, + python-passerelle (= ${binary:Version}), + python-hobo, + python-django-tenant-schemas, + python-psycopg2, + python-memcache, + gunicorn +Recommends: python-django-mellon, nginx, postgresql, memcached +Description: Uniform access to multiple data sources and services + diff --git a/copyright b/copyright index 8c175a44..f8259931 100644 --- a/copyright +++ b/copyright @@ -1,5 +1,5 @@ Files: debian/* -Copyright: 2013 Jérôme Schneider +Copyright: 2015 Thomas NOËL License: GPL-2+ This package is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by diff --git a/debian_config.py b/debian_config.py index 9adccbc9..3db08905 100644 --- a/debian_config.py +++ b/debian_config.py @@ -2,22 +2,82 @@ import os -ETC_DIR = '/etc/passerelle' -VAR_DIR = '/var/lib/passerelle' -RUN_DIR = '/run/passerelle' +from django.conf import global_settings -STATIC_ROOT = os.path.join(VAR_DIR, 'collected-static') -STATICFILES_DIRS = (os.path.join(VAR_DIR, 'static'),) + STATICFILES_DIRS -TEMPLATE_DIRS = (os.path.join(VAR_DIR, 'templates'),) + TEMPLATE_DIRS -LOCALE_PATHS = (os.path.join(VAR_DIR, 'locale'),) + LOCALE_PATHS -TENANT_BASE = os.path.join(VAR_DIR, 'tenants') -TENANT_TEMPLATE_DIRS = (TENANT_BASE,) +PROJECT_NAME = 'passerelle' +ETC_DIR = '/etc/%s' % PROJECT_NAME +VAR_DIR = '/var/lib/%s' % PROJECT_NAME + +STATIC_ROOT = os.path.join(VAR_DIR, 'collectstatic') DATABASES = { 'default': { - 'ENGINE': 'django.db.backends.postgresql_psycopg2', + 'ENGINE': 'tenant_schemas.postgresql_backend', 'NAME': 'passerelle' } } -execfile(os.path.join(ETC_DIR, 'config.py')) +DATABASE_ROUTERS = ( + 'tenant_schemas.routers.TenantSyncRouter', +) + +TENANT_BASE = os.path.join(VAR_DIR, 'tenants') +TENANT_MODEL = 'multitenant.Tenant' + +SHARED_APPS = ( + 'hobo.multitenant', + 'django.contrib.auth', + 'django.contrib.contenttypes', + 'django.contrib.messages', + 'django.contrib.sessions', + 'django.contrib.staticfiles', + 'django.contrib.admin', +) + +TENANT_APPS = INSTALLED_APPS + +INSTALLED_APPS = ('hobo.multitenant',) + INSTALLED_APPS + + +TEMPLATE_LOADERS = ( + 'hobo.multitenant.template_loader.FilesystemLoader', +) + global_settings.TEMPLATE_LOADERS +TENANT_TEMPLATE_DIRS = (TENANT_BASE,) +TEMPLATE_CONTEXT_PROCESSORS = ( + 'django.core.context_processors.request', +) + global_settings.TEMPLATE_CONTEXT_PROCESSORS + +MIDDLEWARE_CLASSES = ( + 'hobo.multitenant.middleware.TenantMiddleware', + 'hobo.middleware.context.TemplateVarsMiddleware', +) + MIDDLEWARE_CLASSES + + +DEFAULT_FILE_STORAGE = 'hobo.multitenant.storage.TenantFileSystemStorage' + +CACHES = { + 'default': { + 'BACKEND': 'hobo.multitenant.cache.TenantCache', + # add a real Django cache backend, with its parameters if needed + 'REAL_BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', + 'LOCATION': '127.0.0.1:11211', + } +} + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = file('/etc/passerelle/secret').read() + +ADMINS = ( + ('root', 'root@localhost'), +) + +DEBUG = False +TEMPLATE_DEBUG = False + +EMAIL_SUBJECT_PREFIX = '[passerelle] ' + +# HTTPS +CSRF_COOKIE_SECURE = True +SESSION_COOKIE_SECURE = True + +execfile(os.path.join(ETC_DIR, 'settings.py')) diff --git a/dirs b/dirs deleted file mode 100644 index a8b6d2b6..00000000 --- a/dirs +++ /dev/null @@ -1,9 +0,0 @@ -/etc/default -/etc/passerelle -/var/lib/passerelle -/var/lib/passerelle/tenants -/var/lib/passerelle/media -/var/lib/passerelle/static -/var/log/passerelle -/usr/share/passerelle/static -/usr/lib/passerelle diff --git a/nginx-example.conf b/nginx-example.conf new file mode 100644 index 00000000..552b631b --- /dev/null +++ b/nginx-example.conf @@ -0,0 +1,39 @@ +server { + listen 443; + server_name *.passerelle.example.org; + + ssl on; + ssl_certificate /etc/ssl/certs/ssl-cert-snakeoil.pem; + ssl_certificate_key /etc/ssl/private/ssl-cert-snakeoil.key; + + access_log /var/log/nginx/passerelle.example.org-access.log combined; + error_log /var/log/nginx/passerelle.example.org-error.log; + + location ~ ^/static/(.+)$ { + root /; + try_files /var/lib/passerelle/tenants/$host/static/$1 + /var/lib/passerelle/collectstatic/$1 + =404; + } + + location / { + proxy_pass http://unix:/run/passerelle/passerelle.sock; + proxy_set_header Host $http_host; + proxy_set_header X-Forwarded-SSL on; + proxy_set_header X-Forwarded-Protocol ssl; + proxy_set_header X-Forwarded-Proto https; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } +} + +server { + listen 80; + server_name *.passerelle.example.org; + + access_log /var/log/nginx/passerelle.example.org-access.log combined; + error_log /var/log/nginx/passerelle.example.org-error.log; + + return 301 https://$host$request_uri; +} + diff --git a/passerelle-manage b/passerelle-manage index a2b6711e..12c80538 100755 --- a/passerelle-manage +++ b/passerelle-manage @@ -1,7 +1,10 @@ #!/bin/sh NAME=passerelle -MANAGE="/usr/lib/$NAME/manage.py --multitenant --config=/usr/lib/${NAME}/debian_config.py" +MANAGE="/usr/lib/passerelle/manage.py" + +# load Debian default configuration +export PASSERELLE_SETTINGS_FILE=/usr/lib/$NAME/debian_config.py # check user if test x$1 = x"--forceuser" diff --git a/passerelle.dirs b/passerelle.dirs new file mode 100644 index 00000000..728a2da0 --- /dev/null +++ b/passerelle.dirs @@ -0,0 +1,5 @@ +/etc/passerelle +/usr/lib/passerelle +/var/lib/passerelle/collectstatic +/var/lib/passerelle/tenants +/var/log/passerelle diff --git a/passerelle.docs b/passerelle.docs new file mode 100644 index 00000000..c8ba92f4 --- /dev/null +++ b/passerelle.docs @@ -0,0 +1,2 @@ +debian/nginx-example.conf +debian/README.Debian diff --git a/init.d b/passerelle.init similarity index 82% rename from init.d rename to passerelle.init index 2469de53..1b8647fa 100755 --- a/init.d +++ b/passerelle.init @@ -5,7 +5,7 @@ # Required-Stop: # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 -# Short-Description: Passerelle provides an uniform access to multiple data sources and services +# Short-Description: Passerelle server # Description: Passerelle provides an uniform access to multiple data sources and services. ### END INIT INFO @@ -21,11 +21,10 @@ LOG_DIR=/var/log/$NAME SCRIPTNAME=/etc/init.d/$NAME BIND=unix:$RUN_DIR/$NAME.sock WORKERS=5 -TIMEOUT=10 +TIMEOUT=30 -DJANGO_SETTINGS_MODULE=passerelle.tenant_settings -DJANGO_CONFIG_FILE=/usr/lib/$NAME/debian_config.py -MANAGE_SCRIPT="python /usr/lib/$NAME/manage.py --config=$DJANGO_CONFIG_FILE" +PASSERELLE_SETTINGS_FILE=/usr/lib/$NAME/debian_config.py +MANAGE_SCRIPT="/usr/bin/$NAME-manage" USER=$NAME GROUP=$NAME @@ -46,7 +45,7 @@ DAEMON_ARGS=${DAEMON_ARGS:-"--pid $PIDFILE \ --worker-class=sync \ --timeout=$TIMEOUT \ --name $NAME \ -passerelle.wsgi:application"} +$NAME.wsgi:application"} # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh @@ -60,14 +59,8 @@ if [ ! -d $RUN_DIR ]; then install -d -m 755 -o $USER -g $GROUP $RUN_DIR fi -# environment for wsgi & settings -export DJANGO_SETTINGS_MODULE -export DJANGO_CONFIG_FILE -# multitenant mode -if [ "x$DJANGO_SETTINGS_MODULE" = "xpasserelle.tenant_settings" ]; then - TENANT_BASE=/var/lib/$NAME/tenants - MANAGE_SCRIPT="$MANAGE_SCRIPT --multitenant" -fi +# environment for wsgi +export PASSERELLE_SETTINGS_FILE # # Function that starts the daemon/service @@ -120,25 +113,19 @@ do_reload() { # restarting (for example, when it is sent a SIGHUP), # then implement that here. # - start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name $NAME + start-stop-daemon --stop --signal 1 --quiet --pidfile $PIDFILE --name `basename $DAEMON` return 0 } do_migrate() { log_action_msg "Applying new migrations .." - if [ "x$TENANT_BASE" != "x" ]; then - su $USER -p -c "$MANAGE_SCRIPT create_schema" - su $USER -p -c "$MANAGE_SCRIPT sync_schemas --noinput" - su $USER -p -c "$MANAGE_SCRIPT migrate_schemas --noinput" - else - su $USER -p -c "$MANAGE_SCRIPT syncdb --migrate --noinput" - fi + su $USER -p -c "$MANAGE_SCRIPT migrate_schemas" log_action_msg ".. done" } do_collectstatic() { log_action_msg "Collect static files.." - su $USER -p -c "$MANAGE_SCRIPT collectstatic --noinput --link" + su $USER -p -c "$MANAGE_SCRIPT collectstatic --noinput" log_action_msg ".. done" } diff --git a/install b/passerelle.install similarity index 65% rename from install rename to passerelle.install index d6a0fec9..f1373093 100644 --- a/install +++ b/passerelle.install @@ -1,3 +1,3 @@ debian/passerelle-manage /usr/bin debian/debian_config.py /usr/lib/passerelle -debian/config.py /etc/passerelle +debian/settings.py /etc/passerelle diff --git a/passerelle.postinst b/passerelle.postinst new file mode 100644 index 00000000..c70d8a32 --- /dev/null +++ b/passerelle.postinst @@ -0,0 +1,45 @@ +#! /bin/sh + +set -e + +NAME="passerelle" +USER=$NAME +GROUP=$NAME +CONFIG_DIR="/etc/$NAME" + +case "$1" in + configure) + + # make sure the administrative user exists + if ! getent passwd $USER >/dev/null; then + adduser --disabled-password --quiet --system \ + --no-create-home --home /var/lib/$NAME \ + --gecos "Passerelle user" --group $USER + fi + # ensure dirs ownership + chown $USER:$GROUP /var/log/$NAME + chown $USER:$GROUP /var/lib/$NAME/collectstatic + chown $USER:$GROUP /var/lib/$NAME/tenants + # create a secret file + SECRET_FILE=$CONFIG_DIR/secret + if [ ! -f $SECRET_FILE ]; then + echo -n "Generating Django secret..." >&2 + cat /dev/urandom | tr -dc [:alnum:]-_\!\%\^:\; | head -c70 > $SECRET_FILE + chown root:$GROUP $SECRET_FILE + chmod 0440 $SECRET_FILE + echo "done" >&2 + fi + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +#DEBHELPER# + +exit 0 + diff --git a/postinst b/postinst deleted file mode 100644 index 1bbe2900..00000000 --- a/postinst +++ /dev/null @@ -1,47 +0,0 @@ -#! /bin/sh - -set -e - -MANAGE="python /usr/lib/passerelle/manage.py --config=/usr/lib/passerelle/debian_config.py" - -case "$1" in - configure) - - # make sure the administrative user exists - if ! getent passwd passerelle >/dev/null; then - adduser --disabled-password --quiet --system \ - --no-create-home --home /var/lib/passerelle \ - --gecos "Passerelle software user" --group passerelle - fi - # ensure dirs ownership - chown passerelle:passerelle /var/log/passerelle - chown passerelle:passerelle /var/lib/passerelle - chown passerelle:passerelle /var/lib/passerelle/media - chown passerelle:passerelle /var/lib/passerelle/tenants - # create a secret file - SECRET_FILE=/etc/passerelle/secret - if [ ! -f $SECRET_FILE ]; then - echo -n "Generating Django secret..." >&2 - cat /dev/urandom | tr -dc [:alnum:]-_\!\%\^:\; | head -c70 > $SECRET_FILE - chown root:passerelle $SECRET_FILE - chmod 0440 $SECRET_FILE - fi - # populate /var/lib/passerelle/collected-static - $MANAGE collectstatic --noinput --link - ;; - reconfigure) - $MANAGE collectstatic --noinput --link - ;; - - abort-upgrade|abort-remove|abort-deconfigure) - ;; - *) - echo "postinst called with unknown argument \`$1'" >&2 - exit 1 - ;; -esac - -#DEBHELPER# - -exit 0 - diff --git a/python-passerelle.dirs b/python-passerelle.dirs new file mode 100644 index 00000000..afe0cdd2 --- /dev/null +++ b/python-passerelle.dirs @@ -0,0 +1 @@ +/usr/lib/passerelle diff --git a/python-passerelle.docs b/python-passerelle.docs new file mode 100644 index 00000000..df15c73b --- /dev/null +++ b/python-passerelle.docs @@ -0,0 +1,2 @@ +README +LICENSE diff --git a/python-passerelle.install b/python-passerelle.install new file mode 100644 index 00000000..5fda4d4e --- /dev/null +++ b/python-passerelle.install @@ -0,0 +1 @@ +usr/lib/python2*/*-packages diff --git a/rules b/rules index bfa4903a..fdf88637 100755 --- a/rules +++ b/rules @@ -1,20 +1,14 @@ #!/usr/bin/make -f # -*- makefile -*- -# Sample debian/rules that uses debhelper. -# This file was originally written by Joey Hess and Craig Small. -# As a special exception, when this file is copied by dh-make into a -# dh-make output file, you may use that output file without restriction. -# This special exception was added by Craig Small in version 0.37 of dh-make. # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -BUILD_DIR := 'debian/passerelle' +PYTHON_PASSERELLE_DIR=$(CURDIR)/debian/python-passerelle %: dh $@ --with python2 override_dh_install: dh_install - mv $(BUILD_DIR)/usr/bin/manage.py $(BUILD_DIR)/usr/lib/passerelle/manage.py - + mv $(CURDIR)/debian/tmp/usr/bin/manage.py $(PYTHON_PASSERELLLE_DIR)/usr/lib/passerelle/manage.py diff --git a/settings.py b/settings.py new file mode 100644 index 00000000..6e7117ca --- /dev/null +++ b/settings.py @@ -0,0 +1,55 @@ +# Configuration for passerelle. +# You can override Passerelle default settings here + +# Passerelle is a Django application: for the full list of settings and their +# values, see https://docs.djangoproject.com/en/1.7/ref/settings/ +# For more information on settings see +# https://docs.djangoproject.com/en/1.7/topics/settings/ + +# WARNING! Quick-start development settings unsuitable for production! +# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/ + +# This file is sourced by "execfile" from /usr/lib/passerelle/debian_config.py + +# SECURITY WARNING: don't run with debug turned on in production! +#DEBUG = False +#TEMPLATE_DEBUG = False + +#ADMINS = ( +# ('User 1', 'poulpe@example.org'), +# ('User 2', 'janitor@example.net'), +#) + +# ALLOWED_HOSTS must be correct in production! +# See https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts +ALLOWED_HOSTS = ['*'] + +# If a tenant doesn't exist, the tenant middleware raise a 404 error. If you +# prefer to redirect to a specific site, use: +# TENANT_NOT_FOUND_REDIRECT_URL = 'http://www.example.net/' + +# Database +# Warning: don't change ENGINE, it must be 'tenant_schemas.postgresql_backend' +#DATABASES['default']['NAME'] = 'passerelle' +#DATABASES['default']['USER'] = 'passerelle' +#DATABASES['default']['PASSWORD'] = '******' +#DATABASES['default']['HOST'] = 'localhost' +#DATABASES['default']['PORT'] = '5432' + +LANGUAGE_CODE = 'fr-fr' +TIME_ZONE = 'Europe/Paris' + +# Email configuration +#EMAIL_SUBJECT_PREFIX = '[passerelle] ' +#SERVER_EMAIL = 'root@passerelle.example.org' +#DEFAULT_FROM_EMAIL = 'webmaster@passerelle.example.org' + +# SMTP configuration +#EMAIL_HOST = 'localhost' +#EMAIL_HOST_USER = '' +#EMAIL_HOST_PASSWORD = '' +#EMAIL_PORT = 25 + +# HTTPS +#CSRF_COOKIE_SECURE = True +#SESSION_COOKIE_SECURE = True From f7709d4d3c9e78fd7bbca222e03c49ebe28122eb Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 12 Mar 2015 14:12:59 +0100 Subject: [PATCH 72/81] control: don't force django version in Build-Depends --- control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control b/control index 66e627e6..a5f4eefb 100644 --- a/control +++ b/control @@ -3,7 +3,7 @@ Section: python Priority: optional Maintainer: Thomas NOËL Build-Depends: debhelper (>= 8.0.0), - python-django (>= 1.7), + python-django, python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3) Standards-Version: 3.9.6 From 6030fcda4f8676662c9dccb8db03f7e0d189f905 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 12 Mar 2015 14:19:33 +0100 Subject: [PATCH 73/81] ouch... typo in rules ... --- rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules b/rules index fdf88637..90ca9aac 100755 --- a/rules +++ b/rules @@ -11,4 +11,4 @@ PYTHON_PASSERELLE_DIR=$(CURDIR)/debian/python-passerelle override_dh_install: dh_install - mv $(CURDIR)/debian/tmp/usr/bin/manage.py $(PYTHON_PASSERELLLE_DIR)/usr/lib/passerelle/manage.py + mv $(CURDIR)/debian/tmp/usr/bin/manage.py $(PYTHON_PASSERELLE_DIR)/usr/lib/passerelle/manage.py From f2b7070aa6a0a9a68cedf2ffa8a601b44b25b2d3 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Thu, 12 Mar 2015 14:21:36 +0100 Subject: [PATCH 74/81] control: missing comma in dependencies --- control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control b/control index a5f4eefb..741e093f 100644 --- a/control +++ b/control @@ -15,7 +15,7 @@ Architecture: all Depends: ${python:Depends}, ${misc:Depends}, python-django (>= 1.7), - python-gadjo + python-gadjo, python-django-jsonresponse, python-django-model-utils, python-requests, From 2f50fceb6df065be90fde20572f03e5a75baa215 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Fri, 13 Mar 2015 13:44:07 +0100 Subject: [PATCH 75/81] debian_config.py, a bit of cleaning --- debian_config.py | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/debian_config.py b/debian_config.py index 3db08905..e0a31ab0 100644 --- a/debian_config.py +++ b/debian_config.py @@ -5,6 +5,17 @@ import os from django.conf import global_settings PROJECT_NAME = 'passerelle' + +DEBUG = False +TEMPLATE_DEBUG = False + +ADMINS = ( + ('root', 'root@localhost'), +) + +# SECURITY WARNING: keep the secret key used in production secret! +SECRET_KEY = file('/etc/%s/secret' % PROJECT_NAME).read() + ETC_DIR = '/etc/%s' % PROJECT_NAME VAR_DIR = '/var/lib/%s' % PROJECT_NAME @@ -13,7 +24,7 @@ STATIC_ROOT = os.path.join(VAR_DIR, 'collectstatic') DATABASES = { 'default': { 'ENGINE': 'tenant_schemas.postgresql_backend', - 'NAME': 'passerelle' + 'NAME': PROJECT_NAME, } } @@ -38,7 +49,6 @@ TENANT_APPS = INSTALLED_APPS INSTALLED_APPS = ('hobo.multitenant',) + INSTALLED_APPS - TEMPLATE_LOADERS = ( 'hobo.multitenant.template_loader.FilesystemLoader', ) + global_settings.TEMPLATE_LOADERS @@ -58,26 +68,17 @@ DEFAULT_FILE_STORAGE = 'hobo.multitenant.storage.TenantFileSystemStorage' CACHES = { 'default': { 'BACKEND': 'hobo.multitenant.cache.TenantCache', - # add a real Django cache backend, with its parameters if needed 'REAL_BACKEND': 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION': '127.0.0.1:11211', } } -# SECURITY WARNING: keep the secret key used in production secret! -SECRET_KEY = file('/etc/passerelle/secret').read() - -ADMINS = ( - ('root', 'root@localhost'), -) - -DEBUG = False -TEMPLATE_DEBUG = False - -EMAIL_SUBJECT_PREFIX = '[passerelle] ' # HTTPS CSRF_COOKIE_SECURE = True SESSION_COOKIE_SECURE = True +# Mail +EMAIL_SUBJECT_PREFIX = '[%s] ' % PROJECT_NAME + execfile(os.path.join(ETC_DIR, 'settings.py')) From 70bf879d4859b4cfefe7d3e5d0496678456f2d6b Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Fri, 13 Mar 2015 13:45:03 +0100 Subject: [PATCH 76/81] debian_config.py: add hobo_deploy (hobo agent) --- debian_config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/debian_config.py b/debian_config.py index e0a31ab0..ef118917 100644 --- a/debian_config.py +++ b/debian_config.py @@ -47,7 +47,7 @@ SHARED_APPS = ( TENANT_APPS = INSTALLED_APPS -INSTALLED_APPS = ('hobo.multitenant',) + INSTALLED_APPS +INSTALLED_APPS = ('hobo.multitenant', 'hobo.agent.common') + INSTALLED_APPS TEMPLATE_LOADERS = ( 'hobo.multitenant.template_loader.FilesystemLoader', From 6a51c77111deeec5afe36adcc5cd2fb72453410b Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Sat, 14 Mar 2015 11:56:58 +0100 Subject: [PATCH 77/81] simplify debian/rules --- python-passerelle.install | 1 + rules | 6 ------ 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/python-passerelle.install b/python-passerelle.install index 5fda4d4e..0c08527d 100644 --- a/python-passerelle.install +++ b/python-passerelle.install @@ -1 +1,2 @@ +usr/bin/manage.py /usr/lib/passerelle usr/lib/python2*/*-packages diff --git a/rules b/rules index 90ca9aac..de1bd885 100755 --- a/rules +++ b/rules @@ -4,11 +4,5 @@ # Uncomment this to turn on verbose mode. #export DH_VERBOSE=1 -PYTHON_PASSERELLE_DIR=$(CURDIR)/debian/python-passerelle - %: dh $@ --with python2 - -override_dh_install: - dh_install - mv $(CURDIR)/debian/tmp/usr/bin/manage.py $(PYTHON_PASSERELLE_DIR)/usr/lib/passerelle/manage.py From 13ec94c8afa7338dd47d6f54bbbf3e8d1a1b1b52 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Sat, 14 Mar 2015 12:08:41 +0100 Subject: [PATCH 78/81] fix some lintian warnings --- control | 4 ++-- passerelle.init | 4 ++-- pydist-overrides | 1 + source/format | 1 - 4 files changed, 5 insertions(+), 5 deletions(-) delete mode 100644 source/format diff --git a/control b/control index 741e093f..1e891570 100644 --- a/control +++ b/control @@ -2,7 +2,7 @@ Source: passerelle Section: python Priority: optional Maintainer: Thomas NOËL -Build-Depends: debhelper (>= 8.0.0), +Build-Depends: debhelper (>= 8.0.0), dh-python, python-django, python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3) @@ -27,7 +27,7 @@ Description: Uniform access to multiple data sources and services (Python module Package: passerelle Architecture: all -Depends: ${misc:Depends}, +Depends: ${misc:Depends}, adduser, python-passerelle (= ${binary:Version}), python-hobo, python-django-tenant-schemas, diff --git a/passerelle.init b/passerelle.init index 1b8647fa..45d28687 100755 --- a/passerelle.init +++ b/passerelle.init @@ -1,8 +1,8 @@ #!/bin/sh ### BEGIN INIT INFO # Provides: passerelle -# Required-Start: $network $local_fs -# Required-Stop: +# Required-Start: $network $local_fs $remote_fs +# Required-Stop: $network $local_fs $remote_fs # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Passerelle server diff --git a/pydist-overrides b/pydist-overrides index 970cfa2a..cf35c895 100644 --- a/pydist-overrides +++ b/pydist-overrides @@ -1 +1,2 @@ jsonfield python-django-jsonfield +django-jsonresponse python-django-jsonresponse diff --git a/source/format b/source/format deleted file mode 100644 index 163aaf8d..00000000 --- a/source/format +++ /dev/null @@ -1 +0,0 @@ -3.0 (quilt) From 5d88ee2883f49604ffc0b867679e4eb98a7be1d4 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Sat, 14 Mar 2015 12:39:18 +0100 Subject: [PATCH 79/81] dh-python is not in wheezy --- control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control b/control index 1e891570..cc2ae326 100644 --- a/control +++ b/control @@ -2,7 +2,7 @@ Source: passerelle Section: python Priority: optional Maintainer: Thomas NOËL -Build-Depends: debhelper (>= 8.0.0), dh-python, +Build-Depends: debhelper (>= 8.0.0), python-django, python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3) From 1d9f54f787d13c641d66b4d5a401c91be67ceb40 Mon Sep 17 00:00:00 2001 From: Thomas NOEL Date: Tue, 17 Mar 2015 17:47:25 +0100 Subject: [PATCH 80/81] debian_config.py: remove obsolete TemplateVarsMiddleware --- debian_config.py | 1 - 1 file changed, 1 deletion(-) diff --git a/debian_config.py b/debian_config.py index ef118917..b0272bf0 100644 --- a/debian_config.py +++ b/debian_config.py @@ -59,7 +59,6 @@ TEMPLATE_CONTEXT_PROCESSORS = ( MIDDLEWARE_CLASSES = ( 'hobo.multitenant.middleware.TenantMiddleware', - 'hobo.middleware.context.TemplateVarsMiddleware', ) + MIDDLEWARE_CLASSES From cd367dca1b743666174862dc659b2276ce01cf1b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 17 Mar 2015 18:53:47 +0100 Subject: [PATCH 81/81] activate django-mellon support by default (#6759) --- control | 3 ++- debian_config.py | 6 ++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/control b/control index cc2ae326..897e4040 100644 --- a/control +++ b/control @@ -33,7 +33,8 @@ Depends: ${misc:Depends}, adduser, python-django-tenant-schemas, python-psycopg2, python-memcache, + python-django-mellon, gunicorn -Recommends: python-django-mellon, nginx, postgresql, memcached +Recommends: nginx, postgresql, memcached Description: Uniform access to multiple data sources and services diff --git a/debian_config.py b/debian_config.py index b0272bf0..8ddb79fb 100644 --- a/debian_config.py +++ b/debian_config.py @@ -16,6 +16,9 @@ ADMINS = ( # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = file('/etc/%s/secret' % PROJECT_NAME).read() +# SAML2 authentication +INSTALLED_APPS += ('mellon',) + ETC_DIR = '/etc/%s' % PROJECT_NAME VAR_DIR = '/var/lib/%s' % PROJECT_NAME @@ -64,6 +67,9 @@ MIDDLEWARE_CLASSES = ( DEFAULT_FILE_STORAGE = 'hobo.multitenant.storage.TenantFileSystemStorage' +# SAML2: search IdP in +MELLON_ADAPTER = ('hobo.multitenant.mellon.MellonAdapter',) + CACHES = { 'default': { 'BACKEND': 'hobo.multitenant.cache.TenantCache',