fix auto-update

This commit is contained in:
Zsolt Ero
2024-09-10 01:46:44 +02:00
parent 0bd2a19d1c
commit eb2d82d764
9 changed files with 35 additions and 34 deletions

View File

@@ -106,5 +106,4 @@ def debug():
if __name__ == '__main__':
# print(config.host_config)
cli()

View File

@@ -1,4 +1,5 @@
import json
import subprocess
from pathlib import Path
@@ -14,17 +15,17 @@ class Configuration:
assets_dir = http_host_dir / 'assets'
mnt_dir = Path('/mnt/ofm')
ofm_config_dir = Path('/data/ofm/config')
deployed_versions_dir = ofm_config_dir / 'deployed_versions'
certs_dir = Path('/data/nginx/certs')
nginx_confs = Path(__file__).parent / 'nginx_confs'
try:
with open(ofm_config_dir / 'http_host.json') as fp:
host_config = json.load(fp)
except Exception:
host_config = {}
ofm_config_dir = Path('/data/ofm/config')
deployed_versions_dir = ofm_config_dir / 'deployed_versions'
ofm_config = json.loads((ofm_config_dir / 'config.json').read_text())
rclone_config = ofm_config_dir / 'rclone.conf'
rclone_bin = subprocess.run(['which', 'rclone'], capture_output=True, text=True).stdout.strip()
config = Configuration()

View File

@@ -13,8 +13,8 @@ def write_nginx_config():
curl_text_mix = ''
domain_le = config.host_config['domain_le']
domain_ledns = config.host_config['domain_ledns']
domain_le = config.ofm_config['domain_le']
domain_ledns = config.ofm_config['domain_ledns']
# remove old configs and certs
for file in Path('/data/nginx/sites').glob('ofm_*.conf'):
@@ -25,7 +25,7 @@ def write_nginx_config():
# processing Round Robin DNS config
if domain_ledns:
if not (config.ofm_config_dir / 'rclone.conf').is_file():
if not config.rclone_config.is_file():
sys.exit('rclone.conf missing')
# download the ledns certificate from bucket using rclone
@@ -64,7 +64,7 @@ def write_nginx_config():
'--webroot-path=/data/nginx/acme-challenges',
'--noninteractive',
'-m',
config.host_config['le_email'],
config.ofm_config['le_email'],
'--agree-tos',
'--cert-name=ofm_le',
# '--staging',
@@ -125,12 +125,11 @@ def create_location_blocks(*, local, domain):
area=area, version=version, subdir=subdir, local=local, domain=domain
)
if not curl_text:
curl_text = (
'\ntest with:\n'
f'curl -H "Host: __LOCAL__" -I http://localhost/{area}/{version}/14/8529/5975.pbf\n'
f'curl -I https://__DOMAIN__/{area}/{version}/14/8529/5975.pbf'
)
curl_text += (
'\ntest with:\n'
f'curl -H "Host: __LOCAL__" -I http://localhost/{area}/{version}/14/8529/5975.pbf\n'
f'curl -I https://__DOMAIN__/{area}/{version}/14/8529/5975.pbf'
)
location_str += create_latest_locations(local=local, domain=domain)

View File

@@ -36,7 +36,7 @@ def full_sync(force=False):
btrfs_downloaded += download_area_version(area='monaco', version='deployed')
# download latest and deployed planet
if not config.host_config.get('skip_planet'):
if not config.ofm_config.get('skip_planet'):
btrfs_downloaded += download_area_version(area='planet', version='latest')
btrfs_downloaded += download_area_version(area='planet', version='deployed')

View File

@@ -3,6 +3,7 @@ from setuptools import find_packages, setup
requirements = [
'click',
'pycurl',
'requests',
]