From fed3410ee6661ee401f80a24881712e8a9fe9368 Mon Sep 17 00:00:00 2001 From: Patrick Date: Sat, 23 Nov 2024 17:00:17 +0100 Subject: [PATCH] reshuffle --- .gitignore | 1 - Dockerfile | 5 ++++- Makefile | 16 ---------------- nginx.cnf => dist/nginx.cnf | 0 openssl.cnf => dist/openssl.cnf | 0 zonefile.cnf => dist/zonefile.cnf | 6 +++--- install.sh | 28 ++++++++++++++++++++++++++++ src/static/style.css | 4 ++-- src/templates/account.html | 9 +++++---- src/templates/index.html | 9 +++++---- src/templates/post.html | 9 +++++---- src/templates/view.html | 9 +++++---- src/wsgi.py | 4 ++-- 13 files changed, 59 insertions(+), 41 deletions(-) delete mode 100644 Makefile rename nginx.cnf => dist/nginx.cnf (100%) rename openssl.cnf => dist/openssl.cnf (100%) rename zonefile.cnf => dist/zonefile.cnf (71%) create mode 100644 install.sh diff --git a/.gitignore b/.gitignore index 2ddc086..4e9a2d0 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,3 @@ .venv/ __pycache__ -thread-sphere.tar posts.db diff --git a/Dockerfile b/Dockerfile index b28db99..5a12153 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,6 @@ +# SPDX-License-Identifier: AGPL-3.0-or-later +# Copyright (c) 2024 Interstellar Development + FROM python:alpine WORKDIR /usr/local/app @@ -10,4 +13,4 @@ RUN adduser -D app RUN chown -R app:app ../app USER app -CMD ["gunicorn","-w 2", "-b 0.0.0.0:5001", "wsgi:app"] +CMD ["gunicorn","-w 2", "-b 0.0.0.0:5000", "wsgi:app"] diff --git a/Makefile b/Makefile deleted file mode 100644 index 3f313c8..0000000 --- a/Makefile +++ /dev/null @@ -1,16 +0,0 @@ -APP = thread-sphere -DOMAIN = threadsphere.com - -build: - docker build -t $(APP) . - docker save -o $(APP).tar $(APP) - -install: - openssl genrsa -out /etc/ssl/private/$(APP).key 2048 - openssl req -new -key /etc/ssl/private/$(APP).key -out /etc/ssl/certs/$(APP).csr -config openssl.cnf - openssl x509 -req -in /etc/ssl/certs/$(APP).csr -CA /root/ca.crt -CAkey /root/ca.key -CAcreateserial -out /etc/ssl/certs/$(APP).crt -extfile openssl.cnf -extensions req_ext -days 500 -sha256 - cp nginx.cnf /etc/nginx/sites-enabled/$(APP) - echo "\nzone \"$(DOMAIN)\" {\n type master;\n file \"/etc/bind/db.$(DOMAIN)\";\n};" | tee -a /etc/bind/named.conf.local - cp zonefile.cnf /etc/bind/db.$(DOMAIN) - docker load -i $(APP).tar - docker run -p 5001:5001 --name $(APP) --restart always -d $(APP) diff --git a/nginx.cnf b/dist/nginx.cnf similarity index 100% rename from nginx.cnf rename to dist/nginx.cnf diff --git a/openssl.cnf b/dist/openssl.cnf similarity index 100% rename from openssl.cnf rename to dist/openssl.cnf diff --git a/zonefile.cnf b/dist/zonefile.cnf similarity index 71% rename from zonefile.cnf rename to dist/zonefile.cnf index 27d7d17..f321fe8 100644 --- a/zonefile.cnf +++ b/dist/zonefile.cnf @@ -7,6 +7,6 @@ $TTL 604800 604800 ) ; @ IN NS ns.threadsphere.com. -ns IN A 192.168.1.1 -@ IN A 192.168.1.1 -www IN A 192.168.1.1 \ No newline at end of file +ns IN A 192.168.16.1 +@ IN A 192.168.16.1 +www IN A 192.168.16.1 \ No newline at end of file diff --git a/install.sh b/install.sh new file mode 100644 index 0000000..7dd1f54 --- /dev/null +++ b/install.sh @@ -0,0 +1,28 @@ +#!/bin/sh + +# SPDX-License-Identifier: AGPL-3.0-or-later +# Copyright (c) 2024 Interstellar Development + +APP=thread-sphere +DOMAIN=threadsphere.com +PORT=5001 +DNS=" +zone \"$DOMAIN\" { + type master; + file \"/etc/bind/db.$DOMAIN\"; +};" + +docker build -t $APP . +cd dist +openssl genrsa -out /etc/ssl/private/$APP.key 2048 +openssl req -new -key /etc/ssl/private/$APP.key -out /etc/ssl/certs/$APP.csr -config openssl.cnf +openssl x509 -req -in /etc/ssl/certs/$APP.csr -CA /root/ca.crt -CAkey /root/ca.key -CAcreateserial -out /etc/ssl/certs/$APP.crt -extfile openssl.cnf -extensions req_ext -days 500 -sha256 +cp nginx.cnf /etc/nginx/sites-enabled/$APP +grep -qF "$DNS" /etc/bind/named.conf.local +if [ $? -eq 0 ]; then + echo "$DNS" | tee -a /etc/bind/named.conf.local +else + echo "Entry already exists in named.conf.local" +fi +cp zonefile.cnf /etc/bind/db.$DOMAIN +docker run -p $PORT:5000 --name $APP --restart always -d $APP diff --git a/src/static/style.css b/src/static/style.css index a7bae43..f704308 100644 --- a/src/static/style.css +++ b/src/static/style.css @@ -1,6 +1,6 @@ /* -This file is part of VM-Experiments. -Licensed under the AGPL-3.0-or-later. See LICENSE for details. +SPDX-License-Identifier: AGPL-3.0-or-later +Copyright (c) 2024 Interstellar Development */ * { diff --git a/src/templates/account.html b/src/templates/account.html index a1dfb08..2196bbf 100644 --- a/src/templates/account.html +++ b/src/templates/account.html @@ -1,9 +1,10 @@ - - diff --git a/src/templates/index.html b/src/templates/index.html index bc0fe6d..4961f5b 100644 --- a/src/templates/index.html +++ b/src/templates/index.html @@ -1,9 +1,10 @@ - - diff --git a/src/templates/post.html b/src/templates/post.html index 5a5a2cb..53e9d61 100644 --- a/src/templates/post.html +++ b/src/templates/post.html @@ -1,9 +1,10 @@ - - diff --git a/src/templates/view.html b/src/templates/view.html index 1500cc2..5a79d5c 100644 --- a/src/templates/view.html +++ b/src/templates/view.html @@ -1,9 +1,10 @@ - - diff --git a/src/wsgi.py b/src/wsgi.py index bba5037..04d37b8 100644 --- a/src/wsgi.py +++ b/src/wsgi.py @@ -1,5 +1,5 @@ -# This file is part of VM-Experiments. -# Licensed under the AGPL-3.0-or-later. See LICENSE for details. +# SPDX-License-Identifier: AGPL-3.0-or-later +# Copyright (c) 2024 Interstellar Development from flask import Flask, session, render_template, request, redirect, url_for import sqlite3