Skip to content

Instantly share code, notes, and snippets.

@cilliemalan
Last active May 30, 2016 07:45
Show Gist options
  • Save cilliemalan/1b68d9d39b03ec0955ce314f5ae5a4d2 to your computer and use it in GitHub Desktop.
Save cilliemalan/1b68d9d39b03ec0955ce314f5ae5a4d2 to your computer and use it in GitHub Desktop.
MSM init script for amazon linux
#!/bin/bash
# My script for provisioning a minecraft server
#
# wget -O - https://git.io/vrQol | bash
sudo yum -y update
# Download the default config file, update the user ID, and also add the -server switch which the MSM guys omitted\
sudo wget http://git.io/6eiCSg -O /etc/msm.conf
# Fix the username
sudo sed -i 's/USERNAME=".*"/USERNAME="ec2-user"/' /etc/msm.conf
#add the "-server" parm
sudo sed -i 's/DEFAULT_INVOCATION="java/DEFAULT_INVOCATION="java -server/' /etc/msm.conf
#reduce default RAM amount
#sudo sed -i 's/DEFAULT_RAM=".*"/DEFAULT_RAM="768"/' /etc/msm.conf
# Set up the install directory and the RAM disk:
sudo mkdir /opt/msm
sudo chown ec2-user /opt/msm
sudo chmod -R 775 /opt/msm
sudo mkdir /dev/shm/msm
sudo chown ec2-user /dev/shm/msm
sudo chmod -R 775 /dev/shm/msm
# Get the main executable.
sudo wget http://git.io/J1GAxA -O /etc/init.d/msm
# Make it executable and set it up as a new service type
sudo chmod 755 /etc/init.d/msm
sudo chkconfig --add msm
sudo chkconfig msm on
# Add a symlink in the path:
sudo ln -s /etc/init.d/msm /usr/local/bin/msm
# Put that path in the sudoers file so it's picked up, and then get MSM to update itself
sudo sed -i 's/secure_path = .*/&:\/usr\/local\/bin/' /etc/sudoers
# sudo vim /etc/sudoers
# Make this edit:
#Defaults secure_path = /sbin:/bin:/usr/sbin:/usr/bin:/usr/local/bin
# Now we can update:
sudo msm update --noinput
# Set up cron:
sudo wget http://git.io/pczolg -O /etc/cron.d/msm
sudo service crond reload
# Now into some MSM stuff. MSM is cool because server data (an MSM server) is kept separate from Minecraft versions (an MSM jargroup). So let's create the jargroup which is responsible for fetching Minecraft jars (update the version number to be current!):
sudo msm jargroup create minecraft https://s3.amazonaws.com/Minecraft.Download/versions/1.9.4/minecraft_server.1.9.4.jar
# Now create a new server, and hook it up to the jargroup we just made:
sudo msm server create minecraftchills
sudo msm minecraftchills jar minecraft
# To avoid an annoying warning on startup, we set this properties file. It doesn't appear to do anything exciting:
#sudo sed -i 's/msm-version=minecraft\/.*/msm-version=minecraft\/1.3.0/' /opt/msm/servers/minecraftchills/server.properties
# vim /opt/msm/servers/minecraftchills/server.properties
# make this edit:
# msm-version=minecraft/1.3.0
# now start the server:
sudo msm minecraftchills start
sudo msm stable stop
#EULA
sed -i 's/eula=false/eula=true/' /opt/msm/servers/minecraftchills/eula.txt
sudo msm minecraftchills start
sudo msm minecraftchills stop
# On first startup, the world directory is created with all your data in it. For best results, MSM recommends you move this as follows:
pushd /opt/msm/servers/minecraftchills
mv world worldstorage
sudo msm minecraftchills worlds load
popd
# We're nearly there. The final hiccup: recent versions of Minecraft have a eula.txt that needs updated. So for each server, we need to:
sudo msm minecraftchills start
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment