mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
ledns -> roundrobin
This commit is contained in:
@@ -1,2 +0,0 @@
|
||||
# once per day
|
||||
2 34 * * * ofm sudo /usr/bin/bash /data/ofm/http_host/bin/ledns_reader.sh >> /data/ofm/http_host/logs/ledns_reader.log 2>&1
|
||||
2
modules/http_host/cron.d/ofm_roundrobin_reader
Normal file
2
modules/http_host/cron.d/ofm_roundrobin_reader
Normal file
@@ -0,0 +1,2 @@
|
||||
# once per day
|
||||
2 34 * * * ofm sudo /usr/bin/bash /data/ofm/http_host/bin/roundrobin_reader.sh >> /data/ofm/http_host/logs/roundrobin_reader.log 2>&1
|
||||
@@ -16,7 +16,7 @@ def write_nginx_config():
|
||||
curl_text_mix = ''
|
||||
|
||||
domain_le = config.ofm_config['domain_le']
|
||||
domain_ledns = config.ofm_config['domain_ledns']
|
||||
domain_roundrobin = config.ofm_config['domain_roundrobin']
|
||||
skip_letsencrypt = config.ofm_config['skip_letsencrypt']
|
||||
|
||||
# remove old configs and certs
|
||||
@@ -27,18 +27,18 @@ def write_nginx_config():
|
||||
file.unlink()
|
||||
|
||||
# processing Round Robin DNS config
|
||||
if domain_ledns:
|
||||
if domain_roundrobin:
|
||||
if not config.rclone_config.is_file():
|
||||
sys.exit('rclone.conf missing')
|
||||
|
||||
# download the ledns certificate from bucket using rclone
|
||||
write_ledns_reader_script(domain_ledns)
|
||||
subprocess.run(['bash', config.http_host_bin / 'ledns_reader.sh'], check=True)
|
||||
# download the roundrobin certificate from bucket using rclone
|
||||
write_roundrobin_reader_script(domain_roundrobin)
|
||||
subprocess.run(['bash', config.http_host_bin / 'roundrobin_reader.sh'], check=True)
|
||||
|
||||
curl_text_mix += create_nginx_conf(
|
||||
template_path=config.nginx_confs / 'ledns.conf',
|
||||
local='ofm_ledns',
|
||||
domain=domain_ledns,
|
||||
template_path=config.nginx_confs / 'roundrobin.conf',
|
||||
local='ofm_roundrobin',
|
||||
domain=domain_roundrobin,
|
||||
)
|
||||
|
||||
# processing Let's Encrypt config
|
||||
@@ -317,13 +317,13 @@ def create_latest_locations(*, local: str, domain: str) -> str:
|
||||
return location_str
|
||||
|
||||
|
||||
def write_ledns_reader_script(domain_ledns):
|
||||
def write_roundrobin_reader_script(domain_roundrobin):
|
||||
script = f"""
|
||||
#!/usr/bin/env bash
|
||||
export RCLONE_CONFIG=/data/ofm/config/rclone.conf
|
||||
rclone copyto -v "remote:ofm-private/ledns/{domain_ledns}/ofm_ledns.cert" /data/nginx/certs/ofm_ledns.cert
|
||||
rclone copyto -v "remote:ofm-private/ledns/{domain_ledns}/ofm_ledns.key" /data/nginx/certs/ofm_ledns.key
|
||||
rclone copyto -v "remote:ofm-private/roundrobin/{domain_roundrobin}/ofm_roundrobin.cert" /data/nginx/certs/ofm_roundrobin.cert
|
||||
rclone copyto -v "remote:ofm-private/roundrobin/{domain_roundrobin}/ofm_roundrobin.key" /data/nginx/certs/ofm_roundrobin.key
|
||||
""".strip()
|
||||
|
||||
with open(config.http_host_bin / 'ledns_reader.sh', 'w') as fp:
|
||||
with open(config.http_host_bin / 'roundrobin_reader.sh', 'w') as fp:
|
||||
fp.write(script)
|
||||
|
||||
@@ -8,8 +8,8 @@ server {
|
||||
listen [::]:443 ssl;
|
||||
http2 on;
|
||||
|
||||
ssl_certificate /data/nginx/certs/ofm_ledns.cert;
|
||||
ssl_certificate_key /data/nginx/certs/ofm_ledns.key;
|
||||
ssl_certificate /data/nginx/certs/ofm_roundrobin.cert;
|
||||
ssl_certificate_key /data/nginx/certs/ofm_roundrobin.key;
|
||||
|
||||
ssl_session_timeout 1d;
|
||||
ssl_session_cache shared:MozSSL:10m; # about 40000 sessions
|
||||
@@ -24,9 +24,9 @@ server {
|
||||
|
||||
# access log doesn't contain IP address
|
||||
#access_log off;
|
||||
access_log /data/ofm/http_host/logs_nginx/ledns-access.jsonl access_json buffer=128k;
|
||||
access_log /data/ofm/http_host/logs_nginx/roundrobin-access.jsonl access_json buffer=128k;
|
||||
|
||||
error_log /data/ofm/http_host/logs_nginx/ledns-error.log;
|
||||
error_log /data/ofm/http_host/logs_nginx/roundrobin-error.log;
|
||||
|
||||
__LOCATION_BLOCKS__
|
||||
|
||||
@@ -51,6 +51,6 @@ server {
|
||||
# catch-all block to deny all other requests
|
||||
location / {
|
||||
deny all;
|
||||
error_log /data/ofm/http_host/logs_nginx/ledns-deny.log error;
|
||||
error_log /data/ofm/http_host/logs_nginx/roundrobin-deny.log error;
|
||||
}
|
||||
}
|
||||
@@ -19,8 +19,8 @@ class Configuration:
|
||||
telegram_token = ofm_config['telegram_token']
|
||||
telegram_chat_id = ofm_config['telegram_chat_id']
|
||||
|
||||
domain_ledns = ofm_config['domain_ledns']
|
||||
domain_root = '.'.join(domain_ledns.split('.')[-2:])
|
||||
domain_roundrobin = ofm_config['domain_roundrobin']
|
||||
domain_root = '.'.join(domain_roundrobin.split('.')[-2:])
|
||||
|
||||
cloudflare_ini = dotenv_values(ofm_config_dir / 'cloudflare.ini')
|
||||
cloudflare_api_token = cloudflare_ini['dns_cloudflare_api_token']
|
||||
|
||||
@@ -72,9 +72,9 @@ def run_area(area):
|
||||
try:
|
||||
# don't check latest
|
||||
if relaxed_mode:
|
||||
check_host_version(config.domain_ledns, host_ip, area, version)
|
||||
check_host_version(config.domain_roundrobin, host_ip, area, version)
|
||||
else:
|
||||
check_host_latest(config.domain_ledns, host_ip, area, version)
|
||||
check_host_latest(config.domain_roundrobin, host_ip, area, version)
|
||||
|
||||
results[host_ip] = True
|
||||
except Exception as e:
|
||||
@@ -91,11 +91,11 @@ def update_records(working_hosts) -> bool:
|
||||
|
||||
updated |= set_records_round_robin(
|
||||
zone_id=zone_id,
|
||||
name=config.domain_ledns,
|
||||
name=config.domain_roundrobin,
|
||||
host_ip_set=working_hosts,
|
||||
proxied=False,
|
||||
ttl=300,
|
||||
comment='domain_ledns',
|
||||
comment='domain_roundrobin',
|
||||
cloudflare_api_token=config.cloudflare_api_token,
|
||||
)
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
#env > /data/ofm/ledns/env.txt
|
||||
#env > /data/ofm/roundrobin/env.txt
|
||||
#RENEWED_DOMAINS=direct.openfreemap.org
|
||||
#RENEWED_LINEAGE=/etc/letsencrypt/live/ofm_ledns
|
||||
#RENEWED_LINEAGE=/etc/letsencrypt/live/ofm_roundrobin
|
||||
|
||||
export RCLONE_CONFIG=/data/ofm/config/rclone.conf
|
||||
|
||||
rclone copyto -v --copy-links "$RENEWED_LINEAGE/fullchain.pem" "remote:ofm-private/ledns/$RENEWED_DOMAINS/ofm_ledns.cert"
|
||||
rclone copyto -v --copy-links "$RENEWED_LINEAGE/privkey.pem" "remote:ofm-private/ledns/$RENEWED_DOMAINS/ofm_ledns.key"
|
||||
rclone copyto -v --copy-links "$RENEWED_LINEAGE/fullchain.pem" "remote:ofm-private/roundrobin/$RENEWED_DOMAINS/ofm_roundrobin.cert"
|
||||
rclone copyto -v --copy-links "$RENEWED_LINEAGE/privkey.pem" "remote:ofm-private/roundrobin/$RENEWED_DOMAINS/ofm_roundrobin.key"
|
||||
|
||||
@@ -43,7 +43,7 @@ def set_version(area, version):
|
||||
def check_all_hosts(area, version) -> bool:
|
||||
oc = config.ofm_config
|
||||
|
||||
domain = oc['domain_ledns'] or oc['domain_le']
|
||||
domain = oc['domain_roundrobin'] or oc['domain_le']
|
||||
print(f'Using domain: {domain}')
|
||||
|
||||
try:
|
||||
|
||||
Reference in New Issue
Block a user