infra/patchwork: systemd files and production.py settings
* systemd/patchwork-delivery*: on demand socket to take mail in a localhost
TCP socket, to allow patchwork to be in a separate container from
email.
* production.py: patchwork.settings.production file.
* pass.py: example pass.py file
diff --git a/infra/patchwork/pass.py b/infra/patchwork/pass.py
new file mode 100644
index 0000000..6514232
--- /dev/null
+++ b/infra/patchwork/pass.py
@@ -0,0 +1,4 @@
+# example pass file
+SECRET_KEY = "aaaaaaaaaaaaaaaaaa"
+EMAIL_HOST_PASSWORD = os.getenv('EMAIL_HOST_PASSWORD', '')
+DATABASES['default']['PASSWORD'] = os.environ.get('DATABASE_PASSWORD', 'bbbbbbbbbbbbbbbbbbbbb');
diff --git a/infra/patchwork/production.py b/infra/patchwork/production.py
new file mode 100644
index 0000000..1683c0c
--- /dev/null
+++ b/infra/patchwork/production.py
@@ -0,0 +1,89 @@
+"""
+Sample production-ready settings for patchwork project.
+
+Most of these are commented out as they will be installation dependent.
+
+Design based on:
+ http://www.revsys.com/blog/2014/nov/21/recommended-django-project-layout/
+"""
+
+from __future__ import absolute_import
+
+import os
+
+import django
+
+from .base import * # noqa
+
+DEBUG = True
+#
+# Core settings
+# https://docs.djangoproject.com/en/1.8/ref/settings/#core-settings
+#
+
+# Security
+#
+# You'll need to replace this to a random string. The following python code can
+# be used to generate a secret key:
+#
+# import string, random
+# chars = string.letters + string.digits + string.punctuation
+# print repr("".join([random.choice(chars) for i in range(0,50)]))
+
+# Email
+#
+# Replace this with your own details
+
+EMAIL_HOST = os.getenv('EMAIL_HOST', 'localhost')
+EMAIL_PORT = os.getenv('EMAIL_PORT', 25)
+EMAIL_HOST_USER = os.getenv('EMAIL_HOST_USER', '')
+# password goes in pass.py
+EMAIL_USE_TLS = True
+
+DEFAULT_FROM_EMAIL = 'Patchwork <patchwork@patchwork.quagga.net>'
+SERVER_EMAIL = DEFAULT_FROM_EMAIL
+NOTIFICATION_FROM_EMAIL = DEFAULT_FROM_EMAIL
+
+ADMINS = (
+ ('Paul Jakma', 'paul@quagga.net'),
+)
+
+# Database
+#
+# If you're using a postgres database, connecting over a local unix-domain
+# socket, then the following setting should work for you. Otherwise,
+# see https://docs.djangoproject.com/en/1.8/ref/settings/#databases
+
+# password goes in pass.py
+DATABASES = {
+ 'default': {
+ 'ENGINE': 'django.db.backends.mysql',
+ 'NAME': os.environ.get('DATABASE_NAME', 'patchwork'),
+ 'USER': os.environ.get('DATABASE_USER', 'patchwork'),
+ 'HOST': '127.0.0.1',
+ },
+}
+
+
+#
+# Static files settings
+# https://docs.djangoproject.com/en/1.8/ref/settings/#static-files
+# https://docs.djangoproject.com/en/1.8/ref/contrib/staticfiles/#manifeststaticfilesstorage
+#
+
+STATIC_ROOT = os.environ.get('STATIC_ROOT', '/home/patchwork/htdocs/static')
+
+
+if django.VERSION >= (1, 7):
+ STATICFILES_STORAGE = \
+ 'django.contrib.staticfiles.storage.ManifestStaticFilesStorage'
+
+ENABLE_XMLRPC = True
+
+LANGUAGE_CODE='en-gb'
+TIME_ZONE='GMT'
+ALLOWED_HOSTS=['patchwork.quagga.net','testpw.quagga.net', 'http', 'http.quagga.net', '*.quagga.net']
+
+with open("patchwork/settings/pass.py") as f:
+ code = compile(f.read(), "patchwork/settings/pass.py", 'exec')
+ exec(code)
diff --git a/infra/patchwork/systemd/patchwork-delivery.socket b/infra/patchwork/systemd/patchwork-delivery.socket
new file mode 100644
index 0000000..bfa6752
--- /dev/null
+++ b/infra/patchwork/systemd/patchwork-delivery.socket
@@ -0,0 +1,15 @@
+[Unit]
+Description=Patchwork unix pipe to accept list mail delivery on
+
+[Socket]
+#ListenStream=/tmp/patchwork.sock
+ListenStream=127.0.0.1:8001
+SocketUser=patchwork
+SocketGroup=patchwork
+Accept=yes
+
+#ListenFIFO=/tmp/patchwork-fifo.sock
+
+
+[Install]
+WantedBy=sockets.target
diff --git a/infra/patchwork/systemd/patchwork-delivery@.service b/infra/patchwork/systemd/patchwork-delivery@.service
new file mode 100644
index 0000000..d152b2d
--- /dev/null
+++ b/infra/patchwork/systemd/patchwork-delivery@.service
@@ -0,0 +1,15 @@
+[Unit]
+Description=Patchwork list mail socket processing script
+
+[Service]
+EnvironmentFile=/home/patchwork/patchwork.env
+ExecStart=-/home/patchwork/patchwork/patchwork/bin/parsemail.sh
+StandardInput=socket
+StandardOutput=inherit
+StandardError=journal
+User=patchwork
+Group=patchwork
+
+[Install]
+WantedBy=multi-user.target
+Also=patchwork-delivery.socket
diff --git a/infra/patchwork/systemd/patchwork.service b/infra/patchwork/systemd/patchwork.service
new file mode 100644
index 0000000..90ec4bb
--- /dev/null
+++ b/infra/patchwork/systemd/patchwork.service
@@ -0,0 +1,12 @@
+[Unit]
+Description=Patchwork Daemon
+
+[Service]
+WorkingDirectory=/home/patchwork/patchwork
+User=patchwork
+Group=patchwork
+EnvironmentFile=/home/patchwork/patchwork.env
+ExecStart=/usr/bin/python3 manage.py runserver 0.0.0.0:8000
+
+[Install]
+WantedBy=multi-user.target