debian: initial import

This commit is contained in:
Jérôme Schneider 2013-06-14 21:26:16 +02:00
parent 86554ad361
commit 3348d9628b
11 changed files with 331 additions and 0 deletions

20
debian/apache-example.conf vendored Normal file
View File

@ -0,0 +1,20 @@
<VirtualHost *:80>
ServerAdmin webmaster@example.com
ServerName montpellier.example.com
Alias /static /var/lib/compte-agglo-montpellier/static
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
ProxyPass /static !
ProxyPass / http://127.0.0.1:8094
ProxyPassReverse / http://127.0.0.1:8094
LogLevel warn
ErrorLog /var/log/apache2/error.log
CustomLog /var/log/apache2/access.log combined
</VirtualHost>

5
debian/changelog vendored Normal file
View File

@ -0,0 +1,5 @@
compte-agglo-montpellier (0.1.61.g86554ad-1) unstable; urgency=low
* Initial release
-- Jérôme Schneider <jschneider@entrouvert.com> Fri, 14 Jun 2013 18:13:16 +0200

1
debian/compat vendored Normal file
View File

@ -0,0 +1 @@
7

13
debian/compte-agglo-montpellier.conf vendored Normal file
View File

@ -0,0 +1,13 @@
# Database configuration
export ENGINE='django.db.backends.sqlite3'
export DATABASE_NAME='/var/lib/compte-agglo-montpellier/compte-agglo-montpellier.db'
# Static root directory
export STATIC_ROOT='/var/lib/compte-agglo-montpellier/static'
# Log root directory
export LOG_ROOT='/var/log/compte-agglo-montpellier/compte-agglo-montpellier.log'
# secret to CHANGE
export SECRET_KEY="changeme"

12
debian/compte-agglo-montpellier.sh vendored Normal file
View File

@ -0,0 +1,12 @@
#!/bin/sh
if [ "$(whoami)" != "compte-agglo-montpellier" ]; then
echo "You must run this script with compte-agglo-montpellier user"
exit 1
fi
if [ -f /etc/compte-agglo-montpellier/compte-agglo-montpellier.conf ]; then
. /etc/compte-agglo-montpellier/compte-agglo-montpellier.conf
fi
/var/lib/compte-agglo-montpellier/manage.py $*

23
debian/control vendored Normal file
View File

@ -0,0 +1,23 @@
Source: compte-agglo-montpellier
Maintainer: Benjamin Dauvergne <info@entrouvert.com>
Section: python
Priority: optional
Build-Depends: python-setuptools (>= 0.6b3), python-all (>= 2.6.6-3),
debhelper (>= 7.4.3), python-django (>= 1.5)
Standards-Version: 3.9.1
X-Python-Version: >= 2.6
Package: compte-agglo-montpellier
Architecture: all
Depends: ${misc:Depends},
python-portail-citoyen,
python-portail-citoyen-announces (>= 0.1),
python-demjson,
python-entrouvert,
adduser,
python-cmsplugin-embedded-menu,
python-cmsplugin-text-wrapper,
rsyslog | syslog-ng | dsyslog | busybox-syslogd | inetutils-syslogd,
gunicorn (>= 0.14)
Description: Compte agglo montpellier

5
debian/dirs vendored Normal file
View File

@ -0,0 +1,5 @@
var/lib/compte-agglo-montpellier/media
var/lib/compte-agglo-montpellier/static
var/lib/compte-agglo-montpellier/extra-static
var/run/compte-agglo-montpellier
var/log/compte-agglo-montpellier

164
debian/init.d vendored Normal file
View File

@ -0,0 +1,164 @@
#!/bin/sh
### BEGIN INIT INFO
# Provides: compte-agglo-montpellier
# 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 <jschneider@entrouvert.com>
PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=compte-agglo-montpellier
NAME=compte-agglo-montpellier
DAEMON=/usr/bin/gunicorn
PIDFILE=/var/run/compte-agglo-montpellier/$NAME.pid
LOG_DIR=/var/log/compte-agglo-montpellier
SCRIPTNAME=/etc/init.d/$NAME
USER=compte-agglo-montpellier
GROUP=compte-agglo-montpellier
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:8094 \
--workers=10 \
--worker-class=sync \
--timeout=60 \
compte_agglo_montpellier.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 confg
. /etc/compte-agglo-montpellier/compte-agglo-montpellier.conf
# 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

2
debian/install vendored Normal file
View File

@ -0,0 +1,2 @@
debian/compte-agglo-montpellier.conf /etc/compte-agglo-montpellier
debian/apache-example.conf /etc/compte-agglo-montpellier

64
debian/postinst vendored Normal file
View File

@ -0,0 +1,64 @@
#!/bin/sh
#
# Postinst script for compte-agglo-montpellier
#
set -e
USER=compte-agglo-montpellier
GROUP=compte-agglo-montpellier
HOME=/var/lib/compte-agglo-montpellier
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 "Compte citoyen Montpellier daemon" \
--ingroup $GROUP \
--no-create-home --home $HOME \
$USER
echo "..done"
fi
chown $USER:$GROUP /var/lib/compte-agglo-montpellier /var/run/compte-agglo-montpellier /var/log/compte-agglo-montpellier
chown $USER:$GROUP /var/lib/compte-agglo-montpellier/static /var/lib/compte-agglo-montpellier/extra-static
chown $USER:$GROUP /var/lib/compte-agglo-montpellier/media
echo -n "Generating static files.."
su compte-agglo-montpellier -p -c "/usr/bin/compte-agglo-montpellier collectstatic --noinput --link"
echo "..done"
;;
reconfigure)
su compte-agglo-montpellier -p -c "/usr/bin/compte-agglo-montpellier-ctl collectstatic --noinput --link"
;;
abort-upgrade|abort-remove|abort-deconfigure)
;;
*)
echo "postinst called with unknown argument \`$1'" >&2
exit 1
;;
esac
case "$1" in
configure)
if [ -z "$2" ]; then
su compte-agglo-montpellier -p -c "/usr/bin/compte-agglo-montpellier syncdb --noinput"
fi
;;
esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
#DEBHELPER#
exit 0

22
debian/rules vendored Executable file
View File

@ -0,0 +1,22 @@
#!/usr/bin/make -f
d=$(CURDIR)/debian/compte-agglo-montpellier
%:
dh $@ --with python2 --buildsystem=python_distutils
# FIXME: remove this overrides when we will have a clean upstream branch
override_dh_auto_clean:
git status
dh_auto_clean
override_dh_auto_build:
git status
dh_auto_build
override_dh_auto_install:
git status
dh_auto_install
mv $(d)/usr/bin/compte-agglo-montpellier $(d)/var/lib/compte-agglo-montpellier/manage.py
cp $(CURDIR)/debian/compte-agglo-montpellier.sh $(d)/usr/bin/compte-agglo-montpellier