Am 05.03.2011 23:47, schrieb Jake Moe:
> I'm currently trying to write a simple initscript to run
> minecraft-server on one of my boxes.  I've looked at the ebuild provided
> via java-overlay, but it turns out it uses baselayout 2, and I'm not
> ready to go down that upgrade path on this particular box just yet.
> 
> So far, I've managed to get a simple start() function written, which
> kinda-sorta "works"; it will start the server, but there are two problems:
> 
> 1) The "server" was written to stay interactive on a console, so you can
> manage it from there.  As such, the process never exits, so the
> initscript gets stuck on "starting"
> 2) There is nowhere in the server config file to specify where it writes
> it's data files.  So when I run this from my initscript, it seems to
> default to the root directory, and I can't figure out how to tell it to
> use something else as a working directory.
> 
> So far, I've got this:
> 
> depend() {
>   need bootmisc localmount net
> }
> 
> start() {
>   einfo "Starting Minecraft Server"
>   cd /usr/local/games/minecraft-server
>   start-stop-daemon --start --make-pidfile --pidfile
> /var/run/minecraft-server.pid \
>                     --exec /usr/bin/java -- -Xmx1024M -Xms1024M -jar
> /usr/local/games/minecraft-server/minecraft_server.jar nogui
>   eend $?
> }
> 
> Do any of the experts here know a way out of my dilemma?
> 
> Jake Moe
> 


You already know start-stop-daemon, good. Parameter --background will
force the program to detach. That solves your first problem.

--chdir should solve your second problem. You should also consider
--user and --group to drop root privileges. It also sets $HOME in case
the server does not write to the working directory but the home directory.

Hope this helps,
Florian Philipp

Attachment: signature.asc
Description: OpenPGP digital signature

Reply via email to