SHARE
TWEET

minecraft_server multi server type patch

a guest Nov 22nd, 2012 538 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. --- minecraft_server    Wed Nov 21 19:22:52 2012
  2. +++ minecraft_server_a  Thu Nov 22 00:52:04 2012
  3. @@ -79,24 +79,37 @@
  4.  
  5.  
  6.  ## Minecraft server options.
  7. +SERVER_TYPES="mojang bukkit tekkit"
  8.  
  9. -# Choose only one server distribution, leave the other commented out.
  10. +## Some extra Java Options
  11. +#JAVA_OPTS="-Xmx1536M -XX:+UseConcMarkSweepGC -XX:+UseParNewGC -XX:+CMSIncrementalPacing -XX:ParallelGCThreads=2 -XX:+AggressiveOpts"
  12.  
  13.  # Default Mojang server distribution.
  14. -SERVER_URL="http://www.minecraft.net/download/minecraft_server.jar"
  15. -SERVER_JAR="minecraft_server.jar"
  16. -SERVER_ARGS="nogui"
  17. +SERVER_MOJANG_URL="https://s3.amazonaws.com/MinecraftDownload/launcher/Minecraft_Server.exe"
  18. +SERVER_MOJANG_JAR="minecraft_server.jar"
  19. +SERVER_MOJANG_ARGS="nogui"
  20. +SERVER_MOJANG_JAVA_OPTS="-Xms512M -Xmx1G"
  21.  
  22.  # CraftBukkit server distribution.
  23. -# SERVER_URL="http://repo.bukkit.org/service/local/artifact/maven/redirect?g=org.bukkit&a=craftbukkit&v=RELEASE&r=releases"
  24. -# SERVER_JAR="craftbukkit.jar"
  25. -# SERVER_ARGS=""
  26. +SERVER_BUKKIT_URL="http://cbukk.it/craftbukkit.jar"
  27. +SERVER_BUKKIT_JAR="craftbukkit.jar"
  28. +SERVER_BUKKIT_JAVA_OPTS="-Xms512M -Xmx1G"
  29. +SERVER_BUKKIT_ARGS=""
  30. +
  31. +# Tekkit server distribution.
  32. +SERVER_TEKKIT_URL="http://mirror.technicpack.net/Technic/servers/tekkit/Tekkit_Server_3.1.3.zip"
  33. +SERVER_TEKKIT_JAR="Tekkit.jar"
  34. +SERVER_TEKKIT_JAVA_OPTS="-Xms512M -Xmx1G"
  35. +SERVER_TEKKIT_ARGS="nogui"
  36. +
  37. +# Feed the Beast server distribution.
  38. +SERVER_FTB_URL="http://repo.creeperhost.net/direct/FTB2/71a030a9197ede2920757ecdc59cd6c1/FTBBetaA_Server.zip"
  39. +SERVER_FTB_JAR="FTB-Beta-A.jar"
  40. +SERVER_FTB_JAVA_OPTS="-Xms512M -Xmx1G"
  41. +SERVER_FTB_ARGS="nogui"
  42.  
  43.  # Generic server options.
  44. -INITIAL_MEMORY="128M"
  45. -MAXIMUM_MEMORY="2048M"
  46.  SERVER_LOCATION="$LOCATION/minecraft_server"
  47. -SERVER_COMMAND="$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS"
  48.  
  49.  
  50.  ## World configuration.
  51. @@ -111,16 +124,18 @@
  52.  # address blank if not needed.
  53.  #
  54.  # # Minecraft world configuration file
  55. -# # <world>    <port>  <ip>
  56. -#   alpha      25565
  57. -#   beta       25566
  58. -#   gamma      25567
  59. -#   delta      25568
  60. -#   epsilon    25569
  61. +# # <world>    <server>        <port>  <ip>
  62. +#   alpha      mojang  25565
  63. +#   beta       mojang  25566
  64. +#   gamma      bukkit  25567
  65. +#   delta      tekkit  25568
  66. +#   epsilon    ftb     25569
  67.  WORLDS_CONF="$LOCATION/worlds.conf"
  68.  
  69. -# Default world name, port, and IP address if the worlds.conf file is missing.
  70. +# Default world name, server type, port, and IP address if the worlds.conf file is missing.
  71. +# Supported server types are ( mojang bukkit tekkit )
  72.  DEFAULT_WORLD="world"
  73. +DEFAULT_SERVER="mojang"
  74.  DEFAULT_PORT="25565"
  75.  DEFAULT_IP=""
  76.  
  77. @@ -314,7 +329,7 @@
  78.  # @return The port that the world is configured to use.
  79.  getPort() {
  80.         local PORT
  81. -       PORT=$(execute "cat $WORLDS_CONF" $USER_NAME | $PERL -ne 'if ($_ =~ /^'$1'\s+(\d+)/) { print "$1"; }')
  82. +       PORT=$(execute "cat $WORLDS_CONF" $USER_NAME | $PERL -ne 'if ($_ =~ /^'$1'\s+[\w\d]+\s+(\d+)/) { print "$1"; }')
  83.         echo $PORT
  84.  }
  85.  
  86. @@ -324,10 +339,20 @@
  87.  # @return The IP address that the world is configured to run on.
  88.  getIP() {
  89.         local IP
  90. -        IP=$(execute "cat $WORLDS_CONF" $USER_NAME | $PERL -ne 'if ($_ =~ /^'$1'\s+\d+\s+([\d\.]+)/) { print "$1"; }')
  91. +       IP=$(execute "cat $WORLDS_CONF" $USER_NAME | $PERL -ne 'if ($_ =~ /^'$1'\s+[\w\d]+\s+\d+\s+([\d\.]+)/) { print "$1"; }')
  92.         echo $IP
  93.  }
  94.  
  95. +# Grab the server type for the given world.
  96. +#
  97. +# @param 1 The world server of interest.
  98. +# @return The server type that the world is configured to run on.
  99. +getServerType() {
  100. +       local SERVER
  101. +       SERVER=$(execute "cat $WORLDS_CONF" $USER_NAME | $PERL -ne 'if ($_ =~ /^'$1'\s+([\w\d]+)/) { print "$1"; }')
  102. +       echo $SERVER
  103. +}
  104. +
  105.  # Grab the first line of the Message of the Day file as a summary, and strip
  106.  # any color codes from it.
  107.  getMOTD() {
  108. @@ -344,7 +369,7 @@
  109.  # @return The list of worlds.
  110.  getWorlds() {
  111.         local WORLDS
  112. -       WORLDS=$(execute "cat $WORLDS_CONF" $USER_NAME | $PERL -ne 'if ($_ =~ /^(\w+)\s+(\d+)/) { print "$1 "; }')
  113. +       WORLDS=$(execute "cat $WORLDS_CONF" $USER_NAME | $PERL -ne 'if ($_ =~ /^([\w\d]+)\s+[\w\d]+\s+\d+/) { print "$1 "; }')
  114.         echo $WORLDS
  115.  }
  116.  
  117. @@ -534,15 +559,63 @@
  118.  #
  119.  # @param 1 The world server to start.
  120.  start() {
  121. -       local PID WORLD_DIR
  122. +       local PID WORLD_DIR SERVER_TYPE SERVER_JAR SERVER_ARGS JAVA_OPTS
  123. +
  124.         # Make sure that the world's directory exists.
  125.         WORLD_DIR="$WORLDS_LOCATION/$1"
  126. -       execute "mkdir -p $WORLD_DIR" $USER_NAME
  127. -       # Make sure that the server.properties file holds the correct values.
  128. -       setPropertiesValue $WORLDS_LOCATION/$1/server.properties "level-name"  "$1"
  129. -       setPropertiesValue $WORLDS_LOCATION/$1/server.properties "server-port" "$(getPort $1)"
  130. -       setPropertiesValue $WORLDS_LOCATION/$1/server.properties "server-ip"   "$(getIP $1)"
  131. -       setPropertiesValue $WORLDS_LOCATION/$1/server.properties "motd"        "$(getMOTD)"
  132. +       if [ ! -d "$WORLDS_LOCATION/$1" ]; then
  133. +               execute "mkdir -p $WORLD_DIR" $USER_NAME
  134. +       fi
  135. +
  136. +       # Get the world server type
  137. +       SERVER_TYPE=$(getServerType "$1")
  138. +
  139. +       # Set the server location, and args
  140. +       if [ $SERVER_TYPE = "mojang" ]; then
  141. +               SERVER_JAR=$SERVER_MOJANG_JAR
  142. +               SERVER_ARGS=$SERVER_MOJANG_ARGS
  143. +               JAVA_OPTS=$SERVER_MOJANG_JAVA_OPTS
  144. +       elif [ $SERVER_TYPE = "bukkit" ]; then
  145. +               SERVER_JAR=$SERVER_BUKKIT_JAR
  146. +               SERVER_ARGS=$SERVER_BUKKIT_ARGS
  147. +               JAVA_OPTS=$SERVER_BUKKIT_JAVA_OPTS
  148. +       elif [ $SERVER_TYPE = "tekkit" ]; then
  149. +               SERVER_JAR=$SERVER_TEKKIT_JAR
  150. +               SERVER_ARGS=$SERVER_TEKKIT_ARGS
  151. +               JAVA_OPTS=$SERVER_TEKKIT_JAVA_OPTS
  152. +       elif [ $SERVER_TYPE = "ftb" ]; then
  153. +               SERVER_JAR=$SERVER_FTB_JAR
  154. +               SERVER_ARGS=$SERVER_FTB_ARGS
  155. +               JAVA_OPTS=$SERVER_FTB_JAVA_OPTS
  156. +       else
  157. +               SERVER_JAR=$SERVER_MOJANG_JAR
  158. +               SERVER_ARGS=$SERVER_MOJANG_ARGS
  159. +               JAVA_OPTS=$SERVER_MOJANG_JAVA_OPTS
  160. +       fi
  161. +
  162. +       # Make sure that the server software exists.
  163. +       if [ ! -e $SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR ]; then
  164. +               printf "\nServer software not found, downloading it...\n"
  165. +               update "server"
  166. +       fi
  167. +
  168. +       # Custom actions for tekkit
  169. +       if [ $SERVER_TYPE = "tekkit" ] && [ ! -e "$WORLDS_LOCATION/$1/$SERVER_TEKKIT_JAR" ]; then
  170. +               execute "cp -Rp $SERVER_LOCATION/$SERVER_TYPE/* $WORLDS_LOCATION/$1/" $USER_NAME
  171. +       fi
  172. +
  173. +       # Custom actions for feed-the-beast
  174. +       if [ $SERVER_TYPE = "ftb" ] && [ ! -e "$WORLDS_LOCATION/$1/$SERVER_FTB_JAR" ]; then
  175. +               execute "cp -Rp $SERVER_LOCATION/$SERVER_TYPE/* $WORLDS_LOCATION/$1/" $USER_NAME
  176. +       fi
  177. +
  178. +       # Make sure that the server.properties file holds the same values as
  179. +       # the worlds.conf and motd.txt files.
  180. +       setPropertiesValue $WORLDS_LOCATION/$1/server.properties "level-name" $1
  181. +       setPropertiesValue $WORLDS_LOCATION/$1/server.properties "server-port" $(getPort $1)
  182. +       setPropertiesValue $WORLDS_LOCATION/$1/server.properties "server-ip" $(getIP $1)
  183. +       setPropertiesValue $WORLDS_LOCATION/$1/server.properties "motd" "$(getMOTD $1)"
  184. +
  185.         # Make a mirror image of the world directory if requested.
  186.         if [ $ENABLE_MIRROR -eq 1 ] && [ -d $MIRROR_PATH ]; then
  187.                 execute "mkdir -p $MIRROR_PATH/$1" $USER_NAME
  188. @@ -560,7 +633,7 @@
  189.         # case it is not already empty for some reason.
  190.         execute "printf \"\" > \"$WORLDS_LOCATION/$1.users\"" $USER_NAME
  191.         # Start the server.
  192. -       execute "$SCREEN -dmS minecraft-$1 $SERVER_COMMAND" $USER_NAME
  193. +       execute "$SCREEN -dmS minecraft-$1 $JAVA $JAVA_OPTS -jar $SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR $SERVER_ARGS" $USER_NAME
  194.         if [ $? -ne 0 ]; then
  195.                 printf "Error starting the server.\n"
  196.                 exit 1
  197. @@ -637,21 +710,72 @@
  198.  
  199.  # Update the server software.
  200.  updateServerSoftware() {
  201. -       execute "mkdir -p $SERVER_LOCATION" $USER_NAME
  202. -       # Backup the old minecraft.jar file.
  203. -       if [ -e $SERVER_LOCATION/$SERVER_JAR ]; then
  204. -               execute "mv -f $SERVER_LOCATION/$SERVER_JAR $SERVER_LOCATION/$SERVER_JAR.old" $USER_NAME
  205. -       fi
  206. -       # Download the new minecraft server software.
  207. -       execute "$WGET -qO \"$SERVER_LOCATION/$SERVER_JAR\" \"$SERVER_URL\"" $USER_NAME
  208. -       # Check for error and restore backup if found.
  209. -       if [ $? -ne 0 ]; then
  210. -               printf "\nError updating server software.\n"
  211. -               if [ -e "$SERVER_LOCATION/$SERVER_JAR.old" ]; then
  212. -                       execute "mv -f $SERVER_LOCATION/$SERVER_JAR.old $SERVER_LOCATION/$SERVER_JAR" $USER_NAME
  213. +       local SERVER_JAR SERVER_URL
  214. +
  215. +       for SERVER_TYPE in $SERVER_TYPES; do
  216. +               # Set the server location, and args
  217. +               if [ $SERVER_TYPE = "mojang" ]; then
  218. +                       SERVER_URL=$SERVER_MOJANG_URL
  219. +                       SERVER_JAR=$SERVER_MOJANG_JAR
  220. +               elif [ $SERVER_TYPE = "bukkit" ]; then
  221. +                       SERVER_URL=$SERVER_BUKKIT_URL
  222. +                       SERVER_JAR=$SERVER_BUKKIT_JAR
  223. +               elif [ $SERVER_TYPE = "tekkit" ]; then
  224. +                       SERVER_URL=$SERVER_TEKKIT_URL
  225. +                       SERVER_JAR=$SERVER_TEKKIT_JAR
  226. +               elif [ $SERVER_TYPE = "ftb" ]; then
  227. +                       SERVER_URL=$SERVER_FTB_URL
  228. +                       SERVER_JAR=$SERVER_FTB_JAR
  229.                 fi
  230. -               exit 1
  231. -       fi
  232. +
  233. +               execute "mkdir -p $SERVER_LOCATION/$SERVER_TYPE" $USER_NAME
  234. +
  235. +               # Custom actions for tekkit
  236. +               if [ $SERVER_TYPE = "tekkit" ]; then
  237. +                       printf "\nNot updating Tekkit.\n"
  238. +                       # Backup the old server package.
  239. +                       # if [ -e "$SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR" ]; then
  240. +                       #       execute "tar zcf $SERVER_LOCATION/$SERVER_TYPE.old.tar.gz $SERVER_LOCATION/$SERVER_TYPE/" $USER_NAME
  241. +                       #       execute "rm -rf $SERVER_LOCATION/$SERVER_TYPE/" $USER_NAME
  242. +                       #       execute "rm $SERVER_LOCATION/$SERVER_TYPE.zip" $USER_NAME
  243. +                       # fi
  244. +
  245. +                       # Download the new server software.
  246. +                       # execute "$WGET -qO $SERVER_LOCATION/$SERVER_TYPE.zip $SERVER_URL" $USER_NAME
  247. +
  248. +                       # Check for error and restore backup if found.
  249. +                       # if [ $? -ne 0 ]; then
  250. +                       #       printf "\nError updating server software.\n"
  251. +                       #       if [ -e "$SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR.old.tar.gz" ]; then
  252. +                       #               execute "tar xzf $SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR.old.tar.gz" $USER_NAME
  253. +                       #       fi
  254. +                       #       exit 1
  255. +                       # else
  256. +                       #       execute "unzip -qq $SERVER_LOCATION/$SERVER_TYPE.zip -d $SERVER_LOCATION/$SERVER_TYPE/" $USER_NAME
  257. +                               #TODO - copy new update to all tekkit servers
  258. +                       #fi
  259. +               # Custom actions for feed-the-beast
  260. +               elif [ $SERVER_TYPE = "ftb" ]; then
  261. +                       printf "\nNot updating Feed the Beast.\n"
  262. +               else
  263. +                       # Backup the old server jar.
  264. +                       if [ -e "$SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR" ]; then
  265. +                               execute "mv -f $SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR $SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR.old" $USER_NAME
  266. +                       fi
  267. +
  268. +                       # Download the new server software.
  269. +                       execute "$WGET -qO $SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR $SERVER_URL" $USER_NAME
  270. +
  271. +                       # Check for error and restore backup if found.
  272. +                       if [ $? -ne 0 ]; then
  273. +                               printf "\nError updating server software.\n"
  274. +                               if [ -e "$SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR.old" ]; then
  275. +                                       execute "mv -f $SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR.old $SERVER_LOCATION/$SERVER_TYPE/$SERVER_JAR" $USER_NAME
  276. +                               fi
  277. +                               exit 1
  278. +                       fi
  279. +               fi
  280. +       done
  281.  }
  282.  
  283.  # Update the c10t mapping software.  If already installed, compare version
  284. @@ -845,7 +969,7 @@
  285.  if [ ! -e $JAVA ] || [ ! -e $JAR ]; then
  286.         printf "ERROR: Java not found!\n"
  287.         printf "Try installing this with:\n"
  288. -       printf "sudo apt-get install openjdk-6-jdk"
  289. +       printf "sudo apt-get install openjdk-7-jre\n"
  290.         exit 1
  291.  fi
  292.  if [ ! -e $PERL ]; then
  293. @@ -898,8 +1022,8 @@
  294.  # Generate a default worlds.conf file if it does not already exist.
  295.  if [ ! -e $WORLDS_CONF ]; then
  296.         execute "printf \"# Minecraft world configuration file\n\" > $WORLDS_CONF" $USER_NAME
  297. -       execute "printf \"# <world>\t<port>\t<ip>\n\" >> $WORLDS_CONF" $USER_NAME
  298. -       execute "printf \"$DEFAULT_WORLD\t$DEFAULT_PORT\t$DEFAULT_IP\n\" >> $WORLDS_CONF" $USER_NAME
  299. +       execute "printf \"# <world>\t<server>\t<port>\t<ip>\n\" >> $WORLDS_CONF" $USER_NAME
  300. +       execute "printf \"$DEFAULT_WORLD\t$DEFAULT_SERVER\t$DEFAULT_PORT\t$DEFAULT_IP\n\" >> $WORLDS_CONF" $USER_NAME
  301.  fi
  302.  
  303.  # Make sure that the server software exists.
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top