Dxcufgb's Workshop

Automatic Updates

WIPWork in progress: may be very buggy and can change a lot between versions.

Off by default. When turned on, the machine checks once a day whether this repository has a newer release and, if so, installs it.

  • Linux: a systemd timer (foundry-release-proxy-update.timer, daily with up to 6 hours of random delay) runs foundry-release-proxy-update.service as root.
  • Windows: the scheduled task FoundryReleaseProxy-Update runs as SYSTEM daily at 03:00 plus up to 6 hours of random delay.

Turning them on and off

Linux Windows (elevated PowerShell)
turn on while installing sudo ./install.sh --auto-update (or answer y to the prompt) .\scripts\install-service.ps1 -AutoUpdate
turn on later sudo ./install.sh --enable-auto-update .\scripts\install-service.ps1 -EnableAutoUpdate
turn off sudo ./install.sh --disable-auto-update .\scripts\install-service.ps1 -DisableAutoUpdate
check only (exit 0 = current, 10 = update available) sudo ./install.sh --check-update .\scripts\install-service.ps1 -Check
update now sudo ./install.sh --update-now, or Check for update → Update now on the admin page .\scripts\install-service.ps1 -UpdateNow, or the admin page
log journalctl -u foundry-release-proxy-update C:\ProgramData\FoundryReleaseProxy\auto-update.log

On Linux sudo ./scripts/install-service.sh takes the same options (--check is the older name of --check-update). The commands also work from the installed copy (/opt/foundry-release-proxy/scripts/install-service.sh, C:\Program Files\FoundryReleaseProxy\scripts\install-service.ps1).

Re-running the installer keeps the choice (auto-update.conf next to env; --no-auto-update / -NoAutoUpdate turn it off while re-installing).

--check-update and --update-now work whether or not the daily updates are on. While another update run holds the lock, --check-update (-Check) exits 75 ("could not check") instead of 0 or 10.

The e-mails an update run sends are described in Notifications and Daily Check.

What an update does

src/updater.js asks https://api.github.com/repos/dxcufgb/FoundryVTT-Private-Github-proxy/releases/latest (drafts and pre-releases never count) and compares the tag with the installed package.json version by semantic versioning; only a strictly newer release is installed (the version of an installed copy is the one stamped into its package.json when the release was built).

It downloads SHA256SUMS.txt and the archive (foundry-release-proxy-<version>-linux.tar.gz on Linux, -windows.zip on Windows) through the API asset URL, follows GitHub's redirect to the pre-signed download without the token, refuses anything that is not HTTPS or larger than 20 MB, and checks the archive's SHA-256.

The script then unpacks it into a fresh temporary folder (refusing paths outside the archive's top folder), copies the current code to /opt/foundry-release-proxy.prev (C:\Program Files\FoundryReleaseProxy.prev), runs the new release's installer in upgrade mode (non-interactive) and checks that the proxy is running again. If anything fails, the previous version is reinstalled from that copy and checked to be running again; if that also fails, the log says ROLLBACK FAILED with the command to reinstall it by hand from the .prev folder.

A lock (flock / a named mutex) stops two runs at once. config.json, env and their owners, modes and ACLs are never changed by an update.

Token for the updater (optional)

This repository is public, so the updater needs no GitHub token: without one it reads the releases anonymously, which GitHub allows 60 API requests an hour per IP address (an update run needs at most three). A token is still used when there is one, and existing installs keep working as before:

  • by default the updater reads the proxy's own GITHUB_TOKEN from env. It does not need access to this repository: when GitHub refuses it for this repository (no access, expired, revoked), the update log says GitHub refused the updater's token (HTTP ...); continuing without it and the run goes on without a token;
  • or give the updater a token of its own (any fine-grained token; public repositories are readable with every token): answer y to the optional question, or set UPDATER_GITHUB_TOKEN in the environment before running the installer (on Linux pass it through sudo with sudo --preserve-env=UPDATER_GITHUB_TOKEN ...; never put it on the command line). It is stored in /etc/foundry-release-proxy/updater-token (root, 600) or C:\ProgramData\FoundryReleaseProxy\updater-token (Administrators and SYSTEM only). Turning updates off or uninstalling deletes it.

If the one-line Linux installer was given a token, it exports it as INSTALL_GITHUB_TOKEN; when you turn automatic updates on, install.sh stores it as the updater token (asking first when interactive; with --yes it does so without asking). An updater token that is already configured is kept. Nothing about the updater's token ever stops an install or --yes to ask.

A token is only sent to api.github.com and is never logged. When GitHub's rate limit is reached (HTTP 403 or 429), the update log says GitHub's API rate limit is reached with the time it resets, and the next daily run tries again.

Limits

The checksum guards against corrupted or truncated downloads; it comes from the same release, so it does not protect against someone who can publish releases in this repository. Updates restart the proxy (a few seconds of downtime). The previous version stays in the .prev folder until the next update.

Update proxy now

Check for update in the admin page's footer asks GitHub for the latest release; when it is newer, a dialog asks whether to update the proxy now. Update now runs the same update as the daily automatic update, at once, whether or not automatic updates are turned on: same optional token (TOKEN_FILE in auto-update.conf, else the proxy's env), same checks (only a strictly newer, checksum-verified release; rollback on failure), same log and the same notification e-mail.

The proxy restarts when a newer version was installed, which ends every admin login; the page waits for that and asks you to log in again. An update can be requested again after two minutes.

The proxy itself never runs the update (it has no rights to): it only asks the root (Linux) or SYSTEM (Windows) updater the installer set up to run now, and nothing it sends can change what that updater does.

  • Linux: the installer creates /etc/foundry-release-proxy/update-request (empty, owned by foundry-proxy, mode 600) and the systemd units foundry-release-proxy-update-now.path and -update-now.service. The proxy writes the time into that file; the path unit sees the change and starts the update service as root. Root never reads the file. Log: journalctl -u foundry-release-proxy-update-now.
  • Windows: the installer registers the task FoundryReleaseProxy-UpdateNow (SYSTEM, no schedule) and lets LOCAL SERVICE run it, but not change it; the proxy starts it with schtasks /Run. Log: auto-update.log, as above.

Installs from before this version get the button when the installer runs again (an automatic update does it); until then the page says it is not set up. UPDATE_REQUEST_FILE (Linux) and UPDATE_TASK (Windows) in env override the file and task names for a hand-made setup.

This page mirrors the Private GitHub Proxy wiki on GitHub.