ok, need some linux help please.
I'm trying to run a minecraft server on unRAID (slackware based). I want to create some scripts that I can execute as buttons on 'unMenu' so I can easily start and shutdown the server.
The server will run in the shell, and then sit there waiting for input. To stop it, I need to type 'stop' and press enter, and then it'll save the world and gracefully exit, and I'm back in the shell. That all works if I run it via telnetting into the NAS box, but I want to run it directly on the box.
I was thinking that 'screen' might be the best option, as the server takes over the shell waiting for different server commands. So launch it in a detached screen and then when I want to stop it, just send 'stop' and a carriage return to that screen. But it isn't working. It launches the server ok, but it doesn't seem to be in a screen, so I can't get in and stop it neatly.
someone else suggested just using 'nohup' but AFAIK (very noob here), that doesn't let me send input to it after its started - its 'fire and forget'.
this is what I previously had as a first attempt:
Code:
#define USER_SCRIPT_LABEL Start Minecraft server
#define USER_SCRIPT_DESCR Start minecraft server. needs sde2 mounted first
cd /mnt/disk/sde2/MCunraid
screen -d -m -S minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar
MCunraid is the folder where I have the Craftbukkit.jar and all the world files etc. I *think* that screen command should create a detached screen instance called 'minecraft' and launch the server from within it. The server does launch, but I can't access the screen and no screens are listed. if I type that screen line in directly, the screen does setup detached correctly
The alternative someone suggested was
Code:
nohup minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar 2>&1 1>/tmp/logfile &
but I think nohup doesn't let me send a 'stop' command to it? And anyway that 'minecraft' doesn't look like it belongs.
for stopping the server, I need to 'type' in STOP and then press enter. My approach was
Code:
screen -r minecraft -X stuff "stop $(echo -ne '\r')"
to send to screen 'minecraft' the text s-t-o-p and a carriage return. But that doesn't work, even if I type it directly onto the command line. But if I 'screen -r' I can get to the screen with the server running, then type 'stop' and it shuts down properly.
the alternative suggested was
Code:
minecraft -p -X stuff 'stop' 2>&1 1>/tmp/stop_log
which I don't understand because I thought you couldn't send inputs to a nohup'd process?
any guidance here? The server runs well if I telnet in and do it manually, just need to run it without being connected from my remote computer.