Last active
May 11, 2022 13:57
-
-
Save theskyblockman/270da48de8625f2e4c562a07c7f8f16e to your computer and use it in GitHub Desktop.
A plugin deployer to a spigot server for testing
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 | |
# How to run: | |
# Put this script where you want your servers to be located (in an empty folder) | |
# Have Java 17 | |
# Have an internet connection | |
# And have an computer | |
if [ expr $# < 2 ]; then | |
read -p "Enter the plugin version: " jarVersion | |
read -p "Enter the plugin path: " jarPath | |
else | |
jarVersion=$1 | |
jarPath=$2 | |
fi | |
serverPath="${PWD##}/$jarVersion" | |
RAM_KB=$(grep MemTotal /proc/meminfo | awk '{print $2}') | |
RAM_MB=$(expr $RAM_KB / 1024) | |
SERVER_RAM_CAPACITY=$(expr $RAM_MB / 4) # Edit here the portion of your want that you want to be used by the server, the default is 1/4 of your RAM | |
if [[ "$jarVersion" == *"/"* ]]; then | |
read -p "Hold up! Are you trying to use an external directory for the server? [Y/n]: " verification | |
fi | |
if [[ "$verification" == *"Y"* ]]; then | |
read -p "So please enter the real version of the plugin: " jarVersion | |
read -p "And the path from where do you want the plugin to be runned: " serverPath | |
else | |
if [[ "$verification" == *"N"* ]]; then | |
echo "This is strange but I accept it." | |
fi | |
fi | |
if [ ! -n `which java` ]; then | |
echo "Java is not installed, please install Java to run the Spigot Build Tool and to run the server!" | |
exit 0 | |
fi | |
if [ -d "./$jarVersion" ]; then | |
echo "dir existing" | |
else | |
if [ ! -f "./BuildTool/Buildtool.jar" ]; then | |
echo "Downloading build tool..." | |
mkdir BuildTool | |
wget -q https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar -O ./BuildTool/BuildTool.jar | |
fi | |
mkdir "$serverPath" | |
cd BuildTool/ | |
java -jar BuildTool/BuildTool.jar --rev $jarVersion -o $serverPath | |
cd .. | |
if [ ! $? -eq 0 ]; then | |
echo "The server build didn't ran successfully, is your server path and/or server version correct? Please check the BuildTools logs at BuildTool/BuildTools.log.txt" | |
exit 0 | |
fi | |
if [ -f $jarPath ]; then | |
mkdir "$serverPath/plugins/" | |
mv $jarPath "$serverPath/plugins/" | |
fi | |
fi | |
echo "The plugin move to the plugin folder succed, please wait for the server to start..." | |
echo $SERVER_RAM_CAPACITY | |
cd $jarVersion | |
java -jar -Xmx"$SERVER_RAM_CAPACITY"m $jarVersion/spigot-"$jarVersion".jar --nogui | |
cd .. | |
echo "Thanks for using this builder and runner, see you soon !" | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment