allow install from fork

This commit is contained in:
Mateusz Gruszczyński
2025-11-19 15:19:00 +01:00
parent 964578760b
commit a45ceaf953

View File

@@ -24,6 +24,14 @@ from contextlib import contextmanager
DEBUG = False
# GitHub Repository Configuration
GITHUB_REPO_OWNER = "NginxProxyManager"
GITHUB_REPO_NAME = "nginx-proxy-manager"
GITHUB_REPO_URL = f"https://github.com/{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}"
# Alternative: Use full URL directly (uncomment to override above)
# GITHUB_REPO_URL = "https://github.com/YourUsername/your-fork-name"
# ========== Configuration ==========
# Minimum required Node.js version for NPM 2.13.0+
MIN_NODEJS_VERSION = 20
@@ -512,16 +520,16 @@ def cleanup_build_artifacts():
p.unlink()
removed_count += 1
if DEBUG:
printf(f" ✓ Removed: {path}")
print(f" ✓ Removed: {path}")
except Exception as e:
if DEBUG:
printf(f" ⚠ Could not remove {path}: {e}")
print(f" ⚠ Could not remove {path}: {e}")
except Exception as e:
if DEBUG:
printf(f" ⚠ Error processing pattern {pattern}: {e}")
print(f" ⚠ Error processing pattern {pattern}: {e}")
if DEBUG and removed_count > 0:
printf(f" Cleaned {removed_count} items from /tmp")
print(f" Cleaned {removed_count} items from /tmp")
with step("Cleaning up Yarn cache directories"):
yarn_cache_dirs = [
@@ -535,7 +543,7 @@ def cleanup_build_artifacts():
if cache_dir.exists():
try:
if DEBUG:
printf(f" Cleaning {cache_dir}...")
print(f" Cleaning {cache_dir}...")
for subdir in ["cache", "global", "install-state.gz"]:
target = cache_dir / subdir
@@ -545,12 +553,12 @@ def cleanup_build_artifacts():
else:
target.unlink()
if DEBUG:
printf(f" ✓ Removed {target}")
print(f" ✓ Removed {target}")
except Exception as e:
if DEBUG:
printf(f" ⚠ Could not clean {cache_dir}: {e}")
print(f" ⚠ Could not clean {cache_dir}: {e}")
def cleanup_swap():
@@ -568,10 +576,13 @@ def cleanup_swap():
print(f"⚠ Could not remove swap: {e}")
def github_latest_release_tag(repo: str, override: str | None) -> str:
def github_latest_release_tag(repo: str, override: str = None) -> str:
if override:
return override.lstrip("v")
if "/" not in repo:
repo = f"{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}"
url = f"https://api.github.com/repos/{repo}/releases/latest"
with step(f"Downloading from GitGub: {repo}"):
with urllib.request.urlopen(url) as r:
data = json.load(r)
@@ -2501,7 +2512,7 @@ def deploy_npm_app_from_git(ref: str) -> str:
version = f"{branch_name}-dev-{timestamp}"
git_ref = branch_name
url = f"https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/{git_ref}"
url = f"https://codeload.github.com/{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}/tar.gz/{git_ref}"
tmp = Path(tempfile.mkdtemp(prefix="npm-angie-"))
src = download_extract_tar_gz(url, tmp)
@@ -2657,9 +2668,8 @@ def deploy_npm_app_from_release(version: str | None) -> str:
"""
# Get latest version if not specified
if not version:
version = github_latest_release_tag(
"NginxProxyManager/nginx-proxy-manager", override=None
)
repo = f"{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}"
version = github_latest_release_tag(repo, override=None)
print(f"✓ Latest stable version: {version}")
if version_parsed < (2, 13, 0):
@@ -2675,7 +2685,7 @@ def deploy_npm_app_from_release(version: str | None) -> str:
return deploy_npm_app_from_git(f"refs/tags/v{version}")
# For versions < 2.13.0, download from release archive
url = f"https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/refs/tags/v{version}"
url = f"https://codeload.github.com/{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}/tar.gz/refs/tags/v{version}"
tmp = Path(tempfile.mkdtemp(prefix="npm-angie-"))
src = download_extract_tar_gz(url, tmp)
@@ -3557,7 +3567,7 @@ def print_summary(
print(f"IPv6: {'ENABLED' if ipv6_enabled else 'DISABLED'}")
print(
"Paths: /opt/npm (app), /data (data), /etc/angie (conf), /opt/certbot (cerbot venv)"
"Paths: /opt/npm (app), /data (npm data), /etc/angie (conf), /opt/certbot (cerbot venv)"
)
print("Services: systemctl status angie.service / npm.service")
@@ -3590,10 +3600,9 @@ def update_only(
if not shutil.which("npm"):
ensure_minimum_nodejs(user_requested_version=node_pkg)
version = github_latest_release_tag(
"NginxProxyManager/nginx-proxy-manager", npm_version_override
)
url = f"https://codeload.github.com/NginxProxyManager/nginx-proxy-manager/tar.gz/refs/tags/v{version}"
repo = f"{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}"
version = github_latest_release_tag(repo, npm_version_override)
url = f"https://codeload.github.com/{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}/tar.gz/refs/tags/v{version}"
tmp = Path(tempfile.mkdtemp(prefix="npm-update-"))
src = download_extract_tar_gz(url, tmp)
@@ -3897,6 +3906,7 @@ def main():
# Display installation banner
print("\n================== NPM + ANGIE installer ==================")
print(f"Repository: https://gitea.linuxiarz.pl/gru/npm-angie-auto-install")
print(f"NPM source repo: {GITHUB_REPO_URL}")
print(f"Script description: Auto-installer with Angie + Node.js auto-setup")
print(f"")
print(f"System Information:")
@@ -3920,6 +3930,10 @@ def main():
installed_from_branch = installer_config.get("installed_from_branch", False)
previous_branch = installer_config.get("branch", "master")
if args.branch:
installed_from_branch = True
previous_branch = args.branch
install_logrotate_for_data_logs()
fix_logrotate_permissions_and_wrapper()
@@ -4042,10 +4056,8 @@ def main():
else:
# Install latest stable
with step("Detecting latest stable release"):
latest_version = github_latest_release_tag(
"NginxProxyManager/nginx-proxy-manager",
override=None
)
repo = f"{GITHUB_REPO_OWNER}/{GITHUB_REPO_NAME}"
latest_version = github_latest_release_tag(repo, override=None)
print(f" Latest stable version: {latest_version}")
version_parsed = parse_version(latest_version)