TheRemote/RaspberryPiMinecraft

start.sh: line 197: "path":"/v2/projects/paper/versions/"} + 0:

Opened this issue · 3 comments

Hi,

When starting server i have an error:
Updating to most recent paperclip version ... start.sh: line 197: "path":"/v2/projects/paper/versions/"} + 0: syntax error: operand expected (error token is ""path":"/v2/projects/paper/versions/"} + 0") Starting Minecraft server. To view window type screen -r minecraft. To minimize the window and let the server run in the background, press Ctrl+A then Ctrl+D

OS:
Ubuntu server x64 22.05.04 (testd on 24.05.4 same error but server not starting)

Pi version:
PI4 8GB

I got the same problem too! After changing the version in SetupMinecraft.sh to 1.21.7 and setting AllowLocalCopy="1", the replaced start.sh doesn't have the correct version.

When I run this command:

cat ~/minecraft/start.sh | grep Version

I got the following output:

    BuildJSON=$(curl --no-progress-meter -H "Accept-Encoding: identity" -H "Accept-Language: en" -L -A "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4.212 Safari/537.36" https://api.papermc.io/v2/projects/paper/versions/$Version)
screen -dmS minecraft /home/jimmy/minecraft/jre/bin/java -DPaper.IgnoreJavaVersion=true -jar -Xms400M -Xmx3319M /home/jimmy/minecraft/paperclip.jar

Seems like $Version is not properly set?

I fixed this by adding the line

Version="verselect"

In the very beginning of the start.sh script. This works because perviously "Version" is not defined at all, so SetupMinecraft.sh does nothing to update the version.

However, SetupMinecraft.sh always pulls start.sh from this git repo everytime when it is executed. To fix this, I renamed my modified start.sh file to start-template.sh, and modified the SetupMinecraft.sh so that it copies my start-template.sh, and generate a new start.sh accordingly.

Here's the part that I changed in SetupMinecraft.sh:

# Updates all scripts
Update_Scripts() {
    # Remove existing scripts
    cd "$DirName/minecraft"
    rm -f start.sh stop.sh restart.sh fixpermissions.sh update.sh

    # Download start.sh from repository (COMMENT THIS OUT!) 
    # Print_Style "Grabbing start.sh from repository..." "$YELLOW"
    # curl -H "Accept-Encoding: identity" -L -o start.sh https://raw.githubusercontent.com/TheRemote/RaspberryPiMinecraft/master/start.sh
    # chmod +x start.sh

    # Copy start-template.sh to start.sh (FIX)  
    cp "$DirName/minecraft/start-template.sh" "$DirName/minecraft/start.sh"
    chmod +x "$DirName/minecraft/start.sh"

    # Same command afterwards (unchanged) 
    sed -i "s:dirname:$DirName:g" start.sh
    sed -i "s:memselect:$MemSelected:g" start.sh
    sed -i "s:verselect:$Version:g" start.sh
    sed -i "s<pathvariable<$PATH<g" start.sh
}

I hope this change can be done and pushed to the official repo so it "just works" for everyone!

Hey everyone,

I just love this little script and have been using it for my kid's little home server for years now...

I had a quick look at the new V3 paper io API and replaced the update code from start.sh with this example code from https://docs.papermc.io/misc/downloads-api (just changed server.jar to paperclip.jar ;-))

# Update paperclip.jar
echo "Updating to most recent paperclip version ..."

PROJECT="paper"
MINECRAFT_VERSION="1.21.7"
USER_AGENT="cool-project/1.0.0 (contact@me.com)"

# First check if the version exists
VERSION_CHECK=$(curl -s -H "User-Agent: $USER_AGENT" https://fill.papermc.io/v3/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds)

# Check if the API returned an error
if echo "$VERSION_CHECK" | jq -e '.ok == false' > /dev/null 2>&1; then
  ERROR_MSG=$(echo "$VERSION_CHECK" | jq -r '.message // "Unknown error"')
  echo "Error: $ERROR_MSG"
  exit 1
fi

# Get the download URL directly, or null if no stable build exists
PAPERMC_URL=$(curl -s -H "User-Agent: $USER_AGENT" https://fill.papermc.io/v3/projects/${PROJECT}/versions/${MINECRAFT_VERSION}/builds | \
  jq -r 'first(.[] | select(.channel == "STABLE") | .downloads."server:default".url) // "null"')

if [ "$PAPERMC_URL" != "null" ]; then
  # Download the latest Paper version
  curl -o paperclip.jar $PAPERMC_URL
  echo "Download completed"
else
  echo "No stable build for version $MINECRAFT_VERSION found :("
fi

works like a charm...

best regards
Anthrax