From c622863d98f57c1cfdaf12789c41644f51dd828b Mon Sep 17 00:00:00 2001 From: Thierry Parmentelat Date: Wed, 27 Nov 2013 10:07:29 +0100 Subject: [PATCH] =?utf8?q?refine=20packaging=20one=20step=20further=20name?= =?utf8?q?=20generic=20stuff=20as=20unfold=20instead=20of=20myslice=20--?= =?utf8?q?=20db=20installed=20in=20/var/unfold=20and=20permissions=20revie?= =?utf8?q?wed=20-=20no=20insane=20chmod=20777=20!=3F!=3F!=20wsgi=20in=20/u?= =?utf8?q?sr/share/unfold/apache/unfold.wsgi=20conf=20in=20/etc/apache2/si?= =?utf8?q?tes-available/unfold.conf=20=E2=80=94=20not=20tested?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- Makefile | 2 +- apache/{myslice.conf => unfold.conf} | 24 ++++++++++-------------- myslice/wsgi.py => apache/unfold.wsgi | 0 debian/unfold.install | 4 +++- debian/unfold.postinst | 7 ++++--- myslice/settings.py | 23 +++++++++++++---------- setup.py | 4 ++-- 7 files changed, 33 insertions(+), 31 deletions(-) rename apache/{myslice.conf => unfold.conf} (68%) rename myslice/wsgi.py => apache/unfold.wsgi (100%) diff --git a/Makefile b/Makefile index 473e3d76..e3449bbd 100644 --- a/Makefile +++ b/Makefile @@ -148,7 +148,7 @@ ifeq (,$(MYSLICEBOX)) @echo " $(MAKE) MYSLICEBOX=debian04.pl.sophia.inria.fr "$@"" @exit 1 else - +$(RSYNC) ./apache/myslice.conf $(SSHURL)/$(INSTALLED_APACHE)/ + +$(RSYNC) ./apache/unfold.conf $(SSHURL)/$(INSTALLED_APACHE)/ +$(RSYNC) ./apache/unfold-init-ssl.sh $(SSHURL)/$(bindir)/ endif diff --git a/apache/myslice.conf b/apache/unfold.conf similarity index 68% rename from apache/myslice.conf rename to apache/unfold.conf index 8ee84d0f..61bb49f9 100644 --- a/apache/myslice.conf +++ b/apache/unfold.conf @@ -1,15 +1,11 @@ -# xxx it might be smarter to install wsgi.py in some other location -# so we don't have to hard-wire these paths here -# xxx it might also be helpful to set up a specific log channel for this -# e.g. in /var/log/myslice.log - WSGIDaemonProcess myslice processes=2 threads=25 - WSGIProcessGroup myslice - CustomLog ${APACHE_LOG_DIR}/myslice-access.log common - ErrorLog ${APACHE_LOG_DIR}/myslice-error.log - WSGIScriptAlias / /usr/lib/python2.7/dist-packages/myslice/wsgi.py - - + WSGIDaemonProcess unfold processes=2 threads=25 + WSGIProcessGroup unfold + CustomLog ${APACHE_LOG_DIR}/unfold-access.log common + ErrorLog ${APACHE_LOG_DIR}/unfold-error.log + WSGIScriptAlias / /usr/share/unfold/apache/unfold.wsgi + + Order deny,allow Allow from all @@ -33,9 +29,9 @@ WSGIProcessGroup myslice-ssl CustomLog ${APACHE_LOG_DIR}/myslice-ssl-access.log common ErrorLog ${APACHE_LOG_DIR}/myslice-ssl-error.log - WSGIScriptAlias / /usr/lib/python2.7/dist-packages/myslice/wsgi.py - - + WSGIScriptAlias / /usr/share/unfold/apache/unfold.wsgi + + Order deny,allow Allow from all diff --git a/myslice/wsgi.py b/apache/unfold.wsgi similarity index 100% rename from myslice/wsgi.py rename to apache/unfold.wsgi diff --git a/debian/unfold.install b/debian/unfold.install index 5bf0af9a..9730d70c 100644 --- a/debian/unfold.install +++ b/debian/unfold.install @@ -8,5 +8,7 @@ usr/lib*/python*/dist-packages/myslice usr/lib*/python*/dist-packages/sample usr/share/unfold/static usr/share/unfold/templates +apache/unfold.wsgi /usr/share/unfold/apache/ +apache/unfold.conf /etc/apache2/sites-available manage.py usr/share/unfold/ -apache/myslice.conf /etc/apache2/sites-available +usr/bin/unfold-init-ssl.sh diff --git a/debian/unfold.postinst b/debian/unfold.postinst index de85dd31..77a479e3 100644 --- a/debian/unfold.postinst +++ b/debian/unfold.postinst @@ -1,10 +1,11 @@ #!/bin/bash # if this requires a service to be running, add something like this # update-rc.d unfold defaults +[ -d /var/unfold ] || mkdir /var/unfold +chown -R www-data.www-data /var/unfold /usr/share/unfold/manage.py syncdb /usr/share/unfold/manage.py migrate -chmod 777 /usr/share/unfold/myslice.sqlite3 -chmod 777 /usr/share/unfold +chmod 700 /var/unfold/unfold.sqlite3 a2dissite default -a2ensite myslice.conf +a2ensite unfold.conf service apache2 restart diff --git a/myslice/settings.py b/myslice/settings.py index 4df98e2e..c51010a4 100644 --- a/myslice/settings.py +++ b/myslice/settings.py @@ -1,4 +1,4 @@ -# Django settings for myslice project. +# Django settings for unfold project. import os.path @@ -19,17 +19,20 @@ except: import traceback traceback.print_exc() -# find out DATAROOT, which is different from ROOT +# find out HTTPROOT, which is different from ROOT # when deployed from a package # this code is run by collectstatic too, so we cannot # assume we have ./static present already -DATAROOT="/usr/share/unfold" +HTTPROOT="/usr/share/unfold" +# the place to store local data, like e.g. the sqlite db +DATAROOT="/var/unfold" # if not there, then we assume it's from a devel tree -if not os.path.isdir (os.path.join(DATAROOT,"static")): +if not os.path.isdir (os.path.join(HTTPROOT,"static")): + HTTPROOT=ROOT DATAROOT=ROOT -if not os.path.isdir(ROOT): raise Exception,"Cannot find ROOT %s for myslice"%ROOT -if not os.path.isdir(DATAROOT): raise Exception,"Cannot find DATAROOT %s for myslice"%DATAROOT +if not os.path.isdir(ROOT): raise Exception,"Cannot find ROOT %s for unfold"%ROOT +if not os.path.isdir(HTTPROOT): raise Exception,"Cannot find HTTPROOT %s for unfold"%HTTPROOT #################### ADMINS = ( @@ -49,7 +52,7 @@ EMAIL_USE_TLS = False DATABASES = { 'default': { 'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'. - 'NAME': os.path.join(DATAROOT,'myslice.sqlite3'), # Or path to database file if using sqlite3. + 'NAME': os.path.join(DATAROOT,'unfold.sqlite3'), # Or path to database file if using sqlite3. 'USER': '', # Not used with sqlite3. 'PASSWORD': '', # Not used with sqlite3. 'HOST': '', # Set to empty string for localhost. Not used with sqlite3. @@ -93,7 +96,7 @@ MEDIA_URL = '' # Don't put anything in this directory yourself; store your static files # in apps' "static/" subdirectories and in STATICFILES_DIRS. # Example: "/home/media/media.lawrence.com/static/" -STATIC_ROOT = os.path.join(DATAROOT,'static') +STATIC_ROOT = os.path.join(HTTPROOT,'static') # URL prefix for static files. # Example: "http://media.lawrence.com/static/" @@ -157,13 +160,13 @@ MIDDLEWARE_CLASSES = ( ROOT_URLCONF = 'myslice.urls' # Python dotted path to the WSGI application used by Django's runserver. -WSGI_APPLICATION = 'myslice.wsgi.application' +WSGI_APPLICATION = 'unfold.wsgi.application' TEMPLATE_DIRS = ( # Put strings here, like "/home/html/django_templates" or "C:/www/django/templates". # Always use forward slashes, even on Windows. # Don't forget to use absolute paths, not relative paths. - os.path.join(DATAROOT,"templates"), + os.path.join(HTTPROOT,"templates"), ) INSTALLED_APPS = ( diff --git a/setup.py b/setup.py index 99b077d7..e7ab6a5b 100644 --- a/setup.py +++ b/setup.py @@ -1,6 +1,6 @@ #!/usr/bin/python # -# Setup script for myslice +# Setup script for myslice+unfold # # Thierry Parmentelat # INRIA (c) 2013 @@ -21,5 +21,5 @@ setup(packages = packages, ( '/usr/share/unfold/static/img', glob ('static/img/*')), ( '/usr/share/unfold/static/fonts', glob ('static/fonts/*')), ( '/usr/share/unfold/templates', glob ('templates/*')), - ( 'apache', [ 'apache/myslice.conf' ]), + ( 'apache', [ 'apache/unfold.conf', 'apache/unfold.wsgi' ]), ]) -- 2.43.0