Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/bash
- #title :ServerMaker.sh
- #description :Creates and starts a server for any CurseForge modpack
- #author :Stapleton
- #date :20190127
- #version :0.5
- #usage :./ServerMaker.sh <CurseForgeLink>
- #notes :Needs Java 8 JRE to install and run the server
- #=======================================================
- packlink=$1
- cmpdlpackversion=${2:-latest}
- log=ServerMaker.log
- forgeprop=server.properties
- cmpdl="cmpdl-1.2.jar"
- if [ -f ./$log ]; then
- rm $log
- fi
- div======================================================
- cmpdllink=https://github.com/Vazkii/CMPDL/releases/download/1.2/cmpdl-1.2.jar
- xms=1G
- xmx=6G
- jar_args=nogui
- java_args="-server -d64 -Xms$xms -Xmx$xmx -XX:+UseG1GC -Dsun.rmi.dgc.server.gcInterval=2147483646 -XX:+UnlockExperimentalVMOptions -XX:G1NewSizePercent=20 -XX:G1ReservePercent=20 -XX:MaxGCPauseMillis=50 -XX:G1HeapRegionSize=32M -Dfml.readTimeout=180"
- /usr/bin/clear
- _GetCMPDL() {
- wget -q $cmpdllink &&
- chmod +x ./$cmpdl
- }
- _InstallModpack() {
- /usr/bin/java -jar $cmpdl $packlink $cmpdlpackversion | tee -a $log | grep -e "Downloading [A-Za-z]" -e "Downloaded!"
- packdir=$(grep -e "Output Dir is " ./$log)
- packdir=${packdir#"Output Dir is "}
- mv "$packdir"/minecraft/* .
- mv "$packdir"/instance.cfg ./.instance.cfg
- rm -rf "$packdir"
- }
- _GetVars() {
- forgeversion=$(grep notes ./.instance.cfg | cut -d= -f2 | cut -d" " -f9)
- forgeversion=${forgeversion%"."}
- packversion=$(grep name ./.instance.cfg | cut -d= -f2)
- packversion=${packversion##*\ }
- mcversion=$(grep IntendedVersion ./.instance.cfg | cut -d= -f2)
- forgelink=https://files.minecraftforge.net/maven/net/minecraftforge/forge/$mcversion-$forgeversion/forge-$mcversion-$forgeversion-installer.jar
- forgeinstaller="forge-$mcversion-$forgeversion-installer.jar"
- forge="forge-$mcversion-$forgeversion-universal.jar"
- }
- _BannerInstall() {
- echo $div
- echo "Installing Modpack Server"
- echo "Minecraft $mcversion"
- echo "Modpack Version: $packversion"
- echo "Using Forge: $forgeversion"
- echo $div
- echo ""
- }
- _BannerStart() {
- echo $div
- echo "Starting Modpack Server"
- echo "Minecraft $mcversion"
- echo "Modpack Version: $packversion"
- echo "Using Forge: $forgeversion"
- echo $div
- echo ""
- }
- _GetForge() {
- wget -q $forgelink &&
- chmod +x ./$forgeinstaller
- }
- _InstallForge() {
- /usr/bin/java -jar $forgeinstaller --installServer
- }
- _Setup() {
- echo "eula=true" >> eula.txt
- echo "allow-flight=true" >> $forgeprop
- echo "server-ip=0.0.0.0" >> $forgeprop
- }
- _Cleanup() {
- rm -rf $forgeinstaller $forgeinstaller.log $cmpdl
- }
- _StartServer() {
- /usr/bin/java $java_args -jar $forge $jar_args
- }
- Install() {
- echo $div
- echo "Downloading CMPDL from Github"
- echo $div
- _GetCMPDL >> $log &&
- /usr/bin/clear
- echo $div
- echo "Downloading Modpack from Curseforge via CMPDL"
- echo $div
- _InstallModpack &&
- /usr/bin/clear
- _GetVars &&
- _BannerInstall &&
- /usr/bin/clear
- echo $div
- echo "Downloading Forge $forgeversion"
- echo $div
- _GetForge >> $log &&
- /usr/bin/clear
- echo $div
- echo "Installing Forge $forgeversion Server"
- echo $div
- _InstallForge >> $log &&
- /usr/bin/clear
- echo $div
- echo "Setting up Modpack Server"
- echo $div
- _Setup &&
- /usr/bin/clear
- echo $div
- echo "Cleaning up installation files"
- echo $div
- _Cleanup &&
- /usr/bin/clear
- echo $div
- echo "Successfully installed Modpack Server"
- echo "Minecraft $mcversion"
- echo "Modpack Version: $packversion"
- echo "Using Forge: $forgeversion"
- echo $div
- echo ""
- }
- Start() {
- _GetVars &&
- _BannerStart &&
- _StartServer
- }
- if [ ! -f ./minecraft*.jar ]; then
- if [ "$packlink" == '' ]; then
- echo "No CurseForge Modpack link was supplied!"
- exit
- fi
- Install
- else
- Start
- fi
Advertisement
Add Comment
Please, Sign In to add comment