0 Replies - 480 Views - Last Post: 07 May 2011 - 03:48 PM

#1 Tom9729  Icon User is offline

  • Segmentation fault
  • member icon

Reputation: 180
  • View blog
  • Posts: 2,641
  • Joined: 30-December 07

Minecraft FreeBSD Server Script

Posted 07 May 2011 - 03:48 PM

FreeBSD 8 init script that I wrote for my Minecraft server. There are a couple of similar scripts for Linux floating around out there. This is the first time I have really worked with BSD or rsync so be nice. :)

Version 2011.05.04

You need to install bash, opejdk7, screen, curl, and rsync.

Save the script as /etc/rc.d/minecraft and set permissions chown root:wheel /etc/rc.d/minecraft and chmod 555 /etc/rc.d/minecraft.

Create a minecraft user adduser minecraft preferably without password login enabled. This user is just to run the server and own the directories it needs.

Create a folder for the server mkdir -p /var/minecraft/backup, and download/save the minecraft_server.jar to /var/minecraft/minecraft_server.jar.

Should probably also do chown -R minecraft:wheel /var/minecraft.

The script has several commands:
start/stop/reload - start, stop, or restart the server
backup - backup the world to /var/minecraft/backup/world-{timestamp}
update - download a new server jar and restart the server if necessary
echo {something} - equivalent to doing say {something} in the server console

Add minecraft_enable="YES" to /etc/rc.conf to autostart.

Setup crontabs to automate updates/backups. My crontab looks like this
## Backup every hour
0 * * * * /etc/rc.d/minecraft backup
## Get minecraftian time and echo to server every minute
* * * * * /etc/rc.d/minecraft echo `/usr/local/bin/mcgate time`

Also optional is my mcgate script that figures out the "minecraft" time from the world. Depends on this python module.

mcgate time will return something like 6:09am, which is the time of the minecraft world (not the same as real time).

Please report any problems, and remember to backup your data before trying this script because it is experimental and it's not my fault if you break something. :)

Is This A Good Question/Topic? 2
  • +

Page 1 of 1