diff options
author | Max Christian Pohle | 2019-11-13 00:23:06 +0100 |
---|---|---|
committer | Max Christian Pohle | 2019-11-13 00:27:47 +0100 |
commit | 1dcb4c6cc058800d8995bd3489ce840ff07055ec (patch) | |
tree | d16c02338c38d5bd06158fbcc021e52986b8b837 | |
parent | 151c39e6aa8e9ec9d9cbe31bcca81ada71d9c72b (diff) | |
download | pdnsupdate-1dcb4c6cc058800d8995bd3489ce840ff07055ec.tar.bz2 pdnsupdate-1dcb4c6cc058800d8995bd3489ce840ff07055ec.zip |
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.
-rw-r--r-- | README.md | 22 | ||||
-rw-r--r-- | uwsgi.ini | 28 | ||||
-rw-r--r-- | wsgi.py | 19 |
3 files changed, 69 insertions, 0 deletions
diff --git a/README.md b/README.md new file mode 100644 index 0000000..d8869ae --- /dev/null +++ b/README.md | |||
@@ -0,0 +1,22 @@ | |||
1 | Installation: FreeBSD | ||
2 | ===================== | ||
3 | |||
4 | 1. install uwsgi (dependency, but really small): `pkg install uwsgi` | ||
5 | |||
6 | 2. add to `/etc/rc.conf`: | ||
7 | ``` | ||
8 | uwsgi_enable="YES" | ||
9 | uwsgi_emperor="YES" | ||
10 | uwsgi_vassals_dir="/usr/local/www/*/uwsgi.ini" | ||
11 | ``` | ||
12 | |||
13 | 3. start uwsgi `service uwsgi start` | ||
14 | |||
15 | 4. Git clone this directory under /usr/local/www/ | ||
16 | |||
17 | |||
18 | WIP | ||
19 | === | ||
20 | |||
21 | This is work in progress. Do not expect wonders or good documentation in this | ||
22 | 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 @@ | |||
1 | [uwsgi] | ||
2 | master = true | ||
3 | socket = /var/run/%c.sock | ||
4 | reuse-port = true | ||
5 | master = true | ||
6 | reload-os-env = true | ||
7 | vaccuum = true | ||
8 | logto = /usr/local/www/%c/uwsgi.log | ||
9 | manage-script-name = true | ||
10 | chdir = /usr/local/www/%c | ||
11 | touch-reload = /usr/local/www/%c | ||
12 | wsgi-file = wsgi.py | ||
13 | # mount = /%c=%c/wsgi.py | ||
14 | # static-map = /static=/usr/local/www/%c/static | ||
15 | # static-map = /media=/usr/local/www/%c/media | ||
16 | unenv = DJANGO_SETTINGS_MODULE | ||
17 | unenv = DJANGO_SETTINGS | ||
18 | wsgi-env-behaviour = cheat | ||
19 | print = we are using %c | ||
20 | http = 10.0.1.99:8080 | ||
21 | |||
22 | |||
23 | |||
24 | # set cheaper algorithm to use, if not set default will be used | ||
25 | cheaper-algo = backlog | ||
26 | cheaper-overload = 4 | ||
27 | cheaper-idle = 1 | ||
28 | cheaper-initial = 0 | ||
@@ -0,0 +1,19 @@ | |||
1 | #!/usr/bin/env python3.6 | ||
2 | |||
3 | import time | ||
4 | import re | ||
5 | import subprocess | ||
6 | from cgi import parse_qs | ||
7 | |||
8 | def application(environ, start_response): | ||
9 | d = parse_qs(environ['QUERY_STRING']) | ||
10 | |||
11 | start_response('200 OK', [('Content-Type', 'text/plain')]) | ||
12 | if re.match('\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}', d.get('ip', ['0'])[0]): | ||
13 | ip = d.get('ip', ['0'])[0].encode() | ||
14 | if re.match('[0-9a-z]+', d.get('host', [''])[0]): | ||
15 | host = d.get('host', ['0'])[0].encode() | ||
16 | yield(subprocess.run(["/usr/local/bin/pdnsutil", "delete-rrset", "wire-me.de", host, "A"], stdout=subprocess.PIPE).stdout) | ||
17 | yield(subprocess.run(["/usr/local/bin/pdnsutil", "add-record", "wire-me.de", host, "A", ip], stdout=subprocess.PIPE)) | ||
18 | yield(subprocess.run(["/usr/local/bin/pdnsutil", "list-zone", "wire-me.de"], stdout=subprocess.PIPE).stdout) | ||
19 | |||