From b7ed4c754aaff2dc86ab9b9613ddadf97c4e5399 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Fri, 18 Oct 2013 19:45:03 +0200 Subject: [PATCH 01/26] Initial release --- changelog | 5 ++ compat | 1 + control | 12 ++++ files | 1 + init.d | 161 ++++++++++++++++++++++++++++++++++++++++++++++++ install | 1 + local_config.py | 30 +++++++++ rules | 10 +++ source/format | 1 + 9 files changed, 222 insertions(+) create mode 100644 changelog create mode 100644 compat create mode 100644 control create mode 100644 files create mode 100644 init.d create mode 100644 install create mode 100644 local_config.py create mode 100755 rules create mode 100644 source/format diff --git a/changelog b/changelog new file mode 100644 index 0000000..9b082d8 --- /dev/null +++ b/changelog @@ -0,0 +1,5 @@ +mandaye-cam (0.1.0.g9ebbd69-1) unstable; urgency=low + + * source package automatically created by stdeb 0.6.0+git + + -- Jerome Schneider Fri, 18 Oct 2013 17:06:18 +0200 diff --git a/compat b/compat new file mode 100644 index 0000000..7f8f011 --- /dev/null +++ b/compat @@ -0,0 +1 @@ +7 diff --git a/control b/control new file mode 100644 index 0000000..7b3c8c7 --- /dev/null +++ b/control @@ -0,0 +1,12 @@ +Source: mandaye-cam +Maintainer: Jerome Schneider +Section: python +Priority: optional +Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 7.4.3) +Standards-Version: 3.9.1 + +Package: mandaye-cam +Architecture: all +Depends: ${misc:Depends}, ${python:Depends} +Description: CAM is a Mandaye project, modular reverse proxy to authentic + diff --git a/files b/files new file mode 100644 index 0000000..0d75f21 --- /dev/null +++ b/files @@ -0,0 +1 @@ +python-mandaye-cam_0.1.0.g9ebbd69-1_all.deb python optional diff --git a/init.d b/init.d new file mode 100644 index 0000000..1ddd880 --- /dev/null +++ b/init.d @@ -0,0 +1,161 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: mandaye-cam +# Required-Start: $network $local_fs +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: authentication reverse proxy for CAM +# Description: authentication reverse proxy for Montpellier Agglomeration +### END INIT INFO + +# Author: Jérôme Schneider + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +DESC=compte-meyzieu +NAME=compte-meyzieu +DAEMON=/usr/bin/gunicorn +PIDFILE=/var/run/mandaye-cam/$NAME.pid +LOG_DIR=/var/log/mandaye-cam +SCRIPTNAME=/etc/init.d/$NAME + +USER=mandaye-cam +GROUP=mandaye-cam + +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:8022 \ +--workers=10 \ +--worker-class=sync \ +--timeout=60 \ +cam.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 0000000..4be9bc3 --- /dev/null +++ b/install @@ -0,0 +1 @@ +debian/local_config.py /etc/mandaye-cam/ diff --git a/local_config.py b/local_config.py new file mode 100644 index 0000000..b6a0b6c --- /dev/null +++ b/local_config.py @@ -0,0 +1,30 @@ +import os +import logging + +_PROJECT_PATH = os.path.join(os.path.dirname(__file__), '..') + +db_url = 'sqlite:///' + os.path.join(_PROJECT_PATH, 'data/test.db') + +debug = False +log_file = os.path.join('/var/log/mandaye-cam/mandaye.log') +log_level = logging.INFO + +# Encrypt service provider passwords with a secret +# You should install pycypto to use this feature +encrypt_sp_password = True +# Must be a 16, 24, or 32 bytes long +encrypt_secret = 'CHANGE_ME' + +static_root = os.path.join(_PROJECT_PATH, 'cam/static') + +hosts = { + 'archimed.montpellier.entrouvert.org': [ + {'path': r'/', + 'target': 'http://ermes2.montpellier-agglo.com', + 'mapping': 'cam.configs.archimed_saml.archimed_mapping' + }, + { 'path': r'/static', + 'static': static_root + } + ], +} diff --git a/rules b/rules new file mode 100755 index 0000000..45b70b4 --- /dev/null +++ b/rules @@ -0,0 +1,10 @@ +#!/usr/bin/make -f + +%: + dh $@ --with python2 + +override_dh_install: + dh_install + for ver in $(shell pyversions -vr); do \ + ln -s /etc/mandaye-cam/local_config.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/cam/; \ + done diff --git a/source/format b/source/format new file mode 100644 index 0000000..163aaf8 --- /dev/null +++ b/source/format @@ -0,0 +1 @@ +3.0 (quilt) From 330fb9d86f00265145f35334d310f633351bd6c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 14:49:52 +0200 Subject: [PATCH 02/26] debian: first release --- control | 1 + files | 1 - init.d | 3 +-- local_config.py | 54 +++++++++++++++++++++++++++++++++---------------- postinst | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ rules | 5 +++++ 6 files changed, 98 insertions(+), 20 deletions(-) delete mode 100644 files mode change 100644 => 100755 init.d create mode 100644 postinst diff --git a/control b/control index 7b3c8c7..82ff86a 100644 --- a/control +++ b/control @@ -4,6 +4,7 @@ Section: python Priority: optional Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3), debhelper (>= 7.4.3) Standards-Version: 3.9.1 +X-Python-Version: current Package: mandaye-cam Architecture: all diff --git a/files b/files deleted file mode 100644 index 0d75f21..0000000 --- a/files +++ /dev/null @@ -1 +0,0 @@ -python-mandaye-cam_0.1.0.g9ebbd69-1_all.deb python optional diff --git a/init.d b/init.d old mode 100644 new mode 100755 index 1ddd880..0ae758c --- a/init.d +++ b/init.d @@ -12,8 +12,7 @@ # Author: Jérôme Schneider PATH=/sbin:/usr/sbin:/bin:/usr/bin -DESC=compte-meyzieu -NAME=compte-meyzieu +NAME=mandaye-cam DAEMON=/usr/bin/gunicorn PIDFILE=/var/run/mandaye-cam/$NAME.pid LOG_DIR=/var/log/mandaye-cam diff --git a/local_config.py b/local_config.py index b6a0b6c..95cd37a 100644 --- a/local_config.py +++ b/local_config.py @@ -1,22 +1,6 @@ -import os import logging -_PROJECT_PATH = os.path.join(os.path.dirname(__file__), '..') - -db_url = 'sqlite:///' + os.path.join(_PROJECT_PATH, 'data/test.db') - -debug = False -log_file = os.path.join('/var/log/mandaye-cam/mandaye.log') -log_level = logging.INFO - -# Encrypt service provider passwords with a secret -# You should install pycypto to use this feature -encrypt_sp_password = True -# Must be a 16, 24, or 32 bytes long -encrypt_secret = 'CHANGE_ME' - -static_root = os.path.join(_PROJECT_PATH, 'cam/static') - +## Virtual hosts configuration hosts = { 'archimed.montpellier.entrouvert.org': [ {'path': r'/', @@ -28,3 +12,39 @@ hosts = { } ], } + +## Database configuration +db_url = 'sqlite:///var/lib/mandaye-cam/cam.db' + +## Logging configuration +debug = False +log_file = '/var/log/mandaye-cam/mandaye.log' +log_level = logging.INFO + +## PATH +# Data directory +data_dir = '/var/lib/mandaye-cam/data' + +## Email notification configuration +email_notification = True +smtp_host = 'localhost' +smtp_port = 25 +email_from = 'traceback+mandaye-cam@entrouvert.com' +email_to = ['admin+mandaye-cam@entrouvert.com'] + + +## Session configuration +# http://beaker.readthedocs.org/en/latest/configuration.html#options-for-sessions-and-caching +session_opts = { + 'session.type': 'file', + 'session.cookie_expires': True, + 'session.timeout': 3600, + 'session.data_dir': '/var/lib/mandaye-cam/sessions' +} + +## Encrypt service provider passwords with a secret +# You should install pycypto to use this feature +encrypt_sp_password = True +# Must be a 16, 24, or 32 bytes long +encrypt_secret = 'CHANGEME' + diff --git a/postinst b/postinst new file mode 100644 index 0000000..c8e2958 --- /dev/null +++ b/postinst @@ -0,0 +1,54 @@ +#!/bin/sh +# +# Postinst script for mandaye-cam +# + +set -e + +USER=mandaye-cam +G0ROUP=mandaye-cam +NAME=mandaye-cam + +case "$1" in + configure) + if ! getent group $GROUP > /dev/null 2>&1; then + echo -n "Adding group $GROUP.." + addgroup --quiet --system $GROUP + echo "..done" + fi + if ! getent passwd $USER > /dev/null 2>&1; then + echo -n "Adding user $USER.." + adduser --quiet --system --gecos "Mandaye CAM daemon" \ + --ingroup $GROUP \ + --no-create-home --home $HOME \ + $USER + echo "..done" + fi + + chown -R $USER:$GROUP /var/lib/$NAME /var/run/$NAME /var/log/$NAME + + if [ -z "$2" ]; then + echo -n "Creating database.." + su $USER -p -c "/usr/bin/cam_mandaye_manager --createdb" + echo "..done" + fi + ;; + + reconfigure) + ;; + + abort-upgrade|abort-remove|abort-deconfigure) + ;; + + *) + echo "postinst called with unknown argument \`$1'" >&2 + exit 1 + ;; +esac + +# dh_installdeb will replace this with shell code automatically +# generated by other debhelper scripts. + +#DEBHELPER# + +exit 0 diff --git a/rules b/rules index 45b70b4..9f5658b 100755 --- a/rules +++ b/rules @@ -1,5 +1,7 @@ #!/usr/bin/make -f +BUILD_DIR := 'debian/mandaye-cam' + %: dh $@ --with python2 @@ -8,3 +10,6 @@ override_dh_install: for ver in $(shell pyversions -vr); do \ ln -s /etc/mandaye-cam/local_config.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/cam/; \ done + install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam + install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-cam + install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-cam From c935f4ad41766c51fdf0b47b4b8237c9b69b23ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 15:15:01 +0200 Subject: [PATCH 03/26] pydist-overrides: define mandaye and crypto --- pydist-overrides | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 pydist-overrides diff --git a/pydist-overrides b/pydist-overrides new file mode 100644 index 0000000..d10358f --- /dev/null +++ b/pydist-overrides @@ -0,0 +1,2 @@ +mandaye python-mandaye +pycrypto python-crypto From 8edc813c6a9b818240af4f39e63f03a0fb879717 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 16:31:16 +0200 Subject: [PATCH 04/26] postinst: fix bad variable name --- postinst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/postinst b/postinst index c8e2958..5b2a773 100644 --- a/postinst +++ b/postinst @@ -6,7 +6,7 @@ set -e USER=mandaye-cam -G0ROUP=mandaye-cam +GROUP=mandaye-cam NAME=mandaye-cam case "$1" in From ed4df7fb4e146e8c4b5427d00b595b82b655de80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 16:50:34 +0200 Subject: [PATCH 05/26] local_config: fix configuration --- local_config.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/local_config.py b/local_config.py index 95cd37a..98471a5 100644 --- a/local_config.py +++ b/local_config.py @@ -1,4 +1,10 @@ import logging +import os + +_PROJECT_PATH = os.path.join(os.path.dirname(__file__), '..') + +# Static folder +static_root = os.path.join(_PROJECT_PATH, 'cam/static') ## Virtual hosts configuration hosts = { From de592ce08c1f106e9f3e319134f726a6803f0f52 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 16:53:22 +0200 Subject: [PATCH 06/26] gunicorn: use 5 workers instead of 10 --- init.d | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/init.d b/init.d index 0ae758c..c686ca0 100755 --- a/init.d +++ b/init.d @@ -27,7 +27,7 @@ DAEMON_ARGS="--pid $PIDFILE \ --access-logfile $LOG_DIR/gunicorn-access.log \ --log-file $LOG_DIR/gunicorn-error.log \ --bind=127.0.0.1:8022 \ ---workers=10 \ +--workers=5 \ --worker-class=sync \ --timeout=60 \ cam.wsgi:application" From 56b793b0c7175f2a9200f894669895bc9ca0da01 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 17:34:10 +0200 Subject: [PATCH 07/26] init.d: fix daemon --- init.d | 2 +- local_config.py | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/init.d b/init.d index c686ca0..b43bbba 100755 --- a/init.d +++ b/init.d @@ -13,7 +13,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin NAME=mandaye-cam -DAEMON=/usr/bin/gunicorn +DAEMON=/usr/bin/cam_mandaye_server PIDFILE=/var/run/mandaye-cam/$NAME.pid LOG_DIR=/var/log/mandaye-cam SCRIPTNAME=/etc/init.d/$NAME diff --git a/local_config.py b/local_config.py index 98471a5..5a7f8f4 100644 --- a/local_config.py +++ b/local_config.py @@ -3,8 +3,6 @@ import os _PROJECT_PATH = os.path.join(os.path.dirname(__file__), '..') -# Static folder -static_root = os.path.join(_PROJECT_PATH, 'cam/static') ## Virtual hosts configuration hosts = { @@ -13,9 +11,6 @@ hosts = { 'target': 'http://ermes2.montpellier-agglo.com', 'mapping': 'cam.configs.archimed_saml.archimed_mapping' }, - { 'path': r'/static', - 'static': static_root - } ], } @@ -30,12 +25,14 @@ log_level = logging.INFO ## PATH # Data directory data_dir = '/var/lib/mandaye-cam/data' +# Static folder +static_root = '/usr/share/mandaye-cam/static' ## Email notification configuration email_notification = True smtp_host = 'localhost' smtp_port = 25 -email_from = 'traceback+mandaye-cam@entrouvert.com' +email_from = 'admin+mandaye-cam@entrouvert.com' email_to = ['admin+mandaye-cam@entrouvert.com'] From 2638b227f6f08294839b875ef90bf820732b18f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 18:07:16 +0200 Subject: [PATCH 08/26] rules: add data directory --- rules | 1 + 1 file changed, 1 insertion(+) diff --git a/rules b/rules index 9f5658b..5ea8f14 100755 --- a/rules +++ b/rules @@ -11,5 +11,6 @@ override_dh_install: ln -s /etc/mandaye-cam/local_config.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/cam/; \ done install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam + install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam/data install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-cam install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-cam From 0fff1a7f85fc3641be3d9925428ab346b2ec85d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 18:32:42 +0200 Subject: [PATCH 09/26] put static into /usr/share/mandaye-cam --- postinst | 10 +++++++--- rules | 2 ++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/postinst b/postinst index 5b2a773..126891e 100644 --- a/postinst +++ b/postinst @@ -5,9 +5,10 @@ set -e -USER=mandaye-cam -GROUP=mandaye-cam NAME=mandaye-cam +USER=$NAME +GROUP=$NAME +HOME=/var/lib/$NAME case "$1" in configure) @@ -25,7 +26,10 @@ case "$1" in echo "..done" fi - chown -R $USER:$GROUP /var/lib/$NAME /var/run/$NAME /var/log/$NAME + echo -n "Fixing permissions.." + chown $USER:$GROUP /var/lib/$NAME /var/run/$NAME /var/log/$NAME + chown $USER:$GROUP /var/lib/$NAME/data + echo "..done" if [ -z "$2" ]; then echo -n "Creating database.." diff --git a/rules b/rules index 5ea8f14..33a9260 100755 --- a/rules +++ b/rules @@ -14,3 +14,5 @@ override_dh_install: install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam/data install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-cam install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-cam + install -d -m 0755 $(BUILD_DIR)/usr/share/mandaye-cam + ln -s /usr/share/pyshared/cam/static $(BUILD_DIR)/usr/share/mandaye-cam/static From ea86d092f367679db86ab0367820f5a006e16727 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 18:36:11 +0200 Subject: [PATCH 10/26] ruels: fix link to static --- rules | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/rules b/rules index 33a9260..189b0b4 100755 --- a/rules +++ b/rules @@ -12,7 +12,7 @@ override_dh_install: done install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam/data - install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-cam + install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-ca install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-cam install -d -m 0755 $(BUILD_DIR)/usr/share/mandaye-cam - ln -s /usr/share/pyshared/cam/static $(BUILD_DIR)/usr/share/mandaye-cam/static + ln -s /usr/share/pyshared/cam/static $(BUILD_DIR)/usr/share/mandaye-cam/ From a4e221d7115fd64aee125516b1360e299451d16a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 19:13:49 +0200 Subject: [PATCH 11/26] rules: install static --- rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules b/rules index 189b0b4..35be1ff 100755 --- a/rules +++ b/rules @@ -15,4 +15,4 @@ override_dh_install: install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-ca install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-cam install -d -m 0755 $(BUILD_DIR)/usr/share/mandaye-cam - ln -s /usr/share/pyshared/cam/static $(BUILD_DIR)/usr/share/mandaye-cam/ + cp -R cam/static $(BUILD_DIR)/usr/share/mandaye-cam From 647ba9361cb778f4218002af817a736d163a6f96 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 23 Oct 2013 19:16:59 +0200 Subject: [PATCH 12/26] rules: typo fix --- rules | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rules b/rules index 35be1ff..7427905 100755 --- a/rules +++ b/rules @@ -12,7 +12,7 @@ override_dh_install: done install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam/data - install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-ca + install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-cam install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-cam install -d -m 0755 $(BUILD_DIR)/usr/share/mandaye-cam cp -R cam/static $(BUILD_DIR)/usr/share/mandaye-cam From 357ad4730ee85558ae38e865907624780df45601 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 31 Oct 2013 11:31:47 +0100 Subject: [PATCH 13/26] create sessions folder in the packae and improve local_config.py --- local_config.py | 15 ++++++++------- postinst | 2 +- rules | 1 + 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/local_config.py b/local_config.py index 5a7f8f4..4f627a5 100644 --- a/local_config.py +++ b/local_config.py @@ -1,8 +1,4 @@ import logging -import os - -_PROJECT_PATH = os.path.join(os.path.dirname(__file__), '..') - ## Virtual hosts configuration hosts = { @@ -14,7 +10,10 @@ hosts = { ], } -## Database configuration +## SQL Backend config +# http://docs.sqlalchemy.org/en/rel_0_7/core/engines.html +# rfc 1738 https://tools.ietf.org/html/rfc1738 +# dialect+driver://username:password@host:port/database db_url = 'sqlite:///var/lib/mandaye-cam/cam.db' ## Logging configuration @@ -23,10 +22,12 @@ log_file = '/var/log/mandaye-cam/mandaye.log' log_level = logging.INFO ## PATH -# Data directory -data_dir = '/var/lib/mandaye-cam/data' +# Static url +static_url = '/static' # Static folder static_root = '/usr/share/mandaye-cam/static' +# Data directory +data_dir = '/var/lib/mandaye-cam/data' ## Email notification configuration email_notification = True diff --git a/postinst b/postinst index 126891e..bdcc519 100644 --- a/postinst +++ b/postinst @@ -28,7 +28,7 @@ case "$1" in echo -n "Fixing permissions.." chown $USER:$GROUP /var/lib/$NAME /var/run/$NAME /var/log/$NAME - chown $USER:$GROUP /var/lib/$NAME/data + chown $USER:$GROUP /var/lib/$NAME/data /var/lib/$NAME/sessions echo "..done" if [ -z "$2" ]; then diff --git a/rules b/rules index 7427905..4eb38ca 100755 --- a/rules +++ b/rules @@ -12,6 +12,7 @@ override_dh_install: done install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam/data + install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam/sessions install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-cam install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-cam install -d -m 0755 $(BUILD_DIR)/usr/share/mandaye-cam From 4c5832d2a9a7f5c74c28358ecb0037e0b37c3ed2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Thu, 9 Jan 2014 17:03:57 +0100 Subject: [PATCH 14/26] init : create pid directory --- init.d | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/init.d b/init.d index b43bbba..d7e632e 100755 --- a/init.d +++ b/init.d @@ -14,6 +14,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin NAME=mandaye-cam DAEMON=/usr/bin/cam_mandaye_server +PID_DIR=/var/run/mandaye-cam PIDFILE=/var/run/mandaye-cam/$NAME.pid LOG_DIR=/var/log/mandaye-cam SCRIPTNAME=/etc/init.d/$NAME @@ -38,6 +39,9 @@ cam.wsgi:application" # Read configuration variable file if it is present [ -r /etc/default/$NAME ] && . /etc/default/$NAME +# Create pid directory +[ ! -d $PID_DIR ] && mkdir $PID_DIR && chown $USER:$GROUP $PID_DIR + # Load the VERBOSE setting and other rcS variables . /lib/init/vars.sh From a2eb85bcf23c441627048d6928e342a54d0573ce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 26 Mar 2014 17:57:04 +0100 Subject: [PATCH 15/26] control: depend on python-mandaye --- control | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/control b/control index 82ff86a..6086600 100644 --- a/control +++ b/control @@ -8,6 +8,7 @@ X-Python-Version: current Package: mandaye-cam Architecture: all -Depends: ${misc:Depends}, ${python:Depends} +Depends: ${misc:Depends}, ${python:Depends}, + python-mandaye (>= 0.7) Description: CAM is a Mandaye project, modular reverse proxy to authentic From a591c67bf5a38b31e1b8e39119b89f3d6281a53b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 24 Jun 2014 19:33:26 +0200 Subject: [PATCH 16/26] migrate to the new version using .ini files --- control | 5 +++-- dirs | 6 ++++++ install | 2 +- local_config.py | 54 ------------------------------------------------- rules | 9 --------- 5 files changed, 10 insertions(+), 66 deletions(-) create mode 100644 dirs delete mode 100644 local_config.py diff --git a/control b/control index 6086600..ebc3257 100644 --- a/control +++ b/control @@ -8,7 +8,8 @@ X-Python-Version: current Package: mandaye-cam Architecture: all -Depends: ${misc:Depends}, ${python:Depends}, - python-mandaye (>= 0.7) +Depends: ${misc:Depends}, ${python:Depends}, memcached, + python-memcache, python-raven, python-crypto, + python-mandaye (>= 0.8) Description: CAM is a Mandaye project, modular reverse proxy to authentic diff --git a/dirs b/dirs new file mode 100644 index 0000000..881b76a --- /dev/null +++ b/dirs @@ -0,0 +1,6 @@ +var/lib/mandaye-cam +var/lib/mandaye-cam/data +var/lib/mandaye-cam/sessions +var/run/mandaye-cam +var/log/mandaye-cam +usr/share/mandaye-cam diff --git a/install b/install index 4be9bc3..5e140f6 100644 --- a/install +++ b/install @@ -1 +1 @@ -debian/local_config.py /etc/mandaye-cam/ +debian/config.ini /etc/mandaye-cam/ diff --git a/local_config.py b/local_config.py deleted file mode 100644 index 4f627a5..0000000 --- a/local_config.py +++ /dev/null @@ -1,54 +0,0 @@ -import logging - -## Virtual hosts configuration -hosts = { - 'archimed.montpellier.entrouvert.org': [ - {'path': r'/', - 'target': 'http://ermes2.montpellier-agglo.com', - 'mapping': 'cam.configs.archimed_saml.archimed_mapping' - }, - ], -} - -## SQL Backend config -# http://docs.sqlalchemy.org/en/rel_0_7/core/engines.html -# rfc 1738 https://tools.ietf.org/html/rfc1738 -# dialect+driver://username:password@host:port/database -db_url = 'sqlite:///var/lib/mandaye-cam/cam.db' - -## Logging configuration -debug = False -log_file = '/var/log/mandaye-cam/mandaye.log' -log_level = logging.INFO - -## PATH -# Static url -static_url = '/static' -# Static folder -static_root = '/usr/share/mandaye-cam/static' -# Data directory -data_dir = '/var/lib/mandaye-cam/data' - -## Email notification configuration -email_notification = True -smtp_host = 'localhost' -smtp_port = 25 -email_from = 'admin+mandaye-cam@entrouvert.com' -email_to = ['admin+mandaye-cam@entrouvert.com'] - - -## Session configuration -# http://beaker.readthedocs.org/en/latest/configuration.html#options-for-sessions-and-caching -session_opts = { - 'session.type': 'file', - 'session.cookie_expires': True, - 'session.timeout': 3600, - 'session.data_dir': '/var/lib/mandaye-cam/sessions' -} - -## Encrypt service provider passwords with a secret -# You should install pycypto to use this feature -encrypt_sp_password = True -# Must be a 16, 24, or 32 bytes long -encrypt_secret = 'CHANGEME' - diff --git a/rules b/rules index 4eb38ca..a63ae2b 100755 --- a/rules +++ b/rules @@ -7,13 +7,4 @@ BUILD_DIR := 'debian/mandaye-cam' override_dh_install: dh_install - for ver in $(shell pyversions -vr); do \ - ln -s /etc/mandaye-cam/local_config.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/cam/; \ - done - install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam - install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam/data - install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-cam/sessions - install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-cam - install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-cam - install -d -m 0755 $(BUILD_DIR)/usr/share/mandaye-cam cp -R cam/static $(BUILD_DIR)/usr/share/mandaye-cam From a80c5a0e486cd4af2440799d79482fbc80cb9279 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Tue, 24 Jun 2014 19:41:23 +0200 Subject: [PATCH 17/26] add missing config.ini --- config.ini | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 config.ini diff --git a/config.ini b/config.ini new file mode 100644 index 0000000..83258cc --- /dev/null +++ b/config.ini @@ -0,0 +1,32 @@ +[database] +url: sqlite:///var/lib/mandaye-cam/cam.db + +[dirs] +config_root: /etc/mandaye-cam/config.ini +data_dir: /var/lib/mandaye-cam/data +static_root: /usr/share/mandaye-cam/static +static_url: /static + +[debug] +debug: false +use_long_trace: true +log_debug: false +; you need to install python-raven for this feature +sentry_dsn: + +[mandaye] +; if you want to encypt password set to true +; you need to install pycrypto for this feature +encrypt_sp_password: false +; if encrypt_sp_password then you need to choose a secret +; must be a 16, 24, or 32 bytes long +encrypt_secret: + +[session] +; file, dbm, memory or memcached +; if memcached you need to install python-memcached and memcached +type: memcached +url: 127.0.0.1:11211 +cookie_expires: true +timeout: 3600 +data_dir: /var/lib/mandaye-cam/sessions From e3957dab4847e5bbef87a317ecc94ef1d393341f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 25 Jun 2014 14:33:44 +0200 Subject: [PATCH 18/26] add site-available and sites-enabled --- dirs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/dirs b/dirs index 881b76a..d04d9e9 100644 --- a/dirs +++ b/dirs @@ -1,3 +1,6 @@ +etc/mandaye-cam +etc/mandaye-cam/sites-available +etc/mandaye-cam/sites-enabled var/lib/mandaye-cam var/lib/mandaye-cam/data var/lib/mandaye-cam/sessions From f8661115371cbae9287ec7f750208f2300157a4f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 25 Jun 2014 14:36:10 +0200 Subject: [PATCH 19/26] config.ini: fixes default configuration --- config.ini | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.ini b/config.ini index 83258cc..18c72e2 100644 --- a/config.ini +++ b/config.ini @@ -2,7 +2,7 @@ url: sqlite:///var/lib/mandaye-cam/cam.db [dirs] -config_root: /etc/mandaye-cam/config.ini +config_root: /etc/mandaye-cam/sites-enabled data_dir: /var/lib/mandaye-cam/data static_root: /usr/share/mandaye-cam/static static_url: /static From 113a39d82cccb14a2bd5c867de57d9330b71840b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 25 Jun 2014 15:08:27 +0200 Subject: [PATCH 20/26] control: depends on python-lasso and recommends ngix and raven --- control | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/control b/control index ebc3257..5578ece 100644 --- a/control +++ b/control @@ -9,7 +9,8 @@ X-Python-Version: current Package: mandaye-cam Architecture: all Depends: ${misc:Depends}, ${python:Depends}, memcached, - python-memcache, python-raven, python-crypto, + python-memcache, python-raven, python-crypto, python-lasso, python-mandaye (>= 0.8) +Recommends: python-raven, nginx Description: CAM is a Mandaye project, modular reverse proxy to authentic From 34240a600f34e361de04b237184d375ffcb7a4e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 29 Oct 2014 18:18:59 +0100 Subject: [PATCH 21/26] Use new mandaye configuration --- control | 2 +- dirs | 1 + init.d | 4 ++++ install | 1 + mandaye_cam_manager | 22 ++++++++++++++++++++++ postinst | 2 +- rules | 6 ++++-- 7 files changed, 34 insertions(+), 4 deletions(-) create mode 100755 mandaye_cam_manager diff --git a/control b/control index 5578ece..a029c08 100644 --- a/control +++ b/control @@ -10,7 +10,7 @@ Package: mandaye-cam Architecture: all Depends: ${misc:Depends}, ${python:Depends}, memcached, python-memcache, python-raven, python-crypto, python-lasso, - python-mandaye (>= 0.8) + python-mandaye (>= 0.10) Recommends: python-raven, nginx Description: CAM is a Mandaye project, modular reverse proxy to authentic diff --git a/dirs b/dirs index d04d9e9..359e514 100644 --- a/dirs +++ b/dirs @@ -6,4 +6,5 @@ var/lib/mandaye-cam/data var/lib/mandaye-cam/sessions var/run/mandaye-cam var/log/mandaye-cam +usr/lib/mandaye-cam usr/share/mandaye-cam diff --git a/init.d b/init.d index d7e632e..72a0e33 100755 --- a/init.d +++ b/init.d @@ -18,6 +18,7 @@ PID_DIR=/var/run/mandaye-cam PIDFILE=/var/run/mandaye-cam/$NAME.pid LOG_DIR=/var/log/mandaye-cam SCRIPTNAME=/etc/init.d/$NAME +MANDAYE_CONFIG_FILES=/etc/$NAME/config.ini USER=mandaye-cam GROUP=mandaye-cam @@ -49,6 +50,9 @@ cam.wsgi:application" # Depend on lsb-base (>= 3.0-6) to ensure that this file is present. . /lib/lsb/init-functions +# environment for wsgi & settings +export MANDAYE_CONFIG_FILES + # # Function that starts the daemon/service # diff --git a/install b/install index 5e140f6..10d04b7 100644 --- a/install +++ b/install @@ -1 +1,2 @@ debian/config.ini /etc/mandaye-cam/ +debian/mandaye_cam_manager /usr/bin/ diff --git a/mandaye_cam_manager b/mandaye_cam_manager new file mode 100755 index 0000000..f2fdd72 --- /dev/null +++ b/mandaye_cam_manager @@ -0,0 +1,22 @@ +#!/bin/sh + +NAME=mandaye-cam +MANAGER="/usr/lib/$NAME/manager.py --config=/etc/$NAME/config.ini" + +# check user +if test x$1 = x"--forceuser" +then + shift +elif test $(id -un) != "$NAME" +then + echo "error: must use $0 with user ${NAME}" + exit 1 +fi + +if test $# -eq 0 +then + python ${MANAGER} --help + exit 1 +fi + +python ${MANAGER} "$@" diff --git a/postinst b/postinst index bdcc519..5510398 100644 --- a/postinst +++ b/postinst @@ -33,7 +33,7 @@ case "$1" in if [ -z "$2" ]; then echo -n "Creating database.." - su $USER -p -c "/usr/bin/cam_mandaye_manager --createdb" + su $USER -p -c "/usr/bin/mandaye_cud_manager --createdb" echo "..done" fi ;; diff --git a/rules b/rules index a63ae2b..ea3bbd4 100755 --- a/rules +++ b/rules @@ -6,5 +6,7 @@ BUILD_DIR := 'debian/mandaye-cam' dh $@ --with python2 override_dh_install: - dh_install - cp -R cam/static $(BUILD_DIR)/usr/share/mandaye-cam + dh_install + mv $(BUILD_DIR)/usr/bin/server.py $(BUILD_DIR)/usr/lib/mandaye-cam/server.py + mv $(BUILD_DIR)/usr/bin/manager.py $(BUILD_DIR)/usr/lib/mandaye-cam/manager.py + cp -R cam/static $(BUILD_DIR)/usr/share/mandaye-cam From 567879616fef806f6fdd0e6733b1647197b1f821 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 29 Oct 2014 18:40:36 +0100 Subject: [PATCH 22/26] postinst: add certificates generation --- postinst | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/postinst b/postinst index 5510398..8cbf569 100644 --- a/postinst +++ b/postinst @@ -26,6 +26,16 @@ case "$1" in echo "..done" fi + if [ ! -f /etc/$NAME/certs/saml.crt -a ! -f /etc/$NAME/certs/saml.key ]; then + echo -n "Generating key material..." >&2 + openssl genpkey -algorithm rsa -pkeyopt rsa_keygen_bits:2048 -out /etc/$NAME/certs/saml.key >&2 + openssl req -x509 -new -out /etc/$NAME/certs/saml.crt -subj '/CN=whocares' -key /etc/$NAME/certs/saml.key -days 3650 >&2 + chown root:$GROUP /etc/$NAME/certs/saml.crt /etc/$NAME/certs/saml.key + chmod 640 /etc/$NAME/certs/saml.crt /etc/$NAME/certs/saml.key + echo "..done" >&2 + fi + + echo -n "Fixing permissions.." chown $USER:$GROUP /var/lib/$NAME /var/run/$NAME /var/log/$NAME chown $USER:$GROUP /var/lib/$NAME/data /var/lib/$NAME/sessions From b22b989e5fab78ec9218ccc730ccc70ad5ecb5cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 29 Oct 2014 18:45:53 +0100 Subject: [PATCH 23/26] dirs: add /etc/mandaye-cam/certs --- dirs | 1 + 1 file changed, 1 insertion(+) diff --git a/dirs b/dirs index 359e514..091cce7 100644 --- a/dirs +++ b/dirs @@ -1,4 +1,5 @@ etc/mandaye-cam +etc/mandaye-cam/certs etc/mandaye-cam/sites-available etc/mandaye-cam/sites-enabled var/lib/mandaye-cam From 7a76a6f056cc3979e597e5fab647c10d026a57a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 29 Oct 2014 18:48:21 +0100 Subject: [PATCH 24/26] postinst: don't create database by default --- postinst | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/postinst b/postinst index 8cbf569..25850d7 100644 --- a/postinst +++ b/postinst @@ -42,9 +42,8 @@ case "$1" in echo "..done" if [ -z "$2" ]; then - echo -n "Creating database.." - su $USER -p -c "/usr/bin/mandaye_cud_manager --createdb" - echo "..done" + echo "Please create your database :" + echo "su $USER -p -c '/usr/bin/mandaye_cam_manager --createdb'" fi ;; From eb2c296c8330092383308d6e03454d0d1d4035d4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 29 Oct 2014 18:57:18 +0100 Subject: [PATCH 25/26] use pgsql by default and gunicorn --- config.ini | 2 +- init.d | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/config.ini b/config.ini index 18c72e2..1dc5726 100644 --- a/config.ini +++ b/config.ini @@ -1,5 +1,5 @@ [database] -url: sqlite:///var/lib/mandaye-cam/cam.db +url: postgresql://mandaye-cud@/mandaye-cam [dirs] config_root: /etc/mandaye-cam/sites-enabled diff --git a/init.d b/init.d index 72a0e33..14c11c4 100755 --- a/init.d +++ b/init.d @@ -13,7 +13,7 @@ PATH=/sbin:/usr/sbin:/bin:/usr/bin NAME=mandaye-cam -DAEMON=/usr/bin/cam_mandaye_server +DAEMON=/usr/bin/gunicorn PID_DIR=/var/run/mandaye-cam PIDFILE=/var/run/mandaye-cam/$NAME.pid LOG_DIR=/var/log/mandaye-cam From 8e8e6dc5ec082c07b920b295a992bc540c997865 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 28 Jan 2015 17:51:18 +0100 Subject: [PATCH 26/26] depends on mandaye >= 0.11 --- control | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/control b/control index a029c08..721b796 100644 --- a/control +++ b/control @@ -10,7 +10,7 @@ Package: mandaye-cam Architecture: all Depends: ${misc:Depends}, ${python:Depends}, memcached, python-memcache, python-raven, python-crypto, python-lasso, - python-mandaye (>= 0.10) + python-mandaye (>= 0.11) Recommends: python-raven, nginx Description: CAM is a Mandaye project, modular reverse proxy to authentic