HelperScripts-for-ProxmoxVE/misc
CanbiZ (MickLesk) 9a82ec48b2
tools.func: prevent script crash when entering GitHub token after rate limit (#13638)
* fix(tools): prevent script crash when entering GitHub token after rate limit

fetch_and_deploy_gh_release set attempt=0 after accepting a token, then
immediately ran ((0++)) which evaluates to 0 (falsy) causing exit code 1
and killing the script under set -e.

Fix: set attempt=1 and continue to restart the retry loop cleanly,
giving the full max_retries budget with the new token.

Also fix fetch_and_deploy_codeberg_release: replace ((attempt++)) with
attempt=\ to avoid the same zero-evaluation crash on
the first connection timeout (attempt starts at 0 in that loop).

Fixes #13635

* feat(tools): add var_github_token support with token validation

- Add var_github_token to all VAR_WHITELIST arrays in build.func so the
  token can be set via default.vars, app.vars, or environment variable
- Map var_github_token -> GITHUB_TOKEN in default_var_settings() (env
  variable takes precedence over the var file value)
- Add commented var_github_token example to the default.vars template
- Add validate_github_token() to tools.func:
    * Calls GET /user to verify the token is accepted
    * Reports expiry date from x-oauth-expiry header (fine-grained PATs)
    * Warns when classic PAT is missing public_repo scope
    * Returns distinct exit codes: 0=valid, 1=invalid/expired, 2=no scope, 3=error
- Update prompt_for_github_token():
    * Non-interactive path now picks up var_github_token automatically
    * Interactive path also picks up var_github_token without prompting
    * Validates token immediately after entry; loops until valid or Ctrl+C
2026-04-10 11:28:52 +02:00
..
images remove old files and assets (#9991) 2025-12-15 17:37:26 +01:00
alpine-install.func core: APT/APK Mirror Fallback for CDN Failures (#13316) 2026-03-26 16:53:04 +01:00
alpine-tools.func core/tools: replace generic return 1 exit_codes with more specific exit_codes (#13311) 2026-03-26 16:07:38 +01:00
api.func Make shell command substitutions safe with || true (#13279) 2026-03-25 13:06:21 +01:00
build.func tools.func: prevent script crash when entering GitHub token after rate limit (#13638) 2026-04-10 11:28:52 +02:00
cloud-init.func core/tools: replace generic return 1 exit_codes with more specific exit_codes (#13311) 2026-03-26 16:07:38 +01:00
core.func core: silent() function - use return instead of exit to allow || true error handling (#13529) 2026-04-05 21:02:56 +02:00
error_handler.func core: silent() function - use return instead of exit to allow || true error handling (#13529) 2026-04-05 21:02:56 +02:00
install.func APT Proxy: Support full URLs (http/https with custom ports) (#13474) 2026-04-03 21:17:07 +02:00
tools.func tools.func: prevent script crash when entering GitHub token after rate limit (#13638) 2026-04-10 11:28:52 +02:00
vm-core.func Add donate & script page badges to descriptions (#13596) 2026-04-08 21:40:52 +02:00