lsb-release

This commit is contained in:
Mateusz Gruszczyński
2025-10-24 09:19:20 +02:00
parent fe1b7048bb
commit 4d4bea23e9

View File

@@ -363,19 +363,55 @@ RestartSec=3s
WantedBy=multi-user.target
"""
def lsb_info():
try:
apt_try_install(["lsb-release"])
dist = run_out(["bash","-lc","lsb_release -si"]).strip().lower().replace(" ", "")
rel = run_out(["bash","-lc","lsb_release -sr"]).strip()
code = run_out(["bash","-lc","lsb_release -sc"]).strip()
return {"ID": dist, "VERSION_ID": rel, "CODENAME": code, "PRETTY": f"{dist} {rel} ({code})"}
except Exception:
return os_release()
# ========== Angie ==========
def setup_angie(ipv6_enabled: bool):
with step("Adding Angie repo and installing Angie packages"):
# Ubuntu/Debian: common base
apt_try_install(["ca-certificates", "curl", "gnupg", "apt-transport-https", "software-properties-common"])
run(["curl", "-fsSL", "-o", "/etc/apt/trusted.gpg.d/angie-signing.gpg",
"https://angie.software/keys/angie-signing.gpg"])
os_id = run_out(["bash","-lc",". /etc/os-release && echo \"$ID/$VERSION_ID $VERSION_CODENAME\""]).strip()
write_file(Path("/etc/apt/sources.list.d/angie.list"),
f"deb https://download.angie.software/angie/{os_id} main\n")
apt_try_install([
"ca-certificates", "curl", "gnupg", "apt-transport-https",
"software-properties-common", "lsb-release"
])
run([
"curl", "-fsSL", "-o", "/etc/apt/trusted.gpg.d/angie-signing.gpg",
"https://angie.software/keys/angie-signing.gpg"
])
try:
dist = run_out(["bash", "-lc", "lsb_release -si"]).strip().lower().replace(" ", "")
rel = run_out(["bash", "-lc", "lsb_release -sr"]).strip()
code = run_out(["bash", "-lc", "lsb_release -sc"]).strip()
except Exception:
os_id = run_out([
"bash","-lc",". /etc/os-release && echo \"$ID\""
]).strip()
rel = run_out([
"bash","-lc",". /etc/os-release && echo \"$VERSION_ID\""
]).strip()
code = run_out([
"bash","-lc",". /etc/os-release && echo \"$VERSION_CODENAME\""
]).strip()
dist = os_id.lower().replace(" ", "")
os_id = f"{dist}/{rel}".strip().strip("/")
if code:
line = f"deb https://download.angie.software/angie/{os_id} {code} main\n"
else:
line = f"deb https://download.angie.software/angie/{os_id} main\n"
write_file(Path("/etc/apt/sources.list.d/angie.list"), line)
run(["apt-get", "update"])
# Angie core + optional modules if available (prometheus + console for your metrics block)
base = ["angie", "angie-module-headers-more", "angie-module-brotli", "angie-module-zstd"]
optional = ["angie-module-prometheus", "angie-console-light"]
apt_install(base)
@@ -386,7 +422,6 @@ def setup_angie(ipv6_enabled: bool):
modules_dir.mkdir(parents=True, exist_ok=True)
write_file(Path("/etc/angie/angie.conf"), ANGIE_CONF_TEMPLATE, 0o644)
# wrapper forcing sudo (NOPASSWD is set for npm user)
WRAP = """#!/bin/sh
exec sudo -n /usr/sbin/angie "$@"
"""
@@ -403,6 +438,7 @@ exec sudo -n /usr/sbin/angie "$@"
with step("Installing corrected systemd unit for Angie"):
write_file(Path("/etc/systemd/system/angie.service"), ANGIE_UNIT, 0o644)
def write_metrics_files():
"""Create /etc/angie/metrics.conf (port 82 with console & status)."""
with step("Adding Angie metrics & console on :82"):
@@ -974,7 +1010,7 @@ def main():
apt_update_upgrade()
apt_purge(["nginx","openresty","nodejs","npm","yarn","certbot","rustc","cargo"])
apt_install(["ca-certificates","curl","gnupg","openssl","apache2-utils","logrotate","sudo","acl",
"python3","sqlite3"])
"python3","sqlite3", "git", "lsb-release"])
setup_angie(ipv6_enabled=args.enable_ipv6)
write_metrics_files()