mirror of
https://github.com/itzg/docker-minecraft-server.git
synced 2024-06-07 19:40:43 +00:00
Download spiget resources to tempdir under plugins (#1486)
This commit is contained in:
parent
bca7b79f77
commit
b4ca00bd3b
@ -47,7 +47,7 @@ getResourceFromSpiget() {
|
|||||||
mkdir -p /data/plugins
|
mkdir -p /data/plugins
|
||||||
|
|
||||||
versionfile="/data/plugins/.${resource}-version.json"
|
versionfile="/data/plugins/.${resource}-version.json"
|
||||||
versionfileNew="/tmp/.${resource}-version.json"
|
versionfileNew="${versionfile}.tmp"
|
||||||
|
|
||||||
if [ -f "$versionfile" ]; then
|
if [ -f "$versionfile" ]; then
|
||||||
if [[ -n $(find "$versionfile" -mmin +${SPIGET_DOWNLOAD_TOLERANCE}) ]]; then
|
if [[ -n $(find "$versionfile" -mmin +${SPIGET_DOWNLOAD_TOLERANCE}) ]]; then
|
||||||
@ -87,8 +87,10 @@ getResourceFromSpiget() {
|
|||||||
downloadResourceFromSpiget() {
|
downloadResourceFromSpiget() {
|
||||||
resource=${1?}
|
resource=${1?}
|
||||||
|
|
||||||
|
tempDir="/data/plugins/tmp-${resource}"
|
||||||
|
mkdir -p $tempDir
|
||||||
resourceUrl="https://api.spiget.org/v2/resources/${resource}"
|
resourceUrl="https://api.spiget.org/v2/resources/${resource}"
|
||||||
if ! outfile=$(get_silent --output-filename -o /tmp "${acceptArgs[@]}" "${resourceUrl}/download"); then
|
if ! outfile=$(get_silent --output-filename -o $tempDir "${acceptArgs[@]}" "${resourceUrl}/download"); then
|
||||||
log "ERROR: failed to download resource '${resource}' from ${resourceUrl}/download"
|
log "ERROR: failed to download resource '${resource}' from ${resourceUrl}/download"
|
||||||
if externalUrl=$(get --json-path '$.file.externalUrl' "${resourceUrl}"); then
|
if externalUrl=$(get --json-path '$.file.externalUrl' "${resourceUrl}"); then
|
||||||
log " Visit $externalUrl to pre-download the resource"
|
log " Visit $externalUrl to pre-download the resource"
|
||||||
@ -107,11 +109,11 @@ downloadResourceFromSpiget() {
|
|||||||
elif containsJars "${outfile}"; then
|
elif containsJars "${outfile}"; then
|
||||||
log "Extracting contents of resource ${resource} into plugins"
|
log "Extracting contents of resource ${resource} into plugins"
|
||||||
extract "$outfile" /data/plugins
|
extract "$outfile" /data/plugins
|
||||||
rm "$outfile"
|
|
||||||
else
|
else
|
||||||
log "ERROR: file for resource ${resource} has an unexpected file type: ${fileType}"
|
log "ERROR: file for resource ${resource} has an unexpected file type: ${fileType}"
|
||||||
exit 2
|
exit 2
|
||||||
fi
|
fi
|
||||||
|
rm -rf "$tempDir"
|
||||||
}
|
}
|
||||||
|
|
||||||
if [[ ${SPIGET_RESOURCES} ]]; then
|
if [[ ${SPIGET_RESOURCES} ]]; then
|
||||||
|
Loading…
Reference in New Issue
Block a user