Gentoo Archives: gentoo-user

From: Florian Philipp <lists@×××××××××××.net>
To: gentoo-user@l.g.o
Subject: Re: [gentoo-user] Writing Gentoo initscript question
Date: Sat, 05 Mar 2011 23:33:45
Message-Id: 4D72C7B8.3070908@binarywings.net
In Reply to: [gentoo-user] Writing Gentoo initscript question by Jake Moe
1 Am 05.03.2011 23:47, schrieb Jake Moe:
2 > I'm currently trying to write a simple initscript to run
3 > minecraft-server on one of my boxes. I've looked at the ebuild provided
4 > via java-overlay, but it turns out it uses baselayout 2, and I'm not
5 > ready to go down that upgrade path on this particular box just yet.
6 >
7 > So far, I've managed to get a simple start() function written, which
8 > kinda-sorta "works"; it will start the server, but there are two problems:
9 >
10 > 1) The "server" was written to stay interactive on a console, so you can
11 > manage it from there. As such, the process never exits, so the
12 > initscript gets stuck on "starting"
13 > 2) There is nowhere in the server config file to specify where it writes
14 > it's data files. So when I run this from my initscript, it seems to
15 > default to the root directory, and I can't figure out how to tell it to
16 > use something else as a working directory.
17 >
18 > So far, I've got this:
19 >
20 > depend() {
21 > need bootmisc localmount net
22 > }
23 >
24 > start() {
25 > einfo "Starting Minecraft Server"
26 > cd /usr/local/games/minecraft-server
27 > start-stop-daemon --start --make-pidfile --pidfile
28 > /var/run/minecraft-server.pid \
29 > --exec /usr/bin/java -- -Xmx1024M -Xms1024M -jar
30 > /usr/local/games/minecraft-server/minecraft_server.jar nogui
31 > eend $?
32 > }
33 >
34 > Do any of the experts here know a way out of my dilemma?
35 >
36 > Jake Moe
37 >
38
39
40 You already know start-stop-daemon, good. Parameter --background will
41 force the program to detach. That solves your first problem.
42
43 --chdir should solve your second problem. You should also consider
44 --user and --group to drop root privileges. It also sets $HOME in case
45 the server does not write to the working directory but the home directory.
46
47 Hope this helps,
48 Florian Philipp

Attachments

File name MIME type
signature.asc application/pgp-signature

Replies

Subject Author
Re: [gentoo-user] Writing Gentoo initscript question Jake Moe <jakesaddress@×××××.com>