1 |
On 03/06/11 09:31, Florian Philipp wrote: |
2 |
> Am 05.03.2011 23:47, schrieb Jake Moe: |
3 |
>> I'm currently trying to write a simple initscript to run |
4 |
>> minecraft-server on one of my boxes. I've looked at the ebuild provided |
5 |
>> via java-overlay, but it turns out it uses baselayout 2, and I'm not |
6 |
>> ready to go down that upgrade path on this particular box just yet. |
7 |
>> |
8 |
>> So far, I've managed to get a simple start() function written, which |
9 |
>> kinda-sorta "works"; it will start the server, but there are two problems: |
10 |
>> |
11 |
>> 1) The "server" was written to stay interactive on a console, so you can |
12 |
>> manage it from there. As such, the process never exits, so the |
13 |
>> initscript gets stuck on "starting" |
14 |
>> 2) There is nowhere in the server config file to specify where it writes |
15 |
>> it's data files. So when I run this from my initscript, it seems to |
16 |
>> default to the root directory, and I can't figure out how to tell it to |
17 |
>> use something else as a working directory. |
18 |
>> |
19 |
>> So far, I've got this: |
20 |
>> |
21 |
>> depend() { |
22 |
>> need bootmisc localmount net |
23 |
>> } |
24 |
>> |
25 |
>> start() { |
26 |
>> einfo "Starting Minecraft Server" |
27 |
>> cd /usr/local/games/minecraft-server |
28 |
>> start-stop-daemon --start --make-pidfile --pidfile |
29 |
>> /var/run/minecraft-server.pid \ |
30 |
>> --exec /usr/bin/java -- -Xmx1024M -Xms1024M -jar |
31 |
>> /usr/local/games/minecraft-server/minecraft_server.jar nogui |
32 |
>> eend $? |
33 |
>> } |
34 |
>> |
35 |
>> Do any of the experts here know a way out of my dilemma? |
36 |
>> |
37 |
>> Jake Moe |
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 |
49 |
> |
50 |
I've tried "--background", but then it just fails. Adding "--verbose" |
51 |
as well gives the following: |
52 |
|
53 |
jmoe@aus8617 /etc/init.d $ sudo /etc/init.d/minecraft-server start |
54 |
* Starting Minecraft Server |
55 |
Starting /usr/bin/java... |
56 |
Detaching to start /usr/bin/java...done. [ !! ] |
57 |
|
58 |
Not the most helpful of messages. |
59 |
|
60 |
For the second, of what is "--chdir" an argument? If I read the man |
61 |
page for start-stop-daemon, it had "--chroot" and "--chuid", but no |
62 |
"--chdir". I assume that "--chuid" can be used for changing the |
63 |
user:group of the resulting process, but did you mean chroot instead of |
64 |
chdir, or does that go with another command? |
65 |
|
66 |
Also, when I say "the root directory", I don't mean root's home |
67 |
directory (/root), I mean the root (/) directory. So I wind up with |
68 |
config files in the root of my filesystem. Not good. |
69 |
|
70 |
Jake Moe |