diff --git a/npm_install.py b/npm_install.py index 73632de..45ca7c8 100644 --- a/npm_install.py +++ b/npm_install.py @@ -180,9 +180,9 @@ def write_resolvers_conf(ipv6_enabled: bool): def validate_nodejs_version(version: str) -> tuple[bool, str, str | None]: version_map = { - 'latest': '22', - 'lts': '22', - 'current': '23' + 'latest': '21', + 'lts': '18', + 'current': '21' } resolved = version_map.get(version.lower(), version) @@ -203,6 +203,67 @@ def validate_nodejs_version(version: str) -> tuple[bool, str, str | None]: return True, resolved, None +def validate_supported_os(): + distro_id = OSREL.get('ID', '').lower() + version_id = OSREL.get('VERSION_ID', '').strip() + + SUPPORTED = { + 'debian': ['11', '12', '13'], + 'ubuntu': ['20.04', '22.04', '24.04'], + + # Debian derivatives + 'proxmox': ['7', '8', '9'], + 'devuan': ['4', '5'], + 'armbian': ['23.02', '24.02'], + 'mx': ['21', '23'], + 'kali': ['2023.1', '2024.1'], + 'parrot': ['5', '6'], + + # Ubuntu derivatives + 'pop': ['20.04', '22.04'], + 'mint': ['20', '21', '22'], + 'zorin': ['16', '17'], + 'elementary': ['6', '7'], + 'kubuntu': ['20.04', '22.04', '24.04'], + 'xubuntu': ['20.04', '22.04', '24.04'], + 'lubuntu': ['20.04', '22.04', '24.04'], + } + + if distro_id not in SUPPORTED: + print(f"\n⚠ ERROR: Unsupported distribution: {distro_id}") + print(f" Detected: {OSREL.get('PRETTY', 'Unknown')}") + print(f"\n Supported distributions:") + print(f" • Debian 11 (Bullseye), 12 (Bookworm), 13 (Trixie)") + print(f" • Ubuntu 20.04 LTS, 22.04 LTS, 24.04 LTS") + print(f" • Debian derivatives: Proxmox VE, Devuan, MX Linux, Kali, Parrot") + print(f" • Ubuntu derivatives: Linux Mint, Pop!_OS, Zorin, elementary OS") + print(f"\n Your distribution may work but is not officially tested.") + print(f" Continue at your own risk or install on a supported system.\n") + sys.exit(1) + + supported_versions = SUPPORTED[distro_id] + version_match = False + + for supported_ver in supported_versions: + if version_id.startswith(supported_ver): + version_match = True + break + + if not version_match: + print(f"\n⚠ WARNING: Unsupported version of {distro_id}: {version_id}") + print(f" Detected: {OSREL.get('PRETTY', 'Unknown')}") + print(f" Supported versions: {', '.join(supported_versions)}") + print(f"\n This version may work but is not officially tested.") + + response = input("\n Continue anyway? [y/N]: ").strip().lower() + if response not in ['y', 'yes']: + print("\n Installation cancelled.\n") + sys.exit(1) + print() + else: + print(f"✓ Supported OS detected: {OSREL.get('PRETTY', 'Unknown')}\n") + + def comment_x_served_by_step(path="/etc/angie/conf.d/include/proxy.conf"): p = Path(path) if not p.exists(): @@ -1686,7 +1747,8 @@ def main(): update_motd(args.motd == "yes", info, ipv6_enabled=args.enable_ipv6) print_summary(info, args.enable_ipv6, args.dark_mode, update_mode=True) return - + + validate_supported_os() 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",