From 1dcb4c6cc058800d8995bd3489ce840ff07055ec Mon Sep 17 00:00:00 2001 From: Max Christian Pohle Date: Wed, 13 Nov 2019 00:23:06 +0100 Subject: Replacing the old php with a python script python was already installed in my dns jail, so this has very little overhead compared to a full php installation. --- README.md | 22 ++++++++++++++++++++++ uwsgi.ini | 28 ++++++++++++++++++++++++++++ wsgi.py | 19 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 README.md create mode 100644 uwsgi.ini create mode 100644 wsgi.py diff --git a/README.md b/README.md new file mode 100644 index 0000000..d8869ae --- /dev/null +++ b/README.md @@ -0,0 +1,22 @@ +Installation: FreeBSD +===================== + +1. install uwsgi (dependency, but really small): `pkg install uwsgi` + +2. add to `/etc/rc.conf`: + ``` + uwsgi_enable="YES" + uwsgi_emperor="YES" + uwsgi_vassals_dir="/usr/local/www/*/uwsgi.ini" + ``` + +3. start uwsgi `service uwsgi start` + +4. Git clone this directory under /usr/local/www/ + + +WIP +=== + +This is work in progress. Do not expect wonders or good documentation in this +early stage of development. diff --git a/uwsgi.ini b/uwsgi.ini new file mode 100644 index 0000000..4782770 --- /dev/null +++ b/uwsgi.ini @@ -0,0 +1,28 @@ +[uwsgi] +master = true +socket = /var/run/%c.sock +reuse-port = true +master = true +reload-os-env = true +vaccuum = true +logto = /usr/local/www/%c/uwsgi.log +manage-script-name = true +chdir = /usr/local/www/%c +touch-reload = /usr/local/www/%c +wsgi-file = wsgi.py +# mount = /%c=%c/wsgi.py +# static-map = /static=/usr/local/www/%c/static +# static-map = /media=/usr/local/www/%c/media +unenv = DJANGO_SETTINGS_MODULE +unenv = DJANGO_SETTINGS +wsgi-env-behaviour = cheat +print = we are using %c +http = 10.0.1.99:8080 + + + +# set cheaper algorithm to use, if not set default will be used +cheaper-algo = backlog +cheaper-overload = 4 +cheaper-idle = 1 +cheaper-initial = 0 diff --git a/wsgi.py b/wsgi.py new file mode 100644 index 0000000..49224b9 --- /dev/null +++ b/wsgi.py @@ -0,0 +1,19 @@ +#!/usr/bin/env python3.6 + +import time +import re +import subprocess +from cgi import parse_qs + +def application(environ, start_response): + d = parse_qs(environ['QUERY_STRING']) + + start_response('200 OK', [('Content-Type', 'text/plain')]) + if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', d.get('ip', ['0'])[0]): + ip = d.get('ip', ['0'])[0].encode() + if re.match('[0-9a-z]+', d.get('host', [''])[0]): + host = d.get('host', ['0'])[0].encode() + yield(subprocess.run(["/usr/local/bin/pdnsutil", "delete-rrset", "wire-me.de", host, "A"], stdout=subprocess.PIPE).stdout) + yield(subprocess.run(["/usr/local/bin/pdnsutil", "add-record", "wire-me.de", host, "A", ip], stdout=subprocess.PIPE)) + yield(subprocess.run(["/usr/local/bin/pdnsutil", "list-zone", "wire-me.de"], stdout=subprocess.PIPE).stdout) + -- cgit v1.2.3