Skip to content
View in the app

A better way to browse. Learn more.

Unraid

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

need help with minecraft package/unmenu buttons

Featured Replies

Hi

 

I've been looking at how I can get a minecraft server running on my unRAID box, and I've had some success in getting it running through telnet/command lines, but would like some guidance on how to have it run without a telnet window active (eg using screen?) and putting buttons on unmenu/user scripts to let me easily start/stop the server.

 

Ultimate aim would be to have a package to install everything - I think a few people might find it useful?

 

anyway, please be gentle, complete noob here.

 

All I did so far, is to copy my existing minecraft server folder structure across to sde2, which is a non-array drive (2nd partition of my cache drive). Then I installed the Java runtime package from unmenu.

 

I then put this grand script on the flash drive :)

cd /mnt/disk/sde2/MCunraid
/usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar

 

if I run that, it seems to launch the server just fine. This happens to be the crafbukkit plugin version, the normal minecraft version would be a tiny bit different (java -Xmx1024M -Xms1024M -jar minecraft_server.jar nogui). I need to run from the folder where the .jar is located because its expecting other folders/files to be relative to where it is.

 

So.. next steps that I need help with

 

1) how do I get that script running without telnetting in? Can I have it as a button on user scripts?

2) how do I stop it? when i run it from the command line, I can enter text to issue server commands. 'stop' shuts the server down neatly and exits. Would I need to use the screen command to keep the gui alive to issue 'stop' or other commands to it

 

those are the main short term things I need help with.

 

then ultimately..

3) how do you start putting together a package that would install all this? I think for the most basic package, you would need to install

- java runtime (package already available)

- screen maybe (depending if its needed for stopping the server)

- minecraft server jar  - current URL is http://www.minecraft.net/download/minecraft_server.jar?v=1306505397337 but I don't know if thats always the same.

 

 

1) how do I get that script running without telnetting in? Can I have it as a button on user scripts?

You could try calling the script to start minecraft from the go script and place a "&" at the end. So it would look something like this in your script:

cd /mnt/disk/sde2/MCunraid
/usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar &

 

2) how do I stop it? when i run it from the command line, I can enter text to issue server commands. 'stop' shuts the server down neatly and exits. Would I need to use the screen command to keep the gui alive to issue 'stop' or other commands to it

I am not exactly sure on this one, but if I had to guess and you used the above way to start minecraft you would probably need to kill the process id of the running mincraft instance.

 

 

3) how do you start putting together a package that would install all this? I think for the most basic package, you would need to install

It is not overly hard, and all you really need to do is start looking through some of the .conf files in the packages folder that already exist.  Airvideo uses Java so it might be a good on to look at.  The PACKAGE_INSTALLATION lines are essentially what you need to be concerned the most with, and are basically just shell commands.

 

 

- java runtime (package already available)

- screen maybe (depending if its needed for stopping the server)

- minecraft server jar  - current URL is http://www.minecraft.net/download/minecraft_server.jar?v=1306505397337 but I don't know if thats always the same.

You might not need screen.  Look at the airvideo package and if you have any questions post back here.

  • Author

ok, so I think it might make sense to initialise the server using a screen, as it has a textual front end. Plus then I can either connect in and issue commands (messages/kick users etc) but also stop it.

 

would this work:

 

screen -d -m -S minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar

 

(do I need to put quotes around the command line part?)

 

I *think* that should start a screen up in the background, and issue the command line to launch the server..

 

I'll look at wrapping it all in buttons later. I think I can't put it in the startup area as my sde2 (non array disk) doesn't automount.

  • Author

moving on :)

 

my first bash at start/stop scripts. try not to laugh.. Aim is to launch the server in the background via screen, so I can if necessary telnet in and adjust things. Stop should shut it down. need to type in 'stop' which will save and shutdown the server) and I think will end the screen session?

 

Need TERM=xterm for screen to work when telnetting in from my mac. Don't know if I need it when running from a button inside unmenu? Do I need to put quotes around the command I'm trying to execute?

 

 

start:

#define USER_SCRIPT_LABEL Start Minecraft server
#define USER_SCRIPT_DESCR Start minecraft server. needs sde2 mounted first
TERM=xterm
cd /mnt/disk/sde2/MCunraid
screen -d -m -S minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar

 

 

stop:

#define USER_SCRIPT_LABEL Stop Minecraft server
#define USER_SCRIPT_DESCR Stop minecraft server. Do this before shutting down unRAID
TERM=xterm
screen -S minecraft -X stuff 'stop'`echo -ne '\015'`

  • Author

hmm.

 

So using this user script, launched from unmenu, I can get the minecraft server started and connected up with my clients etc

 

#define USER_SCRIPT_LABEL Start Minecraft server

#define USER_SCRIPT_DESCR Start minecraft server. needs sde2 mounted first

TERM=xterm

cd /mnt/disk/sde2/MCunraid

screen -d -m -S minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar

 

 

 

But my stop script

#define USER_SCRIPT_LABEL Stop Minecraft server
#define USER_SCRIPT_DESCR Stop minecraft server. Do this before shutting down unRAID
TERM=xterm
screen -S minecraft -p -X stuff 'stop
'

 

returns 'Must be connected to a terminal' in unmenu, and doesn't stop the server.

If I try to telnet in and reconnect to the screen, its not showing any active screens.

 

any ideas? And what's happened to my screen? would it have been shut down? did it even get created properly? if so, why is the server still running?

hmm.

 

So using this user script, launched from unmenu, I can get the minecraft server started and connected up with my clients etc

 

#define USER_SCRIPT_LABEL Start Minecraft server

#define USER_SCRIPT_DESCR Start minecraft server. needs sde2 mounted first

TERM=xterm

cd /mnt/disk/sde2/MCunraid

screen -d -m -S minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar

 

 

you are using the wrong tool for the task.

screen give you virtual screen buffers, you don't need for the java process.

Simply use "nohup" something like this:

 

nohup minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar  2>&1 1>/tmp/logfile &

But my stop script

#define USER_SCRIPT_LABEL Stop Minecraft server
#define USER_SCRIPT_DESCR Stop minecraft server. Do this before shutting down unRAID
TERM=xterm
screen -S minecraft -p -X stuff 'stop
'

 

returns 'Must be connected to a terminal' in unmenu, and doesn't stop the server.

If I try to telnet in and reconnect to the screen, its not showing any active screens.

 

any ideas? And what's happened to my screen? would it have been shut down? if so, why is the server still running?

The stop script can then just be

minecraft -p -X stuff 'stop' 2>&1 1>/tmp/stop_log

  • Author

wow. I'd looked at nohup but thought it was just for 'fire and forget' commands, and this server has a command line style gui that I needed to enter commands into.

 

so the stop script would issue the equivalent of me typing in 'stop' and pressing enter (which shuts it down)? Fantastic

 

 

