mirror of
https://github.com/hyperknot/openfreemap.git
synced 2026-05-21 14:02:15 +00:00
work
This commit is contained in:
@@ -1,4 +1,4 @@
|
|||||||
from ssh_lib import MODULES_DIR
|
from ssh_lib.config import config
|
||||||
from ssh_lib.utils import apt_get_install, exists, put
|
from ssh_lib.utils import apt_get_install, exists, put
|
||||||
|
|
||||||
|
|
||||||
@@ -20,4 +20,4 @@ def c1000k(c):
|
|||||||
def wrk(c):
|
def wrk(c):
|
||||||
apt_get_install(c, 'wrk')
|
apt_get_install(c, 'wrk')
|
||||||
c.sudo('mkdir -p /data/ofm/benchmark')
|
c.sudo('mkdir -p /data/ofm/benchmark')
|
||||||
put(c, f'{MODULES_DIR}/http_host/benchmark/wrk_custom_list.lua', '/data/ofm/benchmark')
|
put(c, f'{config.modules_dir}/http_host/benchmark/wrk_custom_list.lua', '/data/ofm/benchmark')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from ssh_lib import ASSETS_DIR
|
from ssh_lib.config import config
|
||||||
from ssh_lib.utils import put, put_str
|
from ssh_lib.utils import put, put_str
|
||||||
|
|
||||||
|
|
||||||
@@ -25,6 +25,10 @@ def kernel_vmovercommit(c):
|
|||||||
|
|
||||||
def kernel_thp_fix(c):
|
def kernel_thp_fix(c):
|
||||||
# transparent_hugepage
|
# transparent_hugepage
|
||||||
put(c, f'{ASSETS_DIR}/kernel/thp_fix_service', '/etc/systemd/system/thp_fix.service')
|
put(
|
||||||
|
c,
|
||||||
|
f'{config.local_assets_dir}/kernel/thp_fix_service',
|
||||||
|
'/etc/systemd/system/thp_fix.service',
|
||||||
|
)
|
||||||
c.sudo('systemctl daemon-reload')
|
c.sudo('systemctl daemon-reload')
|
||||||
c.sudo('systemctl enable thp_fix')
|
c.sudo('systemctl enable thp_fix')
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
from ssh_lib import ASSETS_DIR
|
from ssh_lib.config import config
|
||||||
from ssh_lib.utils import (
|
from ssh_lib.utils import (
|
||||||
apt_get_install,
|
apt_get_install,
|
||||||
apt_get_purge,
|
apt_get_purge,
|
||||||
@@ -41,10 +41,10 @@ def nginx(c):
|
|||||||
|
|
||||||
generate_self_signed_cert(c)
|
generate_self_signed_cert(c)
|
||||||
|
|
||||||
put(c, f'{ASSETS_DIR}/nginx/nginx.conf', '/etc/nginx/')
|
put(c, f'{config.local_assets_dir}/nginx/nginx.conf', '/etc/nginx/')
|
||||||
put(c, f'{ASSETS_DIR}/nginx/mime.types', '/etc/nginx/')
|
put(c, f'{config.local_assets_dir}/nginx/mime.types', '/etc/nginx/')
|
||||||
put(c, f'{ASSETS_DIR}/nginx/default_disable.conf', '/data/nginx/sites')
|
put(c, f'{config.local_assets_dir}/nginx/default_disable.conf', '/data/nginx/sites')
|
||||||
put(c, f'{ASSETS_DIR}/nginx/cloudflare.conf', '/data/nginx/config')
|
put(c, f'{config.local_assets_dir}/nginx/cloudflare.conf', '/data/nginx/config')
|
||||||
|
|
||||||
sudo_cmd(c, 'curl https://ssl-config.mozilla.org/ffdhe2048.txt -o /etc/nginx/ffdhe2048.txt')
|
sudo_cmd(c, 'curl https://ssl-config.mozilla.org/ffdhe2048.txt -o /etc/nginx/ffdhe2048.txt')
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
from ssh_lib import PLANETILER_BIN, PLANETILER_SRC
|
from ssh_lib.config import config
|
||||||
from ssh_lib.java import java
|
from ssh_lib.java import java
|
||||||
from ssh_lib.utils import exists, sudo_cmd
|
from ssh_lib.utils import exists, sudo_cmd
|
||||||
|
|
||||||
|
|
||||||
PLANETILER_COMMIT = 'cc769c'
|
PLANETILER_COMMIT = 'cc769c'
|
||||||
PLANETILER_PATH = f'{PLANETILER_BIN}/planetiler.jar'
|
PLANETILER_PATH = f'{config.planetiler_bin}/planetiler.jar'
|
||||||
|
|
||||||
|
|
||||||
def install_planetiler(c):
|
def install_planetiler(c):
|
||||||
@@ -15,24 +15,24 @@ def install_planetiler(c):
|
|||||||
java(c)
|
java(c)
|
||||||
|
|
||||||
c.sudo('rm -rf /root/.m2') # cleaning maven cache
|
c.sudo('rm -rf /root/.m2') # cleaning maven cache
|
||||||
c.sudo(f'rm -rf {PLANETILER_BIN} {PLANETILER_SRC}')
|
c.sudo(f'rm -rf {config.planetiler_bin} {config.planetiler_src}')
|
||||||
c.sudo(f'mkdir -p {PLANETILER_BIN} {PLANETILER_SRC}')
|
c.sudo(f'mkdir -p {config.planetiler_bin} {config.planetiler_src}')
|
||||||
|
|
||||||
c.sudo('git config --global advice.detachedHead false')
|
c.sudo('git config --global advice.detachedHead false')
|
||||||
c.sudo(
|
c.sudo(
|
||||||
f'git clone --recurse-submodules https://github.com/onthegomap/planetiler.git {PLANETILER_SRC}'
|
f'git clone --recurse-submodules https://github.com/onthegomap/planetiler.git {config.planetiler_src}'
|
||||||
)
|
)
|
||||||
|
|
||||||
sudo_cmd(c, f'cd {PLANETILER_SRC} && git checkout {PLANETILER_COMMIT}')
|
sudo_cmd(c, f'cd {config.planetiler_src} && git checkout {PLANETILER_COMMIT}')
|
||||||
sudo_cmd(c, f'cd {PLANETILER_SRC} && git submodule update --init --recursive')
|
sudo_cmd(c, f'cd {config.planetiler_src} && git submodule update --init --recursive')
|
||||||
|
|
||||||
sudo_cmd(c, f'cd {PLANETILER_SRC} && ./mvnw clean test package')
|
sudo_cmd(c, f'cd {config.planetiler_src} && ./mvnw clean test package')
|
||||||
|
|
||||||
c.sudo(
|
c.sudo(
|
||||||
f'mv {PLANETILER_SRC}/planetiler-dist/target/planetiler-dist-*-SNAPSHOT-with-deps.jar {PLANETILER_PATH}',
|
f'mv {config.planetiler_src}/planetiler-dist/target/planetiler-dist-*-SNAPSHOT-with-deps.jar {PLANETILER_PATH}',
|
||||||
warn=True,
|
warn=True,
|
||||||
)
|
)
|
||||||
|
|
||||||
c.sudo(f'java -jar {PLANETILER_PATH} --help', hide=True)
|
c.sudo(f'java -jar {PLANETILER_PATH} --help', hide=True)
|
||||||
|
|
||||||
c.sudo(f'rm -rf {PLANETILER_SRC}')
|
c.sudo(f'rm -rf {config.planetiler_src}')
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
import json5
|
import json5
|
||||||
|
from jsonschema import ValidationError, validate
|
||||||
|
|
||||||
from ssh_lib.benchmark import c1000k, wrk
|
from ssh_lib.benchmark import c1000k, wrk
|
||||||
from ssh_lib.config import config
|
from ssh_lib.config import config
|
||||||
@@ -37,17 +39,41 @@ def upload_config_and_certs(c):
|
|||||||
print(f'{config.local_config_jsonc} not found. Make sure it exists in the /config dir')
|
print(f'{config.local_config_jsonc} not found. Make sure it exists in the /config dir')
|
||||||
return
|
return
|
||||||
|
|
||||||
# validate using json5 + jsonschema
|
# Load and parse the JSONC/JSON5 config file
|
||||||
# use config.config_schema_json
|
try:
|
||||||
config_data = json5.loads(config.local_config_jsonc.read_text())
|
config_data = json5.loads(config.local_config_jsonc.read_text())
|
||||||
|
except Exception as e:
|
||||||
|
print(f'❌ Error parsing config file: {e}')
|
||||||
|
return
|
||||||
|
|
||||||
|
# Load the JSON schema
|
||||||
|
try:
|
||||||
|
schema = json.loads(config.config_schema_json.read_text())
|
||||||
|
except Exception as e:
|
||||||
|
print(f'❌ Error loading schema file: {e}')
|
||||||
|
return
|
||||||
|
|
||||||
|
# Validate the config against the schema
|
||||||
|
try:
|
||||||
|
validate(instance=config_data, schema=schema)
|
||||||
|
print('✓ Configuration is valid')
|
||||||
|
except ValidationError as e:
|
||||||
|
print('❌ Configuration validation failed:')
|
||||||
|
print(f' Error: {e.message}')
|
||||||
|
if e.path:
|
||||||
|
print(f' Path: {".".join(str(p) for p in e.path)}')
|
||||||
|
return
|
||||||
|
except Exception as e:
|
||||||
|
print(f'❌ Validation error: {e}')
|
||||||
|
return
|
||||||
|
|
||||||
# pre-generate all the slugs
|
# pre-generate all the slugs
|
||||||
for domain_data in config_data['domains']:
|
for domain_data in config_data['domains']:
|
||||||
domain_data['slug'] = slugify(domain_data['domain'], separator='_')
|
domain_data['slug'] = slugify(domain_data['domain'], separator='_')
|
||||||
|
|
||||||
if domain_data['cert']['type'] == 'upload':
|
if domain_data['cert']['type'] == 'upload':
|
||||||
local_cert_path = domain_data['cert']['cert_path']
|
local_cert_path = Path(domain_data['cert']['cert_path'])
|
||||||
cert_basename = local_cert_path.basename
|
cert_basename = local_cert_path.stem
|
||||||
local_key_path = local_cert_path.parent / f'{cert_basename}.key'
|
local_key_path = local_cert_path.parent / f'{cert_basename}.key'
|
||||||
if not local_cert_path.is_file() or local_key_path.is_file():
|
if not local_cert_path.is_file() or local_key_path.is_file():
|
||||||
print(
|
print(
|
||||||
@@ -61,8 +87,6 @@ def upload_config_and_certs(c):
|
|||||||
put(c, local_cert_path, remote_cert_path)
|
put(c, local_cert_path, remote_cert_path)
|
||||||
put(c, local_key_path, remote_key_path)
|
put(c, local_key_path, remote_key_path)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# generate a normal JSON and upload it
|
# generate a normal JSON and upload it
|
||||||
config_str = json.dumps(config_data, indent=2, ensure_ascii=False)
|
config_str = json.dumps(config_data, indent=2, ensure_ascii=False)
|
||||||
put_str(c, f'{config.remote_config}/config.json', config_str)
|
put_str(c, f'{config.remote_config}/config.json', config_str)
|
||||||
|
|||||||
Reference in New Issue
Block a user