| - Taken from Linode, credit goes to Jed Smith.
Set up a Minecraft SMP server on Ubuntu. Automatically installs Java, creates a minecraft user, pulls in the latest minecraft_server.jar, and writes a script to automatically start the server. Read the comments in the script for more information.
Following script works on the following OS: Ubuntu 10.04 LTS|Ubuntu 10.10|Ubuntu 9.10
You can download it here or see below for the details.
#!/bin/bash # # Minecraft Stackscript # Prepares the system, installs Java, installs Minecraft, and starts the server. # By Jed Smith # # # # # # done
# install java apt-get -y install sun-java6-jre screen
# add the minecraft user adduser -system -group -disabled-login -disabled-password -home /opt/minecraft minecraft cd /opt/minecraft
# find where to get minecraft (please don't change this, Notch) version=`wget -q -O- http://www.minecraft.net/download.jsp | grep "download/minecraft_server.jar" | cut -d'"‘ -f 2` wget -O minecraft_server.jar "http://www.minecraft.net/$version"
# convert configuration variables [ "$MCONLINE" == "yes" ] && MCONLINE=true [ "$MCONLINE" == "true" ] || MCONLINE=false [ "$MCMONSTERS" == "yes" ] && MCMONSTERS=true [ "$MCMONSTERS" == "true" ] || MCMONSTERS=false
# write the configuration cat >server.properties < # Minecraft server properties # Created by Minecraft StackScript `date` online-mode=$MCONLINE monsters=$MCMONSTERS server-ip= server-port=25565 max-players=$MCMAXPLAYERS level-name=$MCLEVELNAME EOF
# initial op user echo $MCOPNAME >ops.txt touch banned-players.txt touch banned-ips.txt
# write the run script cat >run.sh < #!/bin/sh java -Xmx1024M -Xms1024M -jar /opt/minecraft/minecraft_server.jar nogui EOF
# clean up chown minecraft:minecraft * chmod a+x run.sh
# do a motd too cat >/etc/motd.tail <
This server has been deployed from Jed Smith's Minecraft StackScript. To start Minecraft, run the following as root:
# su - minecraft -s /opt/minecraft/run.sh
screen is also installed if you prefer to run Minecraft in a screen. It is a very bad idea to run the Minecraft server as root; although there are no currently-known vulnerabilities, you're better off insulating your server.
All files related to the server are in /opt/minecraft. EOF
|