Skip to content

Instantly share code, notes, and snippets.

@wgoff194
Last active January 13, 2018 21:40
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wgoff194/93058797a4cdef3ddb29da1e326acce3 to your computer and use it in GitHub Desktop.
Save wgoff194/93058797a4cdef3ddb29da1e326acce3 to your computer and use it in GitHub Desktop.
Update Script created to process update for FTB versions (ie FTBBeyond 1.8.1 to FTBBeyond 1.9.0)
#!/bin/bash
###########################
# Updating FTB to go live with provided version DL link
# Script by WBrown
# Originated on personal FTB Beyond server
# wget rewrite with assistance from u_phit URL: https://www.reddit.com/user/u_phit
############################
# Examples of use using data from FTB Beyond Version 1.9.0 for MC 1.10.2
# https://www.feed-the-beast.com/projects/ftb-beyond/files/2434638#additional-files
#rsync check
command -v rsync >/dev/null 2>&1 || { echo "rsync is required to use this script. Aborting..." >&2; exit 1; }
# Script starts with asking for the download url from https://www.feed-the-beast.com/projects/ftb-beyond/files
echo "\n\nPlease verify Minecraft Server is stopped.\n\n"
read -p "Please Enter Version (1.4.0): " Version
echo "\n\nWhat is the FTB Download link?\n(ie https://www.feed-the-beast.com/projects/ftb-beyond/files/2435256/download)"
read FTBDLa
FTBDLb="$(curl -i $FTBDLa | grep Location | awk '{print$2}'| tr -d '\r')"
ZipFile="$(echo $FTBDLb | awk -F"/" '{print$7}')"
# Sets other variables needed
# Change to match for FTBType and path locations
# Base directory will be the directory the the Minecraft server directory resides
FTBType="FTBPresentsDirewolf20112Server"
FTBVersion="$(echo $Version)"
BasePath="/home/AMP/.ampdata/instances/direwolf2/"
StagingPath="dire-staging"
BackupPath="dire-backups"
World="world"
# Goes to base directory and creates the staging directory
cd $BasePath
mkdir $StagingPath/Minecraft-$FTBType-$FTBVersion
# Updates user of new staging directory
echo "\nStaging directory: \n$BasePath$StagingPath/Minecraft-$FTBType-$FTBVersion/"
#Downloads zip
echo "\nDownloading Specified file $ZipFile from $FTBDLb"
wget -P ${BasePath}${StagingPath}/Minecraft-$FTBType-$FTBVersion/ $FTBDLb
# unzips FTB zip into staging directory
unzip $StagingPath/Minecraft-$FTBType-$FTBVersion/$ZipFile -d $StagingPath/Minecraft-$FTBType-$FTBVersion
echo "\nUnzip complete."
read -p "Press Enter to Continue" Holda
sh $StagingPath/Minecraft-$FTBType-$FTBVersion/FTBInstall.sh
echo "\nInstall into staging complete."
read -p "Press Enter to Continue" Holda
# RSyncs live Mincraft files without overwriting new FTB data (world is not moved in this script. See staging2live.sh
rsync -av --progress Minecraft/* $StagingPath/Minecraft-$FTBType-$FTBVersion --exclude mods --exclude libraries --exclude scripts --exclude modpack --exclude config --exclude ServerStart.sh --exclude ServerStart.bat --exclude $World
echo "\nLive to Staging rsync Complete."
read -p "Press Enter to Continue" Holda
# Rsync Additional Mods places in proper pathing (example below)
# mc-staging/mc-extramods/
# - mods/RTG-1.10.2-4.1.2.4.jar
# - mods/GeographiCraft-1.9.4-0.7.6.jar
# - mods/Dynmap-2.4-forge-1.10.2.jar
# - mods/worldedit-forge-mc1.10.2-6.1.4-dist.jar
# - config/GeographiCraft/geographicraft.cfg
# - config/GeographiCraft/CCDimensions.cfg
# - config/Dynmap.cfg
# - config/worldedit/worldedit.properties
# and so forth
rsync -av --progress $StagingPath/dire-extramods/* $StagingPath/Minecraft-$FTBType-$FTBVersion --exclude mods
echo "\nAdditional Mods rsync Complete."
echo "\n\nStaging Complete, please verify Minecraft Server is stopped.\n\n"
read -p "Press Enter to Continue" Holdb
# Move Live MC to mc-backups/Minecraft-${FTBType}-[date]
mv Minecraft $BackupPath/Minecraft-${FTBType}-$(date +"%Y-%m-%d")
echo "\nLive Minecraft successfully moved to ${BasePath}${BackupPath}/Minecraft-${FTBType}-$(date +"%Y-%m-%d")"
read -p "Press Enter to Continue" Holda
# Makes new Minecraft folder and rsyncs the staging in
mkdir Minecraft/
rsync -av --progress $StagingPath/Minecraft-$FTBType-$FTBVersion/* Minecraft/
echo "\nStaging has been moved into ${BasePath}Minecraft/"
read -p "Press Enter to Continue" Holda
# Syncs world data from new backup to live
mkdir Minecraft/$World/
rsync -av --progress $BackupPath/Minecraft-${FTBType}-$(date +"%Y-%m-%d")/$World/* Minecraft/$World/
echo "\n$World has been moved into ${BasePath}Minecraft/"
@wgoff194
Copy link
Author

wgoff194 commented Jun 25, 2017

I run a FTB Beyond server and hate the update process. I find moving my personal server from FTB Beyond from its current version to the latest release a real pain. However as a Linux admin I find minor scripting to be rewarding. I have created a script for staging and making live a new update. I use an AMP/MCMA server setup so I will use this for examples.

---- Warning ------
Although tested in my enviroment. Use of these scripts or derivatives is at your own risk. Using this script is considered and acknowledgement of this warning. I hold no liability.`
Remember Backups are your friend!

There are a number of things that need to be set up one time. To explain I will use the following:
$BasePath - This is the Parent Directory path where your Minecraft server resides (ie /home/AMP/.ampdata/instances/MCMA/
$StagingPath - This is the directory inside $BasePath for staging (ie mc-staging in /home/AMP/.ampdata/instances/MCMA/)
$BackupPath - This is the Directory the current live site will be backed up to (ie mc-backups in /home/AMP/.ampdata/instances/MCMA/)
$Extramods - Location of Mods not typically included in your FTB pack (ie $StagingPath/mc-extramods
$FTBType - This is the FTB Pack in use (ie FTBBeyondServer found in the name of the zip file FTBBeyondServer_1.9.0.zip)
$FTBVersion - The version of the FTB pack (ie 1.9.0 as seen in the name of the zip file, in this script a pront will ask for this)
$World - Name of your world directory

----- Needed Paths -----
A directory for $StagingPath will need to be created prior to use of script
A directory for $BackupPath will need to be created prior to use of script
If using additional mods the $Extramods folder iand its subfolders (see below) will need to be created in the $StagingPath directory

Example of Extramods:

/home/AMP/.ampdata/instances/MCMA/mc-staging/mc-extramods/
mods/RTG-1.10.2-4.1.2.4.jar
mods/GeographiCraft-1.9.4-0.7.6.jar
mods/Dynmap-2.4-forge-1.10.2.jar
mods/worldedit-forge-mc1.10.2-6.1.4-dist.jar
config/GeographiCraft/geographicraft.cfg
config/GeographiCraft/CCDimensions.cfg
config/Dynmap.cfg
config/worldedit/worldedit.properties
and so forth

(Place this in the $BasePath directory & always run as the user minecraft runs as)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment