Minecraft-server on FreeBSD

What is the best way for me to run minecraft-server on FreeBSD? The current version of minecraft-server is outdated by several versions, current version in ports is 1.4.7 while the current version they run is 1.6.4. For that reason I cannot run the version in ports.

I want to run minecraft-server in a shell as a normal user. I have read topics like this one (minecraftforum.net) for FreeBSD 8.1 and this one (blogspot). But I am not sure how and what is the best way to run minecraft-server on FreeBSD.

My test shell script looks like this. I haven't installed java yet since I am not sure what I should be running.

Code:
PATH="/usr/local/bin:/usr/bin:/bin"
#!/usr/local/bin/bash

java -jar minecraft_server.1.6.4.jar

This is my current version of FreeBSD 9.1.

Code:
uname -a
FreeBSD saturn.net303.net 9.1-RELEASE FreeBSD 9.1-RELEASE #0 r243825: Tue Dec  4 09:23:10 UTC 2012     root@farrell.cse.buffalo.edu:/usr/obj/usr/src/sys/GENERIC  amd64

Thanks for the help. :)
 
I use the current minecraft_server.jar from minecraft.net. I created a minecraft user account and use this init script:

Code:
#!/bin/sh
#
# PROVIDE: minecraft
# REQUIRE: LOGIN DAEMON NETWORKING mountcritlocal
# KEYWORD: shutdown
#
# Add the following lines to /etc/rc.conf.local to enable the minecraft server:
#
# minecraft_enable="YES"
# minecraft_user="<run server as this user>"
# minecraft_chdir="<run server in this directory>"
# minecraft_path="<path to minecraft_server.jar>"
# minecraft_flags="<set as needed>"
#
# For default setup, create a user named 'minecraft', set its home directory
# to /srv/minecraft, and place minecraft_server.jar into /srv/minecraft
#
# See minecraft_server.jar for flags

. /etc/rc.subr

name=minecraft
rcvar=`set_rcvar`

load_rc_config ${name}

command=/usr/local/bin/screen
pidfile=/var/run/minecraft.pid

start_cmd="${name}_start"
stop_cmd="${name}_stop"
status_cmd="${name}_status"

: ${minecraft_enable="NO"}
: ${minecraft_session="minecraft-session"}
: ${minecraft_user="minecraft"}
: ${minecraft_chdir="/srv/minecraft"}
: ${minecraft_path="/srv/minecraft/minecraft_server.jar"}
: ${minecraft_flags=""}
: ${minecraft_args="/usr/local/bin/java -Xms256M -Xmx512M \
                    -jar ${minecraft_path} ${minecraft_flags} nogui"}

minecraft_start() {
    unset "${rc_arg}_cmd"
    minecraft_flags="-d -m -S ${minecraft_session} ${minecraft_args}"
    if minecraft_running; then
	echo "minecraft already running?"
    else
	run_rc_command "start"
    fi
}

minecraft_stop() {
    local cmd
    cmd="${command} -p 0 -S ${minecraft_session} -X eval 'stuff stop\015'"
    if minecraft_running; then
	echo "Stopping minecraft."
	su -m ${minecraft_user} -c "${cmd}"
    fi
}

minecraft_status() {
    if minecraft_running; then
	echo "minecraft is running."
    else
	echo "minecraft is not running."
    fi
}

minecraft_running() {
    local check ses
    ses="${minecraft_session}"
    check=`su -m ${minecraft_user} -c "${command} -list" | grep ${ses}`
    if [ "$check" ]; then
	return 0
    else
	return 1
    fi
}

run_rc_command "$1"
 
I run my server with java/openjdk7. To allow closing the terminal without interrupting the game, I use sysutils/screen to wrap the running process. I can attach for maintenance (or naughty commands) from time to time.

And my code to start the server is as follows. I made an infinite loop in case the Minecraft instance crashes spontaneously.
Code:
#!/bin/sh

while true
do
  java -Djava.net.preferIPv4Stack=true -Xmx2048M -Xms2048M -jar minecraft.jar
  echo Press Ctrl-C now if you mean to stop instead of restart
  sleep 5
done
 
Thanks for this. Sorry for the long replay. I had other things to do.

Now I am moving my minecraft server to FreeBSD server computer. I will create this as suggested with the run command and I hope it works from the start.

I am currently installing openjdk-7.25.15_2.
 
Minecraft server now runs perfectly and without any issues from the looks of it. Thanks for the help!
 
My friend wants me to set-up an minecraft-tekkit server on the computer for me to try out.

I guess I can use the same script as I used to run normal minecraft for this. With just minor edit to it.

Thanks for the help.
 
I installed Minecraft server 1.8.2 using pkg install. Then using a script pretty much identical to the one above I created my rc.conf and rc.d files. But for the life of me I can't get it to work. If I launch the .jar directly it does indeed run, and uses the default mcserver account that got created during the pkg install. But I can't get the Minecraft client on the iPods to connect to it. If I try to have it start using the rc.conf and rc.d files it does not start. I have read various pages on the web to no avail. Seems everyone has their own way, and most are based on downloading the .jar file, versus doing a pkg install.

