ubuntu deadsneaks

This commit is contained in:
Mateusz Gruszczyński
2025-10-24 21:00:04 +02:00
parent 590532477e
commit 3c1804c620

View File

@@ -170,6 +170,28 @@ def write_resolvers_conf(ipv6_enabled: bool):
content = f"resolver {' '.join(ips)} valid=10s{ipv6_flag};\n" content = f"resolver {' '.join(ips)} valid=10s{ipv6_flag};\n"
write_file(Path("/etc/angie/conf.d/include/resolvers.conf"), content, 0o644) write_file(Path("/etc/angie/conf.d/include/resolvers.conf"), content, 0o644)
def comment_x_served_by_step(path="/etc/angie/conf.d/include/proxy.conf"):
p = Path(path)
if not p.exists():
raise FileNotFoundError(path)
src = p.read_text()
pattern = re.compile(r'^(?P<ws>\s*)(?!#)\s*add_header\s+X-Served-By\s+\$host\s*;\s*$', re.MULTILINE)
count = len(pattern.findall(src))
if count == 0:
return 0
backup = p.with_suffix(p.suffix + ".bak")
shutil.copy2(p, backup)
out = pattern.sub(lambda m: f"{m.group('ws')}# add_header X-Served-By $host;", src)
fd, tmp = tempfile.mkstemp(dir=str(p.parent))
os.close(fd)
Path(tmp).write_text(out)
shutil.copymode(p, tmp)
os.replace(tmp, p)
print(f"✔ Commented {count} line(s) | backup: {backup}")
return count
def download_extract_tar_gz(url: str, dest_dir: Path) -> Path: def download_extract_tar_gz(url: str, dest_dir: Path) -> Path:
dest_dir.mkdir(parents=True, exist_ok=True) dest_dir.mkdir(parents=True, exist_ok=True)
with step("Downloading and untaring"): with step("Downloading and untaring"):
@@ -1332,6 +1354,8 @@ def main():
install_logrotate_for_data_logs() install_logrotate_for_data_logs()
fix_logrotate_permissions_and_wrapper() fix_logrotate_permissions_and_wrapper()
sync_backup_nginx_conf() sync_backup_nginx_conf()
comment_x_served_by_step()
with step("Restarting services after installation"): with step("Restarting services after installation"):
run(["systemctl","restart","angie.service"], check=False) run(["systemctl","restart","angie.service"], check=False)
run(["systemctl","restart","npm.service"], check=False) run(["systemctl","restart","npm.service"], check=False)