I want to start my minecraft server when someone tries to connect to it on port 25565. I have a plugin for the server which shuts it down after x amount of minutes without players online. With a shell script I created a loop that starts the server when it shuts down:
#!/bin/bash while true do # run server java -Xms2048M -Xmx2048M -Djava.awt.headless=true -jar "craftbukkit.jar" # server shut down # run MCSignOnDoor java -jar MCSignOnDoor.jar --sentrymode -m "Gone Fishin' Back in Five Minutes!" # McSignOnDoor shut down # stop loop if error code is not 12 # so only restart the server when the program ended because of a packet if [ "$?" -ne "12" ]; then break fi done
McSignOnDoor was a java program someone made that emulates an active server, and exits as soon as someone pings it on port 25565 with exit code 12. Sadly, this does not work since a protocol update, so I'm looking for an alternative.
Is there a way to wait until it receives a packet on port 25565 (or any other port) and then continue the script?