Last active
October 7, 2019 18:55
-
-
Save btarg/13a8757831173ca8ee601fc7b50e100d to your computer and use it in GitHub Desktop.
Google Cloud Minecraft server setup
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
########################################################### | |
# Google Cloud Minecraft server setup | |
# Written by iCrazyBlaze | |
# Last edited 07/10/2019 | |
########################################################### | |
path=/home/minecraft/server | |
backuphours=6 | |
echo "" | |
echo "Please enter your bucket ID: " | |
read bucket | |
echo "" | |
sudo mkdir -p $path | |
# Mount for Google Cloud | |
sudo mkfs.ext4 -F -E lazy_itable_init=0,lazy_journal_init=0,discard /dev/disk/by-id/google-minecraft-disk | |
sudo mount -o discard,defaults /dev/disk/by-id/google-minecraft-disk $path | |
# Install JRE and download server jar | |
sudo apt-get update | |
sudo apt-get install -y default-jre-headless | |
cd $path | |
# Download and run update script - this will allow us to run in the future | |
wget -O updatemcjar.sh https://gist.githubusercontent.com/iCrazyBlaze/188f134e084eacb6740401cc7b10a38a/raw/f04b562c367632822d710661b47cab901d2a2938/updater.sh | |
# Create blank server.jar file to trick updater | |
echo >> $path/server.jar | |
sudo chmod 755 $path/updatemcjar.sh | |
./updatemcjar.sh -y --jar-path $path/server.jar | |
# Remove backup of empty file | |
sudo rm server.jar.bak | |
# First run to generate the text file | |
java -Xmx1024M -Xms1024M -jar server.jar nogui | |
# Agree to the EULA | |
sudo sed -i 's/false/true/g' eula.txt | |
wget https://gist.githubusercontent.com/iCrazyBlaze/ced4323c2768a7e8de11bb1ada013e0f/raw/3787b77884345914ff8c87be7311a71e675730ed/backup.sh | |
wget https://gist.githubusercontent.com/iCrazyBlaze/82f8fdf0e215a6c779750df4bce63a2d/raw/0f2212bf9c9feeb541184f46135a6e4d00b3bce0/launch.sh | |
# Add bucket id from variable | |
sudo sed -i "s/<bucket>/$bucket/g" backup.sh | |
# Set executable | |
sudo chmod 755 $path/backup.sh | |
sudo chmod 755 $path/launch.sh | |
#write out current crontab | |
crontab -l > minecron | |
#echo new cron into cron file | |
echo "0 */$backuphours * * * $path/backup.sh" >> minecron | |
#install new cron file | |
crontab minecron | |
rm minecron | |
# Run in screen terminal | |
apt-get install -y screen | |
sudo ./launch.sh |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment