diff --git a/Makefile b/Makefile index 83d1b72..c060491 100644 --- a/Makefile +++ b/Makefile @@ -25,6 +25,7 @@ install: $(CP) -r bin $(DESTDIR)/opt/polynum $(INSTALL) -d $(DESTDIR)/etc/opt/polynum $(INSTALL) -d $(DESTDIR)/var/opt/polynum + $(INSTALL) -d $(DESTDIR)/opt/polynum/static deb: dch --newversion=0.0.`date +%Y%m%d`~git`git log -1 --oneline | cut -f1 -d" "`-1 diff --git a/bin/polynum-build-virtualenv b/bin/polynum-build-virtualenv index e223c36..406a895 100755 --- a/bin/polynum-build-virtualenv +++ b/bin/polynum-build-virtualenv @@ -12,7 +12,7 @@ function abort() { exit 1 } -test -e ${VEDIR} && abort "$VEDIR already exists" +test -e ${VEDIR}/lib && abort "$VEDIR already exists" DIR=`dirname $VEDIR` VE=`basename $VEDIR` diff --git a/debian/control b/debian/control index d5d0265..1c3c64a 100644 --- a/debian/control +++ b/debian/control @@ -9,7 +9,7 @@ Vcs-Browser: https://sourcesup.renater.fr/scm/?group_id=859 Package: polynum Architecture: all -Depends: ${misc:Depends}, python, python-psycopg2, python-ldap +Depends: ${misc:Depends}, python, python-psycopg2, python-ldap, adduser (>= 3.11) Recommends: python-virtualenv Suggests: postgresql Description: Polycopiés numériques diff --git a/debian/docs b/debian/docs index 511d134..4c499be 100644 --- a/debian/docs +++ b/debian/docs @@ -1,3 +1,5 @@ README requirements local_settings.py.example +polynum/base/fixtures +help diff --git a/debian/links b/debian/links new file mode 100644 index 0000000..5dfa1b5 --- /dev/null +++ b/debian/links @@ -0,0 +1 @@ +opt/polynum/bin/polynum-manage.py usr/bin/polynum-manage.py diff --git a/debian/menu.ex b/debian/menu.ex deleted file mode 100644 index ab426a8..0000000 --- a/debian/menu.ex +++ /dev/null @@ -1,2 +0,0 @@ -?package(polynum):needs="X11|text|vc|wm" section="Applications/see-menu-manual"\ - title="polynum" command="/usr/bin/polynum" diff --git a/debian/polynum.default b/debian/polynum.default new file mode 100644 index 0000000..43b9130 --- /dev/null +++ b/debian/polynum.default @@ -0,0 +1,10 @@ +# Defaults for polynum initscript +# sourced by /etc/init.d/polynum + +POLYNUM_USER=polynum +POLYNUM_GROUP=polynum + +POLYNUM_HOME=/opt/polynum +POLYNUM_VAR=/var/opt/polynum +POLYNUM_ETC=/etc/opt/polynum + diff --git a/debian/polynum.default.ex b/debian/polynum.default.ex deleted file mode 100644 index 6ed498e..0000000 --- a/debian/polynum.default.ex +++ /dev/null @@ -1,10 +0,0 @@ -# Defaults for polynum initscript -# sourced by /etc/init.d/polynum -# installed at /etc/default/polynum by the maintainer scripts - -# -# This is a POSIX shell fragment -# - -# Additional options that are passed to the Daemon. -DAEMON_OPTS="" diff --git a/debian/postinst b/debian/postinst new file mode 100644 index 0000000..393fad8 --- /dev/null +++ b/debian/postinst @@ -0,0 +1,106 @@ +#!/bin/sh +# postinst script for polynum +# +# see: dh_installdeb(1) + +set -e + +# summary of how this script can be called: +# * `configure' +# * `abort-upgrade' +# * `abort-remove' `in-favour' +# +# * `abort-remove' +# * `abort-deconfigure' `in-favour' +# `removing' +# +# for details, see http://www.debian.org/doc/debian-policy/ or +# the debian-policy package + + +case "$1" in + configure) + + # create user to avoid running server as root + + # code borrowed from + # http://www.debian.org/doc/manuals/securing-debian-howto/ch9.en.html#s-bpp-lower-privs + + # If the package has default file it could be sourced, so that + # the local admin can overwrite the defaults + [ -f "/etc/default/packagename" ] && . /etc/default/packagename + + # Sane defaults: + [ -z "$POLYNUM_USER" ] && POLYNUM_USER=polynum + [ -z "$POLYNUM_NAME" ] && POLYNUM_NAME="PolyNum daemon user" + [ -z "$POLYNUM_HOME" ] && POLYNUM_HOME=/opt/polynum + [ -z "$POLYNUM_GROUP" ] && POLYNUM_GROUP=polynum + [ -z "$POLYNUM_VAR" ] && POLYNUM_VAR=/var/opt/polynum + [ -z "$POLYNUM_ETC" ] && POLYNUM_ETC=/etc/opt/polynum + + # 1. create group if not existing + if ! getent group | grep -q "^$POLYNUM_GROUP:" ; then + echo -n "Adding group $POLYNUM_GROUP.." + addgroup --quiet --system $POLYNUM_GROUP 2>/dev/null ||true + echo "..done" + fi + + # 2. create homedir if not existing + # test -d $POLYNUM_HOME || mkdir $POLYNUM_HOME + + # 3. create user if not existing + if ! getent passwd | grep -q "^$POLYNUM_USER:"; then + echo -n "Adding system user $POLYNUM_USER.." + adduser --quiet \ + --system \ + --ingroup $POLYNUM_GROUP \ + --no-create-home \ + --disabled-password \ + $POLYNUM_USER 2>/dev/null || true + echo "..done" + fi + + # 4. adjust passwd entry + usermod -c "$POLYNUM_NAME" \ + -d $POLYNUM_HOME \ + -g $POLYNUM_GROUP \ + $POLYNUM_USER 2>/dev/null || true + + # 5. create default config + # and adjust some files and directories permissions + if [ ! -f $POLYNUM_ETC/local_settings.py ] + then + if ! dpkg-statoverride --list $POLYNUM_ETC/local_settings.py >/dev/null + then + echo -n "Install default $POLYNUM_ETC/local_settings.py .." + cp /usr/share/doc/polynum/local_settings.py.example $POLYNUM_ETC/local_settings.py + chown $POLYNUM_USER:$POLYNUM_GROUP $POLYNUM_ETC/local_settings.py + chmod u=rw,g=,o= $POLYNUM_ETC/local_settings.py + echo "..done" + fi + fi + if ! dpkg-statoverride --list $POLYNUM_VAR/media >/dev/null + then + echo -n "Create upload_dir $POLYNUM_VAR/media .." + mkdir -p $POLYNUM_VAR/media + chown -R $POLYNUM_USER:$POLYNUM_GROUP $POLYNUM_VAR/media + chmod u=rwx,g=rwxs,o= $POLYNUM_VAR/media + echo "..done" + fi + ;; + + 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/debian/postinst.ex b/debian/postinst.ex deleted file mode 100644 index b3edc0d..0000000 --- a/debian/postinst.ex +++ /dev/null @@ -1,39 +0,0 @@ -#!/bin/sh -# postinst script for polynum -# -# see: dh_installdeb(1) - -set -e - -# summary of how this script can be called: -# * `configure' -# * `abort-upgrade' -# * `abort-remove' `in-favour' -# -# * `abort-remove' -# * `abort-deconfigure' `in-favour' -# `removing' -# -# for details, see http://www.debian.org/doc/debian-policy/ or -# the debian-policy package - - -case "$1" in - configure) - ;; - - 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/debian/rules b/debian/rules index b760bee..93ebeb1 100755 --- a/debian/rules +++ b/debian/rules @@ -10,4 +10,7 @@ #export DH_VERBOSE=1 %: - dh $@ + dh $@ + +override_dh_compress: + dh_compress -X.page -X.xml -X.json diff --git a/requirements b/requirements index 77d2f96..113dcd6 100644 --- a/requirements +++ b/requirements @@ -8,3 +8,4 @@ git+https://github.com/sehmaschine/django-grappelli@grappelli_2_4 pypdf flup django-debug-toolbar +gunicorn