If I needed to enter any server commands (I don't usually, so this is a side issue), would that be doable from eg the command line using a similar structure to the 'stop' line, replacing stop with whatever command I'd like to issue to the server?

wow. I'd looked at nohup but thought it was just for 'fire and forget' commands, and this server has a command line style gui that I needed to enter commands into.

 

so the stop script would issue the equivalent of me typing in 'stop' and pressing enter (which shuts it down)? Fantastic

 

 

If I needed to enter any server commands (I don't usually, so this is a side issue), would that be doable from eg the command line using a similar structure to the 'stop' line, replacing stop with whatever command I'd like to issue to the server?

I don't use the program.  It it prompts you for a confirmation to stop, then that is slightly different  If it has a way to daemonize itself, it should have a command line to stop itself too.  All I'm trying to point out is "screen" is the wrong tool for you to use.

 

Joe L.

  • Author

Doesn't prompt you, it just sits there waiting for input. If you type 'stop' and press enter it will shut the server down and end the process without further input. That is what I need - I don't want to kill the process, I need the server to shut down gracefully.

 

Appreciate the assistance :)

 

 

edit: that didn't work. Says 'nohup: cannot run command `minecraft': No such file or directory'. In my previous script, 'minecraft' was just the name I was trying to assign to the screen. The command was the java part, running craftbukkit.jar

 

 

  • Author

checking out my screen route again. If I type

screen -d -m -S minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar

directly into a telnet session, it creates a detached screen called 'minecraft', and the server starts ok

 

if I try

screen -r minecraft -X stuff "stop $(echo -ne '\r')"

it gets ignored

 

but if I do 'screen -r' I get switched to the screen, and then I can manually type in stop, and the server stops.

 

So I think this is the correct approach, I'm just wondering why

1) putting that top screen command in the script doesn't seem to set up a screen, whereas doing it directly on the command line does work

2) why is the screen stuff line not working, but I can attach manually to it and shut it down?

 

 

  • Author

ok, seems to be a problem with screen. It ignores commands if the screen has never been attached. So I launch it detached, it won't listen to -X or stuff. Can I attach/detach within the start/stop script to get around this?

edit: that didn't work. Says 'nohup: cannot run command `minecraft': No such file or directory'. In my previous script, 'minecraft' was just the name I was trying to assign to the screen. The command was the java part, running craftbukkit.jar

So then the command becomes:

nohup /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar  2>&1 1>/tmp/logfile &

I think perhaps the screen approach is a red herring...

 

There is also a startup/shutdown script here that might just suit your needs.

  • Author

ok, but how can I pass it the stop command? Didn't think you could pass it an input once its running?

 

edit: That nohup didn't work. I got '[1] 26443' and then it said 'ignoring input and redirecting stderr to stdout' but it didn't release the command line back to me. Pressing enter gave a  '[1]+ stopped' followed by the command I'd entered.

 

I couldn't connect to the server either while the command was running or after it had stopped.

 

I'm still confused why you think screen is a red herring. I'm coming in cold but it sounds like exactly what is needed to run an interactive process without needing to remain logged into a telnet session? Someone also suggested 'tmux' but that doesn't seem to be in unRAID?

  • Author

I finally found a way to actually pass commands to a detached screen. but there is a difference depending how I run it.

 

Start server:

Works from command line

cd /mnt/disk/sde2/MCunraid
screen -d -m -S minecraft /usr/lib/java/bin/java -Xincgc -Xmx1024M -jar CraftBukkit.jar

 

doesn't work from script

#define USER_SCRIPT_LABEL Start Minecraft server via screen
#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

 

 

Stop server:

works from command line

screen -S minecraft -p 0 -X stuff "stop$(printf \\r)"

 

doesn't work from script

#define USER_SCRIPT_LABEL Stop Minecraft server via screen
#define USER_SCRIPT_DESCR Stop minecraft server. Do this before shutting down unRAID
screen -S minecraft -p 0 -X stuff "stop$(printf \\r)"

 

I'm logging in via telnet as root, but the scripts have full permissions anyway, as do the .jar I'm running. Java itself has permissions of rwxr_xr_x. What user does unmenu execute scripts as?

 

 

edit: trying to run the script directly from the command line I'm getting an error

 

no such file or directory: line 3: cd: /mnt/disk/sde2/MCunraid

 

but if I type 'cd /mnt/disk/sde2/MCunraid' it works fine and changes me into the correct directory. Does unmenu have a log file it writes errors to when running user scripts?

 

 

 

Take a look through the startup/shutdown script I pointed you to and see how it's done in that. No point in re-inventing the wheel, after all ;)

  • Author

no, I understand. But thats a huge script that is overwhelming. All I want to do is start and stop it. I can manage that with command line commands, but those same lines don't work from a script?

  • Author

finally! got it working. I *think* it was just a dirty script. Cleaned it up with a proper text editor but made no changes to it, and it works. So now I have a button in unmenu to start the server, and another to cleanly shut it down.

 

 

finally! got it working. I *think* it was just a dirty script. Cleaned it up with a proper text editor but made no changes to it, and it works. So now I have a button in unmenu to start the server, and another to cleanly shut it down.

 

 

 

If you can work it into an unMenu package that creates the buttons, like the Airvideo and Transmission packages do, then it can be included into the unMenu distribution.

  • Author

would I need that to download the minecraft files too, and include the JRE, or can I put JRE as a dependency for people to install separately?

 

might have a look, but a bit ovewhelming. will take another look at the airvideo and transmission packages.

 

someone on another site posted a link to their script, which lets you set the path for the installation etc, and looks much more flexible - checking status and letting you backup. I think thats a good place to start - then on installation of the package let you edit the config to say where you want it installed, download minecraft to that location.

 

link to script - http://paste.boredomsoft.org/main.php/view/62107887

Start the server
sudo /etc/init.d/minecraftd start
#Stop the server
sudo /etc/init.d/minecraftd stop
#Create a backup of the world
sudo /etc/init.d/minecraftd backup
#Restart the server
sudo /etc/init.d/minecraftd restart
#Use the console "say" command (Quotes are important)
sudo /etc/init.d/minecraftd mcsay "Hello, world!"
#Issue direct commands to the server console (i.e. "ban bobby21")
sudo /etc/init.d/minecraftd mcdo "ban bobby21"
#Query the server status (running/not running)
sudo /etc/init.d/minecraftd status

 

link to post - http://unix.stackexchange.com/questions/13953/sending-text-input-to-a-detached-screen/13974#13974

 

 

would I need that to download the minecraft files too,

Yes, just like the airvideo package has the line to download the Airvideo.jar file.

 

and include the JRE, or can I put JRE as a dependency for people to install separately?

The airvideo install does not install its own java.  It does have a test in the package install to see if java is installed and if not the install exits with a message about needing to install java before the install of airvideo can proceed.

 

might have a look, but a bit ovewhelming. will take another look at the airvideo and transmission packages.

There are simpler packages to look at but the one I mention above are very "comprehensive" packages that do a lot of things.  If you need some help understanding what a package is doing just let us know.

  • 2 years later...

Did you ever get anywhere on this?

I have no input on running the minecraft jar directly on unraid, but I am very successfully running virtualbox in unraid, and have MineOS Turnkey running as one of my guests.

I got the .jar to run directly without any issues. It was quite easy actually. I didn't have any luck with the script posted above though. Even after fixing the paths to my files, it fails to start. I will tinker with it in the coming days, but for now I can run it manually.

Archived

This topic is now archived and is closed to further replies.

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.