Is there a great web page that someone can refer me to, that is based on the pkg install for FreeBSD 10.1-RELEASE, and has examples of the rc.d and rc.conf files they use, and references any settings I need to use. Thanks in advance everyone.
 
I'm not sure about iPods, but I know Minecraft Pocket Edition for Android cannot connect to full blown servers running on Windows or BSD, etc... No work around for it that I know of.

I installed Minecraft on FreeBSD from an earlier port before the (new?) maintainer started updating it for 1.8. I think at some point the new one cleaned it up a lot and I think I remember a post saying something to the effect of leaving it up to the users to decide how they want to launch it at boot. The port I used installed some stuff (tmux at least, maybe more) to make it work at boot and I messed around with it and replaced the minecraft-server.jar file with the one straight from Minecraft's site. It mostly works. It takes a long time to start at boot and I think it's not quite right.

I have a line in /etc/rc.conf:
Code:
minecraft_enable="YES"
then in /usr/local/etc/rc.d, I have a minecraft file that I've attached. I commented out most of it because it didn't seem to work anyway. I think the .lck file it keeps looking for doesn't get created by newer versions of Minecraft. For the start line, I modified the command to increase the memory and to look for the minecraft-server file in a folder on my ZFS partition instead of the default location.

Fortunately for me, the tmux stuff was already there, because I wouldn't have figured that out. Like I said, I'm going to try reinstalling it from ports and see what's been updated. It looks like the maintainer has updated it a few times in the last 30 or 60 days, so that seems like a good thing.
 

Attachments

Righto thanks. I will dive into this soon. If I figure anything out I will post here. Thanks again.
Hi ,
Did you managed to get minecraft working on FreeBSD 10 in the end?
If you have, is there any chance you could share how you did it?

Thank you
 
I got minecraft-client and minecraft-server working this weekend. At least I think I did, and the only reason I said that because it was a lot easier that I expected, and it seems to be working fine.

I install minecraft-server on one machine using ports. I selected daemon mode and simply had to put minecraft_enable="YES" in /etc/rc.conf. Note the port installation instructions about the EULA file you have to modify.

For the minecraft-client I had to do this, which you are told to do on the first run. Set the profile java executable to "/usr/local/share/minecraft-client/minecraft-runtime". Just launch minecraft cient and look inside "edit profile". After you verify server is running, launch the client, do a "add server" and use the IP address of the server. I started with a 'fresh new' world, and will see where that leads us. I haven't tried to get any other devices, like iPods versions, working yet. I've read you can't, and it'll be a while before I try.

I also had to install audio/openal-soft to get sound working.

That was pretty much it.
 
I know the thread is a little dated, but there's another suggestion I'd like to add to the mix, one which hasn't been mentioned so far. Also because the initial question was about running Minecraft in general.

If you want to go for the vanilla Minecraft server then the games/minecraft-server can provided a good solution. However... The main problem with this environment is that it isn't really optimized for server usage. Another possible con (but that's opinion based) is that vanilla Minecraft also won't be able to utilize any plugins.

So a very good alternative which I'd like to mention is the Spigot project. It's basically an open source, and fully optimized, version of Minecraft. I won't go into too much detail but a few specific advantages over vanilla Minecraft:
  • Performance optimization; provides better TPS in general.
  • Built in anti x-ray checks (to catch cheaters).
  • Extensive customization features (maps in item frames, entity activation, tab command completion, crop grow rates, chunk loading, redstone ticks, etc.).
It's my experience that if you're having issues with the resource requirements of vanilla Minecraft then Spigot is most likely a perfect alternative. So far it runs a lot faster on my hardware.

Installing it is easy, but you do need to make sure that you got java/openjdk8 installed as well as devel/git. All it takes is downloading BuildTools.jar and starting it. It'll invoke git to download any further requirements and compile Spigot from source. After completing the build you'll end up with the Spigot jarfile which you can then place into your Minecraft folder and run it as you'd normally would. It'll use some of the default files (permissions.yml, commands.yml) but also use custom ones such as spigot.yml for example.

Of course the downside is that you won't be able to use the ports collection to keep it up to date, but considering the major advantages which Spigot provides over vanilla I'd say its most definitely worth the effort. Maybe something to take into consideration as well?
 
Update: When installing games/minecraft-server port version 1.10.2 with ports-mgmt/synth the build will fail. Apparently the build now requires an interactive dialog for the license part. If however you add
Code:
LICENSES_ACCEPTED=minecraft
to /usr/ports/games/minecraft-server/Makefile it will then build fine. So your makefile license section will look like this, with the first 4 lines as original (meaning included in the port as is).

Code:
LICENSE=        minecraft
LICENSE_NAME=   Minecraft End User License Agreement
LICENSE_TEXT=   The license can be viewed at: https://account.mojang.com/documents/minecraft_eula
LICENSE_PERMS=  no-dist-mirror no-dist-sell no-pkg-mirror no-pkg-sell
LICENSES_ACCEPTED=minecraft
 
Hi! I'm testing FBSD MC Spigot server on mihion.dk:29999. My real srv runs on ubunt, but I think I'll be moving over! ;)
 
Back
Top