Use proper new api and locations, redo how i handle a lot of the jq work
All checks were successful
ci/woodpecker/push/build Pipeline was successful

This commit is contained in:
Ryan Voots 2024-07-31 09:26:51 -04:00
parent 2f149e5c49
commit ecca5c2df9
2 changed files with 16 additions and 6 deletions

View file

@ -23,6 +23,7 @@ RUN apt-get update \
jq \ jq \
&& apt-get clean && apt-get clean
RUN deluser ubuntu
RUN addgroup --gid 1000 velocity \ RUN addgroup --gid 1000 velocity \
&& adduser --system --shell /bin/false --uid 1000 --ingroup velocity --home /data velocity && adduser --system --shell /bin/false --uid 1000 --ingroup velocity --home /data velocity
RUN mkdir /velocity && chown 1000:1000 /velocity RUN mkdir /velocity && chown 1000:1000 /velocity

View file

@ -1,14 +1,23 @@
#!/bin/bash #!/bin/bash
curl 'https://papermc.io/api/v2/projects/velocity/version_group/3.3.0/builds' -H 'User-Agent: docker-build simcop2387@simcop2387.info' | jq -r '.builds[-1]' | tee /tmp/velocity.json set -euxo pipefail
wget -O /tmp/velocity.jar $(jq -r '"https://papermc.io/api/v2/projects/velocity/versions/"+(.version|tostring)+"/builds/"+(.build|tostring)+"/downloads/"+ (.downloads.application.name|tostring)' < /tmp/velocity.json)
CALCULATED=$(sha256sum /tmp/velocity.jar | cut -d' ' -f1)
PROVIDED=$(jq -r '.downloads.application.sha256' < /tmp/velocity.json)
if [[ $CALCULATED == $PROVIDED ]]; then JSON=$(curl 'https://api.papermc.io/v2/projects/velocity/versions/3.3.0-SNAPSHOT/builds' -H 'User-Agent: docker-build simcop2387@simcop2387.info')
BUILD=$(echo $JSON | jq -r '.builds[-1]')
VERSION=$(echo $JSON | jq -r '.version')
BUILD_ID=$(echo $BUILD | jq -r '.build')
FILENAME=$(echo $BUILD | jq -r '.downloads.application.name')
CHECKSUM=$(echo $BUILD | jq -r '.downloads.application.sha256')
wget -O /tmp/velocity.jar "https://api.papermc.io/v2/projects/velocity/versions/${VERSION}/builds/${BUILD_ID}/downloads/${FILENAME}"
CALCULATED=$(sha256sum /tmp/velocity.jar | cut -d' ' -f1)
if [[ $CALCULATED == $CHECKSUM ]]; then
echo download successful, moving to final location echo download successful, moving to final location
mv /tmp/velocity.jar /velocity/ mv /tmp/velocity.jar /velocity/
else else
echo FAILED SHA256 SUM CHECK: $CALCULATED != echo FAILED SHA256 SUM CHECK: $CALCULATED != $CHECKSUM
exit 127 exit 127
fi fi