server/scripts/_sources/_fill.sh
amy a961fb61a5
Updater refactors; 1.21.8 (#173)
* refactor: pass proper user agent to fetched urls

Paper's Fill v3 will require this

* refactor: make sure our exit codes don't overlap with curl

curl uses 100, too

* refactor: use paper's fill v3

* refactor: update server to 1.21.8

no protocol/server changes :P
2025-07-24 22:38:02 +03:00

20 lines
No EOL
612 B
Bash

#!/bin/sh
# Fill (v3) is Paper's API for downloading builds
# See https://docs.papermc.io/misc/downloads-api
_fetch_latest_file() {
builds_url="$1/builds/latest"
debug "fetch: $builds_url"
DEFAULT_DOWNLOAD_URL="$(fetch -so- "$builds_url" \
| jq --raw-output --exit-status '.downloads["server:default"].url')"
}
_download_type_fill() {
read_args endpoint project version
require_args endpoint project version
version_url="${arg_endpoint:?}/v3/projects/${arg_project:?}/versions/${arg_version:?}"
_fetch_latest_file "$version_url"
download "$DEFAULT_DOWNLOAD_URL" "$1"
}