Minecraft Wiki
Advertisement

Page creation

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)

On-demand start & stop daemon

Hello,

I think you did a fantastic job here, considering that I have now my own minecraft server properly configured to start along with my Mac while I am not really accustomed to the Mac command line (I must admit I'm mostly a PC user).

I still have a few questions about this tutorial (please pardon my noobfullness) :

  • Is it possible to adapt your daemon to launch on demand, i.e. when the first client asks for server connection (by listening to port 25565 connection attempts maybe ?)
  • ... and to stop when the last client disconnects, i.e. when nobody's using the server
  • and (maybe) also to launch updates automatically (I've seen some linux scripts available online1 that can do that among other thinks, but I have no idea how to adapt them).

Also, I had to use portmap2 to force port forwarding on my router (did not work without it). Is there a way to include start portmap with the server daemon as well ?

Finally, I understand the security concern, but is there an easy way to administer files in the _minecraft folder. Files are accessible of course, as you can modify them through terminal using the sudo nano command (sudo nano server.properties to edit the server.properties, for instance). But, at this point, modifying those files remains complicated, especially if a lot of them are involved. Concerning this point, is it acceptable to allow a user to access minecraft server files ? And then how should you do it without compromising security ?

Thank you again for sharing your Minecraft Server Startup Daemon with the community.


1, like here : planetminecraft.com/blog/automatically-stop-a-server-when-nobodys-playing

2, www.codingmonkeys.de/portmap/

posted by --Oulipion (talk) 15:45, 7 October 2013 (UTC)
and modified --Oulipion (talk) 21:20, 8 October 2013 (UTC)

Advertisement