mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2026-08-26 00:43:19 +00:00
Updated GH_TOKEN usage (#1688)
This commit is contained in:
@@ -25,20 +25,7 @@ fi
|
|||||||
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
|
# If packwiz url passed, bootstrap packwiz and update mods before other modpack processing
|
||||||
if [[ "${PACKWIZ_URL:-}" ]]; then
|
if [[ "${PACKWIZ_URL:-}" ]]; then
|
||||||
# Ensure we have the latest packwiz bootstrap installer
|
# Ensure we have the latest packwiz bootstrap installer
|
||||||
if [[ "${GH_TOKEN:-}" ]]; then
|
latestPackwiz=$(get_from_gh "https://api.github.com/repos/packwiz/packwiz-installer-bootstrap/releases/latest")
|
||||||
# User has provided a Personal Access Token to mitigate rate-limiting issues
|
|
||||||
oAuthScopes="undefined"
|
|
||||||
oAuthScopes=$(curl -sv -H "Authorization: token $GH_TOKEN" https://api.github.com/users/codertocat -I | grep x-oauth-scopes)
|
|
||||||
if [[ ! "$oAuthScopes" =~ ^x-oauth-scopes:[[:space:]]*$ ]]; then
|
|
||||||
# Don't use what you don't have to...
|
|
||||||
log "ERROR: GH_TOKEN has permissions it doesn't need. Recreate or update this personal access token and disable ALL scopes."
|
|
||||||
exit 1
|
|
||||||
else
|
|
||||||
latestPackwiz=$(curl -fsSL -H "Authorization: token $GH_TOKEN" https://api.github.com/repos/packwiz/packwiz-installer-bootstrap/releases/latest)
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
latestPackwiz=$(curl -fsSL https://api.github.com/repos/packwiz/packwiz-installer-bootstrap/releases/latest)
|
|
||||||
fi
|
|
||||||
if [[ -z "${latestPackwiz}" ]]; then
|
if [[ -z "${latestPackwiz}" ]]; then
|
||||||
log "WARNING: Could not retrieve Packwiz bootstrap installer release information"
|
log "WARNING: Could not retrieve Packwiz bootstrap installer release information"
|
||||||
else
|
else
|
||||||
@@ -59,11 +46,11 @@ if [[ "${PACKWIZ_URL:-}" ]]; then
|
|||||||
#if bootstrap download fails, download installer manually - then run without updating
|
#if bootstrap download fails, download installer manually - then run without updating
|
||||||
returnVal=$?
|
returnVal=$?
|
||||||
if [[ $returnVal ]]; then
|
if [[ $returnVal ]]; then
|
||||||
latestPackwizInstaller=$(curl -fsSL https://api.github.com/repos/packwiz/packwiz-installer/releases/latest)
|
latestPackwizInstaller=$(get_from_gh "https://api.github.com/repos/packwiz/packwiz-installer/releases/latest")
|
||||||
latestPackwizInstallerVer=$(echo "${latestPackwizInstaller}" | jq --raw-output '.tag_name')
|
latestPackwizInstallerVer=$(echo "${latestPackwizInstaller}" | jq --raw-output '.tag_name')
|
||||||
latestPackwizInstallerUrl=$(echo "${latestPackwizInstaller}" | jq --raw-output '.assets[] | select(.name | match("packwiz-installer.jar")) | .url')
|
latestPackwizInstallerUrl=$(echo "${latestPackwizInstaller}" | jq --raw-output '.assets[] | select(.name | match("packwiz-installer.jar")) | .url')
|
||||||
log "Packwiz couldn't update - Downloading Packwiz Installer ${latestPackwizInstallerVer}"
|
log "Packwiz couldn't update - Downloading Packwiz Installer ${latestPackwizInstallerVer}"
|
||||||
curl -H "Accept:application/octet-stream" -o "packwiz-installer.jar" -fsSL "${latestPackwizInstallerUrl}"
|
get_from_gh "${latestPackwizInstallerUrl}" -H "Accept:application/octet-stream" -o "packwiz-installer.jar"
|
||||||
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -bootstrap-no-update -s server "${PACKWIZ_URL}"
|
java -jar "${PACKWIZ_BOOTSTRAP_JAR}" -g -bootstrap-no-update -s server "${PACKWIZ_URL}"
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|||||||
+19
-1
@@ -1,5 +1,23 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
function get_from_gh() {
|
||||||
|
if [[ "${GH_TOKEN:-}" ]]; then
|
||||||
|
# User has provided a Personal Access Token to mitigate rate-limiting issues
|
||||||
|
if [[ -z "${oAuthScopes}" ]]; then
|
||||||
|
oAuthScopes=$(curl -s -H "Authorization: token $GH_TOKEN" https://api.github.com/users/codertocat -I | grep x-oauth-scopes)
|
||||||
|
fi
|
||||||
|
if [[ ! "$oAuthScopes" =~ ^x-oauth-scopes:[[:space:]]*$ ]]; then
|
||||||
|
# Don't use what you don't have to...
|
||||||
|
log "ERROR: GH_TOKEN has permissions it doesn't need. Recreate or update this personal access token and disable ALL scopes."
|
||||||
|
exit 1
|
||||||
|
else
|
||||||
|
echo $(curl -fsSL -H "Authorization: token $GH_TOKEN" ${@:2} $1)
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo $(curl -fsSL ${@:2} $1)
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
function join_by() {
|
function join_by() {
|
||||||
local d=$1
|
local d=$1
|
||||||
shift
|
shift
|
||||||
@@ -291,7 +309,7 @@ function checkSum() {
|
|||||||
|
|
||||||
# Get distro
|
# Get distro
|
||||||
distro=$(getDistro)
|
distro=$(getDistro)
|
||||||
|
|
||||||
if [ "${distro}" == "debian" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then
|
if [ "${distro}" == "debian" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then
|
||||||
return 0
|
return 0
|
||||||
elif [ "${distro}" == "ubuntu" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then
|
elif [ "${distro}" == "ubuntu" ] && sha1sum -c "${sum_file}" --status 2> /dev/null; then
|
||||||
|
|||||||
Reference in New Issue
Block a user