Skip to content

Conversation

@enoch85
Copy link
Member

@enoch85 enoch85 commented Nov 3, 2025

Solves #2771 by implementing a three-tier fallback system for script downloads:

  1. GitHub (primary) - Fast, always up-to-date
  2. Statically.io CDN (fallback) - Works around rate limits with 1-day cache
  3. Local backup (/var/scripts/vm-repo-backup) - Offline support

Implementation:

  • Clone fresh repo on each update (no stale files)
  • Automatic failover in curl_to_dir() and fetch_lib.sh
  • Menu configurations work offline

Testing:
Comprehensive test suite validates all scenarios including intentional GitHub failure to confirm CDN fallback works automatically.

- Add ensure_local_backup_repo() to clone repo fresh on each update
- Add try_local_backup() to copy files from local backup when GitHub fails
- Modify curl_to_dir() to automatically fall back to local backup
- Update fetch_lib.sh to use local backup when downloading lib.sh fails
- Call ensure_local_backup_repo() in update and install scripts

This solves issue #2771 by providing a local fallback when GitHub
raw.githubusercontent.com hits rate limits. The implementation:
- Prioritizes GitHub (online-first approach)
- Falls back to local clone automatically on download failures
- Clones fresh repo on each update run (no stale files)
- Minimal code changes (~55 lines across 4 files)
- Zero breaking changes - fully backward compatible
@github-tomster
Copy link

will this cover #2511 also?

@enoch85
Copy link
Member Author

enoch85 commented Nov 3, 2025

will this cover #2511 also?

Yeah I think so, if I understand you correctly. The PR aims to keep a copy of all scripts "offline" at all times - mostly as a backup, but could also be used offline.

@github-tomster
Copy link

to be more precise:
there are scenarios with nextcloud vms that are offline ...

Remove network_ok check in menu.sh to allow running offline.
The run_script function will automatically:
1. Try to download from GitHub (if online)
2. Fall back to local backup (if offline or rate limited)

This allows users to run menu.sh for configuration changes
even when completely offline, as requested in issue #2771.
- Add CDN fallback between GitHub and local backup
- Update curl_to_dir() in lib.sh to try cdn.statically.io
- Update fetch_lib.sh with CDN fallback
- Update nextcloud_update.sh initial source with CDN fallback
- Statically.io caches main branch for 1 day (helps with rate limits)
- Fallback order: GitHub → Statically CDN → Local backup
- Source fetch_lib.sh which handles GitHub → CDN → Local backup
- Check for local fetch_lib.sh first before downloading
- Add CDN fallback for fetch_lib.sh itself
- Cleaner code, no duplication of fallback logic
@enoch85 enoch85 marked this pull request as ready for review November 4, 2025 13:59
@enoch85 enoch85 changed the title [WIP] use local Github clone as backup Use local Github clone as backup + fallback to statically.io Nov 4, 2025
@enoch85 enoch85 merged commit 74aa4b2 into main Nov 4, 2025
9 of 10 checks passed
@enoch85 enoch85 deleted the feature/local-repo-backup branch November 4, 2025 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants