Merge pull request #41 from sandain/server.properties

Merge the server.properties branch
This commit is contained in:
Jason M. Wood 2013-12-27 11:42:57 -08:00
commit b53de129f1
2 changed files with 339 additions and 62 deletions

74
README
View File

@ -226,38 +226,56 @@ Example motd.txt:
§fLook out for those §2creepers§f!
CraftBukkit
Server Customization
-----------------------------
To use the CraftBukkit server distribution instead of the default Mojang
server, modify the following lines of code:
The server settings for each world can be customized by adding certain
key/value pairs to the world's server.properties file.
## Minecraft server options.
The following keys are available:
mscs-client-version - Assign the version of the client software.
mscs-client-jar - Assign the .jar file for the client software.
mscs-client-url - Assign the download URL for the client software.
mscs-client-location - Assign the location of the client .jar file.
mscs-server-version - Assign the version of the server software.
mscs-server-jar - Assign the .jar file for the server software.
mscs-server-url - Assign the download URL for the server software.
mscs-server-args - Assign the arguments to the server.
mscs-initial-memory - Assign the initial amount of memory for the server.
mscs-maximum-memory - Assign the maximum amount of memory for the server.
mscs-server-location - Assign the location of the server .jar file.
mscs-server-command - Assign the command to run for the server.
The following variables may be used in some of the values of the above keys:
$JAVA - The Java virtual machine.
$CURRENT_VERSION - The current Mojang Minecraft release version.
$CLIENT_VERSION - The version of the client software.
$SERVER_VERSION - The version of the server software.
$SERVER_JAR - The .jar file to run for the server.
$SERVER_ARGS - The arguments to the server.
$INITIAL_MEMORY - The initial amount of memory for the server.
$MAXIMUM_MEMORY - The maximum amount of memory for the server.
$SERVER_LOCATION - The location of the server .jar file.
# Choose only one server distribution, leave the other commented out.
The following example key/value pairs are equivalent to the default values:
mscs-client-version=$CURRENT_VERSION
mscs-client-jar=$CLIENT_VERSION.jar
mscs-client-url=https://s3.amazonaws.com/Minecraft.Download/versions/$CLIENT_VERSION/$CLIENT_VERSION.jar
mscs-client-location=/home/minecraft/.minecraft/versions/$CLIENT_VERSION
mscs-server-version=$CURRENT_VERSION
mscs-server-jar=minecraft_server.$SERVER_VERSION.jar
mscs-server-url=https://s3.amazonaws.com/Minecraft.Download/versions/$SERVER_VERSION/minecraft_server.$SERVER_VERSION.jar
mscs-server-args=nogui
mscs-initial-memory=128M
mscs-maximum-memory=2048M
mscs-server-location=/home/minecraft/minecraft_server
mscs-server-command=$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS
# Default Mojang server distribution.
SERVER_URL="http://www.minecraft.net/download/minecraft_server.jar"
SERVER_JAR="minecraft_server.jar"
SERVER_ARGS="nogui"
# CraftBukkit server distribution.
# SERVER_URL="http://dl.bukkit.org/latest-rb/craftbukkit.jar"
# SERVER_JAR="craftbukkit.jar"
# SERVER_ARGS=""
Bukkit plugins are world specific and are contained within the plugins
directory of the world. ie.
/home/minecraft/worlds/alpha/plugins
If you would prefer to use the same plugins directory for all of your worlds,
you can create symlinks for each world. ie.
mkdir /home/minecraft/plugins
ln -s /home/minecraft/plugins /home/minecraft/worlds/alpha/plugins
ln -s /home/minecraft/plugins /home/minecraft/worlds/beta/plugins
The following example key/value pairs will use the latest CraftBukkit recommended build:
mscs-server-jar=craftbukkit.jar
mscs-server-url=http://dl.bukkit.org/latest-rb/craftbukkit.jar
mscs-server-args=
mscs-initial-memory=128M
mscs-maximum-memory=2048M
Lib Notify

View File

@ -166,32 +166,66 @@ CURRENT_VERSION=$(
# Minecraft Server Settings
# ---------------------------------------------------------------------------
# Choose only one server distribution, leave the other commented out.
# Default settings if not provided in the world's server.properties file.
# Default Mojang server distribution.
SERVER_JAR="minecraft_server.$CURRENT_VERSION.jar"
SERVER_URL="https://s3.amazonaws.com/Minecraft.Download/versions/$CURRENT_VERSION/minecraft_server.$CURRENT_VERSION.jar"
SERVER_ARGS="nogui"
DEFAULT_WORLD="world"
DEFAULT_PORT="25565"
DEFAULT_IP=""
DEFAULT_CLIENT_VERSION=$CURRENT_VERSION
DEFAULT_CLIENT_JAR='$CLIENT_VERSION.jar'
DEFAULT_CLIENT_URL='https://s3.amazonaws.com/Minecraft.Download/versions/$CLIENT_VERSION/$CLIENT_VERSION.jar'
DEFAULT_CLIENT_LOCATION=$LOCATION'/.minecraft/versions/$CLIENT_VERSION'
DEFAULT_SERVER_VERSION=$CURRENT_VERSION
DEFAULT_SERVER_JAR='minecraft_server.$SERVER_VERSION.jar'
DEFAULT_SERVER_URL='https://s3.amazonaws.com/Minecraft.Download/versions/$SERVER_VERSION/minecraft_server.$SERVER_VERSION.jar'
DEFAULT_SERVER_ARGS='nogui'
DEFAULT_INITIAL_MEMORY='128M'
DEFAULT_MAXIMUM_MEMORY='2048M'
DEFAULT_SERVER_LOCATION=$LOCATION'/minecraft_server'
DEFAULT_SERVER_COMMAND='$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS'
# CraftBukkit server distribution.
# SERVER_URL="http://dl.bukkit.org/latest-rb/craftbukkit.jar"
# SERVER_JAR="craftbukkit.jar"
# SERVER_ARGS=""
# Generic server options.
INITIAL_MEMORY="128M"
MAXIMUM_MEMORY="2048M"
SERVER_LOCATION="$LOCATION/minecraft_server"
SERVER_COMMAND="$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS"
# Minecraft Client Settings
# ---------------------------------------------------------------------------
# Used by Minecraft Overviewer mapping software.
CLIENT_JAR="$CURRENT_VERSION.jar"
CLIENT_URL="https://s3.amazonaws.com/Minecraft.Download/versions/$CURRENT_VERSION/$CURRENT_VERSION.jar"
CLIENT_LOCATION="$LOCATION/.minecraft/versions/$CURRENT_VERSION"
# The server settings for each world can be customized by adding certain
# key/value pairs to the world's server.properties file.
#
# The following keys are available:
# mscs-client-version - Assign the version of the client software.
# mscs-client-jar - Assign the .jar file for the client software.
# mscs-client-url - Assign the download URL for the client software.
# mscs-client-location - Assign the location of the client .jar file.
# mscs-server-version - Assign the version of the server software.
# mscs-server-jar - Assign the .jar file for the server software.
# mscs-server-url - Assign the download URL for the server software.
# mscs-server-args - Assign the arguments to the server.
# mscs-initial-memory - Assign the initial amount of memory for the server.
# mscs-maximum-memory - Assign the maximum amount of memory for the server.
# mscs-server-location - Assign the location of the server .jar file.
# mscs-server-command - Assign the command to run for the server.
#
# The following variables may be used in some of the values of the above
# keys:
# $JAVA - The Java virtual machine.
# $CURRENT_VERSION - The current Mojang Minecraft release version.
# $CLIENT_VERSION - The version of the client software.
# $SERVER_VERSION - The version of the server software.
# $SERVER_JAR - The .jar file to run for the server.
# $SERVER_ARGS - The arguments to the server.
# $INITIAL_MEMORY - The initial amount of memory for the server.
# $MAXIMUM_MEMORY - The maximum amount of memory for the server.
# $SERVER_LOCATION - The location of the server .jar file.
#
# The following example key/value pairs are equivalent to the default values:
# mscs-client-version=$CURRENT_VERSION
# mscs-client-jar=$CLIENT_VERSION.jar
# mscs-client-url=https://s3.amazonaws.com/Minecraft.Download/versions/$CLIENT_VERSION/$CLIENT_VERSION.jar
# mscs-client-location=/home/minecraft/.minecraft/versions/$CLIENT_VERSION
# mscs-server-version=$CURRENT_VERSION
# mscs-server-jar=minecraft_server.$SERVER_VERSION.jar
# mscs-server-url=https://s3.amazonaws.com/Minecraft.Download/versions/$SERVER_VERSION/minecraft_server.$SERVER_VERSION.jar
# mscs-server-args=nogui
# mscs-initial-memory=128M
# mscs-maximum-memory=2048M
# mscs-server-location=/home/minecraft/minecraft_server
# mscs-server-command=$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS
# World (Server Instance) Configuration
@ -203,12 +237,6 @@ WORLDS_LOCATION="$LOCATION/worlds"
# The location to store disabled world server files.
DISABLED_WORLDS_LOCATION="$LOCATION/worlds-disabled"
# Default world name, port, and IP address if the worlds.conf file is
# missing.
DEFAULT_WORLD="world"
DEFAULT_PORT="25565"
DEFAULT_IP=""
# Global Message Of The Day file (MOTD)
# ---------------------------------------------------------------------------
@ -532,6 +560,226 @@ setPropertiesValue() {
fi
}
# ---------------------------------------------------------------------------
# Retrieve the version of the client for the world.
#
# @param 1 The world server.
# @return CLIENT_VERSION
# ---------------------------------------------------------------------------
getClientVersion() {
local CLIENT_VERSION
# Get the client version, use the default version if not provided.
CLIENT_VERSION=$(
getPropertiesValue "$1" "mscs-client-version" "$DEFAULT_CLIENT_VERSION" |
$PERL -ne '
$current_version="'$CURRENT_VERSION'";
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
print;
'
)
echo "$CLIENT_VERSION"
}
# ---------------------------------------------------------------------------
# Retrieve the .jar file name for the client for the world.
#
# @param 1 The world server.
# @return CLIENT_JAR
# ---------------------------------------------------------------------------
getClientJar() {
local CLIENT_JAR
# Get the client jar, use the default value if not provided.
CLIENT_JAR=$(
getPropertiesValue "$1" "mscs-client-jar" "$DEFAULT_CLIENT_JAR" |
$PERL -ne '
$current_version="'$CURRENT_VERSION'";
$client_version="'$(getClientVersion "$1")'";
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
$_ =~ s/\$CLIENT_VERSION/$client_version/g;
print;
'
)
echo "$CLIENT_JAR"
}
# ---------------------------------------------------------------------------
# Retrieve the location of the client files for the world.
#
# @param 1 The world server.
# @return CLIENT_LOCATION
# ---------------------------------------------------------------------------
getClientLocation() {
local CLIENT_LOCATION
# Get the client location, use the default value if not provided.
CLIENT_LOCATION=$(
getPropertiesValue "$1" "mscs-client-location" "$DEFAULT_CLIENT_LOCATION" |
$PERL -ne '
$current_version="'$CURRENT_VERSION'";
$client_version="'$(getClientVersion "$1")'";
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
$_ =~ s/\$CLIENT_VERSION/$client_version/g;
print;
'
)
echo "$CLIENT_LOCATION"
}
# ---------------------------------------------------------------------------
# Retrieve the URL to download the client for the world.
#
# @param 1 The world server.
# @return CLIENT_URL
# ---------------------------------------------------------------------------
getClientURL() {
local CLIENT_URL
# Get the client download URL, use the default value if not provided.
CLIENT_URL=$(
getPropertiesValue "$1" "mscs-client-url" "$DEFAULT_CLIENT_URL" |
$PERL -ne '
$current_version="'$CURRENT_VERSION'";
$client_version="'$(getClientVersion "$1")'";
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
$_ =~ s/\$CLIENT_VERSION/$client_version/g;
$_ =~ s/\\\:/\:/g;
print;
'
)
echo "$CLIENT_URL"
}
# ---------------------------------------------------------------------------
# Retrieve the version of the server running the world.
#
# @param 1 The world server.
# @return SERVER_VERSION
# ---------------------------------------------------------------------------
getServerVersion() {
local SERVER_VERSION
# Get the server version, use the default version if not provided.
SERVER_VERSION=$(
getPropertiesValue "$1" "mscs-server-version" "$DEFAULT_SERVER_VERSION" |
$PERL -ne '
$current_version="'$CURRENT_VERSION'";
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
print;
'
)
echo "$SERVER_VERSION"
}
# ---------------------------------------------------------------------------
# Retrieve the .jar file name for the server running the world.
#
# @param 1 The world server.
# @return SERVER_JAR
# ---------------------------------------------------------------------------
getServerJar() {
local SERVER_JAR
# Get the server jar, use the default value if not provided.
SERVER_JAR=$(
getPropertiesValue "$1" "mscs-server-jar" "$DEFAULT_SERVER_JAR" |
$PERL -ne '
$current_version="'$CURRENT_VERSION'";
$server_version="'$(getServerVersion "$1")'";
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
$_ =~ s/\$SERVER_VERSION/$server_version/g;
print;
'
)
echo "$SERVER_JAR"
}
# ---------------------------------------------------------------------------
# Retrieve the location of the server files for the server running the world.
#
# @param 1 The world server.
# @return SERVER_LOCATION
# ---------------------------------------------------------------------------
getServerLocation() {
local SERVER_LOCATION
# Get the server location, use the default value if not provided.
SERVER_LOCATION=$(
getPropertiesValue "$1" "mscs-server-location" "$DEFAULT_SERVER_LOCATION" |
$PERL -ne '
$current_version="'$CURRENT_VERSION'";
$server_version="'$(getServerVersion "$1")'";
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
$_ =~ s/\$SERVER_VERSION/$server_version/g;
print;
'
)
echo "$SERVER_LOCATION"
}
# ---------------------------------------------------------------------------
# Retrieve the URL to download the server running the world.
#
# @param 1 The world server.
# @return SERVER_URL
# ---------------------------------------------------------------------------
getServerURL() {
local SERVER_URL
# Get the server download URL, use the default value if not provided.
SERVER_URL=$(
getPropertiesValue "$1" "mscs-server-url" "$DEFAULT_SERVER_URL" |
$PERL -ne '
$current_version="'$CURRENT_VERSION'";
$server_version="'$(getServerVersion "$1")'";
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
$_ =~ s/\$SERVER_VERSION/$server_version/g;
$_ =~ s/\\\:/\:/g;
print;
'
)
echo "$SERVER_URL"
}
# ---------------------------------------------------------------------------
# Retrieve the command to start the server running the world.
#
# @param 1 The world server.
# @return SERVER_COMMAND
# ---------------------------------------------------------------------------
getServerCommand() {
local SERVER_ARGS INITIAL_MEMORY MAXIMUM_MEMORY SERVER_COMMAND
# Get the server arguments, use the default value if not provided.
SERVER_ARGS=$(
getPropertiesValue "$1" "mscs-server-args" "$DEFAULT_SERVER_ARGS"
)
# Get the initial memory, use the default value if not provided.
INITIAL_MEMORY=$(
getPropertiesValue "$1" "mscs-initial-memory" "$DEFAULT_INITIAL_MEMORY"
)
# Get the maximum memory, use the default value if not provided.
MAXIMUM_MEMORY=$(
getPropertiesValue "$1" "mscs-maximum-memory" "$DEFAULT_MAXIMUM_MEMORY"
)
# Get the server command, use the default value if not provided.
SERVER_COMMAND=$(
getPropertiesValue "$1" "mscs-server-command" "$DEFAULT_SERVER_COMMAND" |
$PERL -ne '
$java = "'$JAVA'";
$current_version = "'$CURRENT_VERSION'";
$server_version = "'$(getServerVersion "$1")'";
$server_jar = "'$(getServerJar "$1")'";
$server_location = "'$(getServerLocation "$1")'";
$server_args = "'$SERVER_ARGS'";
$initial_memory = "'$INITIAL_MEMORY'";
$maximum_memory = "'$MAXIMUM_MEMORY'";
$_ =~ s/\$JAVA/$java/g;
$_ =~ s/\$CURRENT_VERSION/$current_version/g;
$_ =~ s/\$SERVER_VERSION/$server_version/g;
$_ =~ s/\$SERVER_JAR/$server_jar/g;
$_ =~ s/\$SERVER_LOCATION/$server_location/g;
$_ =~ s/\$SERVER_ARGS/$server_args/g;
$_ =~ s/\$INITIAL_MEMORY/$initial_memory/g;
$_ =~ s/\$MAXIMUM_MEMORY/$maximum_memory/g;
print;
'
)
echo "$SERVER_COMMAND"
}
# ---------------------------------------------------------------------------
# Send a message to the desktop using lib-notify, if it is available.
#
@ -714,7 +962,7 @@ start() {
# Start the server.
execute "
tail -f --pid=\$$ $WORLD_DIR/console.in | {
$SERVER_COMMAND mscs-world=$1 > /dev/null 2>&1 && kill \$$;
$(getServerCommand $1) mscs-world=$1 > /dev/null 2>&1 && kill \$$;
}
" $USER_NAME &
# Verify the server is running.
@ -803,12 +1051,18 @@ worldBackup() {
# ---------------------------------------------------------------------------
# Update the Minecraft client software.
#
# @param 1 The world to update.
# ---------------------------------------------------------------------------
updateClientSoftware() {
local CLIENT_JAR CLIENT_LOCATION CLIENT_URL
CLIENT_JAR=$(getClientJar "$1")
CLIENT_LOCATION=$(getClientLocation "$1")
CLIENT_URL=$(getClientURL "$1")
# Make sure the client software directory exists.
execute "mkdir -p $CLIENT_LOCATION" $USER_NAME
# Download the Minecraft client software.
if [ ! -e "$CLIENT_LOCATION/$CLIENT_JAR" ]; then
# Download the Minecraft client software.
execute "$WGET -qO \"$CLIENT_LOCATION/$CLIENT_JAR\" \"$CLIENT_URL\"" $USER_NAME
# Report any errors.
if [ $? -ne 0 ]; then
@ -824,9 +1078,14 @@ updateClientSoftware() {
# @param 1 The world server to update.
# ---------------------------------------------------------------------------
updateServerSoftware() {
local SERVER_JAR SERVER_LOCATION SERVER_URL
SERVER_JAR=$(getServerJar "$1")
SERVER_LOCATION=$(getServerLocation "$1")
SERVER_URL=$(getServerURL "$1")
# Make sure the server software directory exists.
execute "mkdir -p $SERVER_LOCATION" $USER_NAME
if [ ! -e "$SERVER_LOCATION/$SERVER_JAR" ]; then
# Download the new minecraft server software.
# Download the Minecraft server software.
execute "$WGET -qO \"$SERVER_LOCATION/$SERVER_JAR\" \"$SERVER_URL\"" $USER_NAME
# Report any errors.
if [ $? -ne 0 ]; then
@ -846,7 +1105,7 @@ overviewer() {
# Make sure the maps directory exists.
execute "mkdir -p $MAPS_LOCATION/$1" $USER_NAME
# Make sure the Minecraft client is available.
updateClientSoftware
updateClientSoftware "$1"
# Make sure that the world files are actually there before mapping.
if [ -e "$WORLDS_LOCATION/$1/server.properties" ]; then
# Check for Overviewer settings file.