jobs - edit referrers and user-agents data and init work on autoconf integration
This commit is contained in:
@@ -9,9 +9,9 @@ class Config :
|
||||
self.__swarm = swarm
|
||||
self.__api = api
|
||||
|
||||
def __jobs(self, type) :
|
||||
utils.log("[*] Starting jobs (type = " + type + ") ...")
|
||||
proc = subprocess.run(["/bin/su", "-c", "/opt/bunkerized-nginx/entrypoint/" + type + "-jobs.sh", "nginx"], capture_output=True)
|
||||
def __jobs(self) :
|
||||
utils.log("[*] Starting jobs")
|
||||
proc = subprocess.run(["/bin/su", "-c", "/opt/bunkerized-nginx/entrypoint/jobs.sh", "nginx"], capture_output=True)
|
||||
stdout = proc.stdout.decode("ascii")
|
||||
stderr = proc.stderr.decode("ascii")
|
||||
if len(stdout) > 1 :
|
||||
@@ -71,7 +71,7 @@ class Config :
|
||||
# We're done
|
||||
if proc.returncode == 0 :
|
||||
if self.__swarm :
|
||||
return self.__jobs("pre")
|
||||
return self.__jobs()
|
||||
return True
|
||||
utils.log("[!] Error while generating site config for " + env["SERVER_NAME"] + " : return code = " + str(proc.returncode))
|
||||
|
||||
@@ -80,11 +80,7 @@ class Config :
|
||||
return False
|
||||
|
||||
def reload(self, instances) :
|
||||
if self.__api_call(instances, "/reload") :
|
||||
if self.__swarm :
|
||||
return self.__jobs("post")
|
||||
return True
|
||||
return False
|
||||
return self.__api_call(instances, "/reload")
|
||||
|
||||
def __ping(self, instances) :
|
||||
return self.__api_call(instances, "/ping")
|
||||
|
||||
@@ -1,20 +1,19 @@
|
||||
FROM alpine
|
||||
|
||||
COPY autoconf/dependencies.sh /tmp
|
||||
RUN chmod +x /tmp/dependencies.sh && \
|
||||
/tmp/dependencies.sh && \
|
||||
rm -f /tmp/dependencies.sh && \
|
||||
mkdir /opt/bunkerized-nginx
|
||||
|
||||
COPY gen/ /opt/bunkerized-nginx/gen
|
||||
COPY entrypoint/ /opt/bunkerized-nginx/entrypoint
|
||||
COPY confs/global/ /opt/bunkerized-nginx/confs/global
|
||||
COPY confs/site/ /opt/bunkerized-nginx/confs/site
|
||||
COPY scripts/ /opt/bunkerized-nginx/scripts
|
||||
COPY jobs/ /opt/bunkerized-nginx/jobs
|
||||
COPY settings.json /opt/bunkerized-nginx/
|
||||
COPY misc/cron /etc/crontabs/nginx
|
||||
COPY autoconf/* /opt/bunkerized-nginx/entrypoint/
|
||||
|
||||
RUN apk add --no-cache py3-pip bash certbot curl openssl && \
|
||||
pip3 install -r /opt/bunkerized-nginx/gen/requirements.txt && \
|
||||
pip3 install -r /opt/bunkerized-nginx/entrypoint/requirements.txt && \
|
||||
pip3 install -r /opt/bunkerized-nginx/jobs/requirements.txt
|
||||
|
||||
COPY autoconf/prepare.sh /tmp
|
||||
RUN chmod +x /tmp/prepare.sh && \
|
||||
/tmp/prepare.sh && \
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
#!/bin/sh
|
||||
|
||||
# install dependencies
|
||||
apk add py3-pip bash certbot curl openssl
|
||||
pip3 install docker requests jinja2
|
||||
@@ -14,6 +14,8 @@ find /opt/bunkerized-nginx -type f -exec chmod 0740 {} \;
|
||||
find /opt/bunkerized-nginx -type d -exec chmod 0750 {} \;
|
||||
chmod ugo+x /opt/bunkerized-nginx/entrypoint/* /opt/bunkerized-nginx/scripts/*
|
||||
chmod ugo+x /opt/bunkerized-nginx/gen/main.py
|
||||
chmod ugo+x /opt/bunkerized-nginx/jobs/main.py
|
||||
chmod ugo+x /opt/bunkerized-nginx/jobs/reload.py
|
||||
chmod 770 /opt/bunkerized-nginx
|
||||
chmod 440 /opt/bunkerized-nginx/settings.json
|
||||
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/usr/bin/python3
|
||||
|
||||
import sys, socket, os
|
||||
|
||||
if not os.path.exists("/tmp/autoconf.sock") :
|
||||
sys.exit(1)
|
||||
|
||||
try :
|
||||
client = socket.socket(socket.AF_UNIX, socket.SOCK_STREAM)
|
||||
client.connect("/tmp/autoconf.sock")
|
||||
client.send("reload".encode("utf-8"))
|
||||
data = client.recv(512)
|
||||
client.close()
|
||||
if not data or data.decode("utf-8") != "ok" :
|
||||
sys.exit(3)
|
||||
except Exception as e :
|
||||
sys.exit(2)
|
||||
|
||||
sys.exit(0)
|
||||
3
autoconf/requirements.txt
Normal file
3
autoconf/requirements.txt
Normal file
@@ -0,0 +1,3 @@
|
||||
docker
|
||||
requests
|
||||
jinja2
|
||||
Reference in New Issue
Block a user