From 956a03db9c49aabf8d12c04f70f105f2aef201d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Schneider?= Date: Wed, 9 Apr 2014 12:45:57 +0200 Subject: [PATCH] debian: initial import --- changelog | 5 ++ compat | 1 + control | 20 ++++++ init.d | 164 +++++++++++++++++++++++++++++++++++++++++++++++ install | 1 + local_config.py | 70 ++++++++++++++++++++ postinst | 57 ++++++++++++++++ pydist-overrides | 2 + rules | 19 ++++++ source/format | 1 + 10 files changed, 340 insertions(+) create mode 100644 changelog create mode 100644 compat create mode 100644 control create mode 100755 init.d create mode 100644 install create mode 100644 local_config.py create mode 100644 postinst create mode 100644 pydist-overrides create mode 100755 rules create mode 100644 source/format diff --git a/changelog b/changelog new file mode 100644 index 0000000..dc2038b --- /dev/null +++ b/changelog @@ -0,0 +1,5 @@ +mandaye-vincennes (0.1-1) unstable; urgency=medium + + * Initial release + + -- Jérôme Schneider Wed, 09 Apr 2014 12:31:45 +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..0ae1cd4 --- /dev/null +++ b/control @@ -0,0 +1,20 @@ +Source: mandaye-vincennes +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 +X-Python-Version: current + +Package: mandaye-vincennes +Architecture: all +Depends: ${misc:Depends}, ${python:Depends}, + python-mandaye (>= 0.7), + python-beautifulsoup (>= 3.1), + python-crypto (>= 2.6), + python-lasso (>= 2.4.0), + gunicorn (>= 0.17), + python-psycopg2 +Recommends: postgresql +Description: Vincennes Mandaye project, modular reverse proxy to authentic + diff --git a/init.d b/init.d new file mode 100755 index 0000000..73ffe7b --- /dev/null +++ b/init.d @@ -0,0 +1,164 @@ +#!/bin/sh +### BEGIN INIT INFO +# Provides: mandaye-vincennes +# Required-Start: $network $local_fs +# Required-Stop: +# Default-Start: 2 3 4 5 +# Default-Stop: 0 1 6 +# Short-Description: authentication reverse proxy for Vincennes +# Description: authentication reverse proxy for Vincennes +### END INIT INFO + +# Author: Jérôme Schneider + +PATH=/sbin:/usr/sbin:/bin:/usr/bin +NAME=mandaye-vincennes +DAEMON=/usr/bin/vincennes_mandaye_server +PID_DIR=/var/run/mandaye-vincennes +PIDFILE=/var/run/mandaye-vincennes/$NAME.pid +LOG_DIR=/var/log/mandaye-vincennes +SCRIPTNAME=/etc/init.d/$NAME + +USER=mandaye-vincennes +GROUP=mandaye-vincennes + +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=5 \ +--worker-class=sync \ +--timeout=60 \ +mandaye_vincennes.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 + +# 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 + +# 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..219c891 --- /dev/null +++ b/install @@ -0,0 +1 @@ +debian/local_config.py /etc/mandaye-vincennes/ diff --git a/local_config.py b/local_config.py new file mode 100644 index 0000000..f321104 --- /dev/null +++ b/local_config.py @@ -0,0 +1,70 @@ +import logging + +## Virtual hosts configuration +hosts = { + 'biblio.local:8000': [ + { + 'path': r'/', + 'target': 'http://biblio.vincennes.fr', + 'mapping': 'mandaye_vincennes.configs.biblio_vincennes.biblio_mapping', + }, + ], + 'espace-famille.local:8000': [ + { + 'path': r'/', + 'target': 'https://vincennes-noredirect.espace-famille.net', + 'mapping': 'mandaye_vincennes.configs.famille_vincennes.famille_mapping', + } + ], + + 'conservatoire.local:8000': [ + { + 'path': r'/', + 'target': 'https://extranet.duonet.fr', + 'mapping': 'mandaye_vincennes.configs.duonet_vincennes.duonet_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 = 'postgresql://@localhost:5432/mandaye_vincennes' + +## Logging configuration +debug = False +log_file = '/var/log/mandaye-vincennes/mandaye.log' +log_level = logging.INFO + +## PATH +# Static url +static_url = '/static' +# Static folder +static_root = '/usr/share/mandaye-vincennes/static' +# Data directory +data_dir = '/var/lib/mandaye-vincennes/data' + +## Email notification configuration +email_notification = True +smtp_host = 'localhost' +smtp_port = 25 +email_from = 'admin+mandaye-vincennes@entrouvert.com' +email_to = ['admin+mandaye-vincennes@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-vincennes/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..0020f16 --- /dev/null +++ b/postinst @@ -0,0 +1,57 @@ +#!/bin/sh +# +# Postinst script for mandaye-vincennes +# + +set -e + +NAME=mandaye-vincennes +USER=$NAME +GROUP=$NAME +HOME=/var/lib/$NAME + +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 Vincennes daemon" \ + --ingroup $GROUP \ + --no-create-home --home $HOME \ + $USER + echo "..done" + 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 + echo "..done" + + if [ -z "$2" ]; then + echo "Please create your database :" + echo "su $USER -p -c '/usr/bin/vincennes_mandaye_manager --createdb'" + 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/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 diff --git a/rules b/rules new file mode 100755 index 0000000..cd3f75c --- /dev/null +++ b/rules @@ -0,0 +1,19 @@ +#!/usr/bin/make -f + +BUILD_DIR := 'debian/mandaye-vincennes' + +%: + dh $@ --with python2 + +override_dh_install: + dh_install + for ver in $(shell pyversions -vr); do \ + ln -s /etc/mandaye-vincennes/local_config.py $(BUILD_DIR)/usr/lib/python$$ver/dist-packages/mandaye_vincennes/; \ + done + install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-vincennes + install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-vincennes/data + install -d -m 0755 $(BUILD_DIR)/var/lib/mandaye-vincennes/sessions + install -d -m 0755 $(BUILD_DIR)/var/run/mandaye-vincennes + install -d -m 0755 $(BUILD_DIR)/var/log/mandaye-vincennes + install -d -m 0755 $(BUILD_DIR)/usr/share/mandaye-vincennes + cp -R mandaye_vincennes/static $(BUILD_DIR)/usr/share/mandaye-vincennes 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)