Minecraft Wiki
Advertisement

Done with my first draft... Comments, modification, experiences, help?

Cheers

Sakamura 20:50, 26 February 2011 (UTC)

Just got done setting up this up on a Mini Server running OS X Server and here's a few things I learned.

I think it might help make this guide a little clearer to just remove all the references to the "easy ways" to do things.

My Java process does stop properly but the tail hangs around (naturally) so my script kills the tail command after Java exits.

I want to be able to run a second server in the future so my scripts include a "server name". I don't know if anyone else wants to do that, but here's my setup in case:

#!/bin/bash

server_name=server_ross

cd /Users/_minecraft/${server_name}

trap '{ echo "$(date) Killing Minecraft, ${server_name}."; ./stop.sh; exit 0; }' TERM INT

ipconfig waitall

echo "$(date) Starting Minecraft, ${server_name}."

./start.sh &
wait

echo "$(date) Minecraft, ${server_name} done."

Here's my start.sh. The pipe file has been renamed to include the server name so stop.sh can find the tail process to kill it. The -Dnet.minecraft.server=${server_name} is also just there for finding the right server when stopping.

#!/bin/bash

server_name=server_ross

cd /Users/_minecraft/${server_name}

rm command_pipe.${server_name}
touch command_pipe.${server_name}
tail -f command_pipe.${server_name} | java -Xmx1G -Xms1G -Dnet.minecraft.server=${server_name} -jar minecraft_server.jar nogui


Finally, my stop.sh script which also kills the tail process.

#!/bin/bash

server_name=server_ross

cd /Users/_minecraft/${server_name}

echo stop >> command_pipe.${server_name}

while ps -u _minecraft | grep "net.minecraft.server=${server_name}" | grep -qv grep
do
	sleep 1
done

# We have to kill the tail that was feeding Java.
tailpid=$(ps -u _minecraft | grep command_pipe.${server_name} | grep -v grep | cut -c 6-11)
kill $tailpid

Rossiam 01:00, 3 May 2011 (UTC)

Advertisement