Merge pull request #135 from MinecraftServerControl/mscs.defaults.v5

New format for defaults file v5
This commit is contained in:
Jason M. Wood 2016-06-23 10:51:33 -06:00 committed by GitHub
commit 0cefa4d601
5 changed files with 360 additions and 112 deletions

View File

@ -8,6 +8,8 @@ MSCS_INIT_D := /etc/init.d/mscs
MSCS_SERVICE := /etc/systemd/system/mscs.service
MSCS_COMPLETION := /etc/bash_completion.d/mscs
UPDATE_D := $(wildcard update.d/*)
.PHONY: install update clean
install: $(MSCS_HOME) update
@ -27,6 +29,9 @@ update:
if which systemctl; then \
cp mscs.service $(MSCS_SERVICE); \
fi
@for script in $(UPDATE_D); do \
sh $$script; \
done; true;
clean:
if which systemctl; then \

151
README.md
View File

@ -16,11 +16,11 @@
* [Creating a new world](#creating-a-new-world)
* [Importing an existing world](#importing-an-existing-world)
* [Renaming world folder](#renaming-world-folder)
* [Adjusting global server properties](#adjusting-global-server-properties)
* [Default global server properties](#default-global-server-properties)
* [Adjusting world properties](#adjusting-world-properties)
* [Default world properties](#default-world-properties)
* [Enabling Forge, BungeeCord, and other server software](#enabling-forge-bungeecord-and-other-server-software)
* [Adjusting global server options](#adjusting-global-server-settings)
* [Configuring MSCS for multiple users](#configuring-mscs-for-multiple-users)
* [Scheduling backups and other tasks](#scheduling-backups-and-other-tasks)
* [Scheduling backups](#scheduling-backups)
* [Removing backups after X days](#removing-backups-after-x-days)
@ -180,8 +180,9 @@ At first, you probably want to [create a new world](#creating-a-new-world) or
Then, you might want to adjust the
[world properties](#adjusting-world-properties), adjust the
[global server settings](#adjusting-global-server-settings), and enable any other
[server software](#enabling-forge-bungeecord-and-other-server-software) as needed.
[global server properties](#adjusting-global-server-properties), and enable any
other [server software](#enabling-forge-bungeecord-and-other-server-software)
as needed.
### Creating a new world
The command to create a new world is:
@ -258,12 +259,106 @@ that you wish the world to use:
mscs create vanillaMC 25565
### Adjusting global server properties
Default values in the script can be overridden by adding certain properties to one
of the `mscs.defaults` files. The `mscs.defaults` files can be found found in one
of three places depending on how the script is being used. When using the `mscs`
script, the `mscs.defaults` file can be found at `/opt/mscs/mscs.defaults`. When
using the `msctl` script in [multi-user mode](https://github.com/MinecraftServerControl/mscs/wiki/Configuring-MSCS-for-multiple-users), the `mscs.defaults` file can be found at either `$HOME/mscs.defaults` or `$HOME/.config/mscs/mscs.defaults`.
For more information on the various properties, see the [wiki page](https://github.com/MinecraftServerControl/mscs/wiki/Global-Server-Settings).
The following properties are available:
* mscs-location - Location of the mscs files.
* mscs-worlds-location - Location of world files.
* mscs-versions-url - URL to download the version_manifest.json file.
* mscs-versions-json - Location of the version_manifest.json file.
* mscs-versions-duration - Length in minutes to keep the version_manifest.json file before updating.
* mscs-detailed-listing - Properties to return for detailed listings.
* mscs-default-world - Default world name.
* mscs-default-port - Default Port.
* mscs-default-ip - Default IP address.
* mscs-default-version-type - Default version type (release or snapshot).
* mscs-default-client-version - Default version of the client software.
* mscs-default-client-jar - Default .jar file for the client software.
* mscs-default-client-url - Default download URL for the client software.
* mscs-default-client-location - Default location of the client .jar file.
* mscs-default-server-version - Default version of the server software.
* mscs-default-server-jar - Default .jar file for the server software.
* mscs-default-server-url - Default download URL for the server software.
* mscs-default-server-args - Default arguments to for a world server.
* mscs-default-initial-memory - Default initial amount of memory for a world server.
* mscs-default-maximum-memory - Default maximum amount of memory for a world server.
* mscs-default-server-location - Default location of the server .jar file.
* mscs-default-server-command - Default command to run for a world server.
* mscs-backup-location - Location to store backup files.
* mscs-backup-log - Lcation of the backup log file.
* mscs-backup-duration - Length in days that backups survive.
* mscs-log-duration - Length in days that logs survive.
* mscs-enable-mirror - Enable the mirror option by default for worlds (default disabled).
* mscs-mirror-path - Default path for the mirror files.
* mscs-overviewer-bin - Location of Overviewer.
* mscs-overviewer-url - URL for Overviewer.
* mscs-maps-location - Location of Overviewer generated map files.
* mscs-maps-url - URL for accessing Overviewer generated maps.
The following variables may be used in some of the above properties:
* $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.
#### Default global server properties
Below are the default global server properties. You can add one, none, or all
of the properties below to one of the `mscs.defaults` files and adjust it to
your liking.
mscs-location=/opt/mscs
mscs-worlds-location=/opt/mscs/worlds
mscs-versions-url=https://launchermeta.mojang.com/mc/game/version_manifest.json
mscs-versions-json=/opt/mscs/version_manifest.json
mscs-versions-duration=1440
mscs-default-world=world
mscs-default-port=25565
mscs-default-ip=
mscs-default-version-type=release
mscs-default-client-version=$CURRENT_VERSION
mscs-default-client-jar=$CLIENT_VERSION.jar
mscs-default-client-url=https://s3.amazonaws.com/Minecraft.Download/versions/$CLIENT_VERSION/$CLIENT_VERSION.jar
mscs-default-client-location=/opt/mscs/.minecraft/versions/$CLIENT_VERSION
mscs-default-server-version=$CURRENT_VERSION
mscs-default-server-jar=minecraft_server.$SERVER_VERSION.jar
mscs-default-server-url=https://s3.amazonaws.com/Minecraft.Download/versions/$SERVER_VERSION/minecraft_server.$SERVER_VERSION.jar
mscs-default-server-args=nogui
mscs-default-initial-memory=128M
mscs-default-maximum-memory=2048M
mscs-default-server-location=/opt/mscs/server
mscs-default-server-command=$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS
mscs-backup-location=/opt/mscs/backups
mscs-backup-log=/opt/mscs/backups/backup.log
mscs-backup-duration=15
mscs-log-duration=15
mscs-detailed-listing=motd server-ip server-port max-players level-type online-mode
mscs-enable-mirror=0
mscs-mirror-path=/dev/shm/mscs
mscs-overviewer-bin=/usr/bin/overviewer.py
mscs-overviewer-url=http://overviewer.org
mscs-maps-location=/opt/mscs/maps
mscs-maps-url=http://minecraft.server.com/maps
### Adjusting world properties
The `mscs.properties` file can be found in every world folder
(for instance, if you had a world called `myWorld`, the path would be
`/opt/mscs/worlds/myWorld/mscs.properties`).
This file allows you to adjust many different properties for each world
you have. By default, the file only has one line in it: `mscs-enabled=true`.
Each world server can override the default values in a similar manner by
adding certain properties to the world's `mscs.properties` file. The
`mscs.properties` file can be found in every world folder (for instance, if
you had a world called `myWorld`, the path would be
`/opt/mscs/worlds/myWorld/mscs.properties`). This file allows you to adjust
many different properties for each world you have. By default, the file only
has one line in it: `mscs-enabled=true`.
The following properties are available:
* mscs-enabled - Enable the world server (true or false).
@ -316,26 +411,6 @@ liking.
Please visit the [wiki](https://github.com/MinecraftServerControl/mscs/wiki/Server-Customization-Examples)
for additional information.
### Adjusting global server settings
In tandem with the `mscs.properties` file--which handles options for
individual worlds--is the `mscs` file, which handles global server settings.
This file, like the `mscs.properties` file, has default settings already
built-in to MSCS. However, you can also customize it to your liking:
**To customize the properties, you must create this file.** To create this
file:
touch /etc/default/mscs
Once you've created the file, you need to populate it with a list of
properties. The list of properties can be found [here](https://github.com/MinecraftServerControl/mscs/wiki/Global-Server-Settings).
### Configuring MSCS for multiple users
MSCS has the capability to store server data for individual users, ideal for
those who have multiple users on a computer and want each user's data to be
separated. Please see the [wiki page](https://github.com/MinecraftServerControl/mscs/wiki/Configuring-MSCS-for-multiple-users)
for instructions.
## Scheduling backups and other tasks
All MSCS tasks can be automated using [**cron**]
(https://en.wikipedia.org/wiki/Cron), a scheduler software that can run
@ -374,9 +449,9 @@ for more information.
The backups will be saved in `/opt/mscs/backups`.
### Removing backups after X days
You can specify how long to keep backups by changing the `BACKUP_DURATION`
in the `mscs.conf` or `mscs` file (see
[adjusting global server settings](#adjusting-global-server-settings)
You can specify how long to keep backups by changing the
`mscs-backup-duration` property in the `mscs.defaults` file (see
[adjusting global server properties](#adjusting-global-server-properties)
).
### Scheduling restarts
@ -402,13 +477,13 @@ worlds).
Minecraft Server Control Script uses [Overviewer]
(http://docs.overviewer.org/en/latest/) to generate maps. After [installing]
(#mapping-software), modify the settings (if necessary) found in the
`mscs.conf` or `mscs` file (see [adjusting global server settings]
(#adjusting-global-server-settings)):
`mscs.defaults` file (see [adjusting global server properties]
(#adjusting-global-server-properties)):
OVERVIEWER_BIN=$(which overviewer.py)
OVERVIEWER_URL="http://overviewer.org"
MAPS_URL="my.minecraftserver.com"
MAPS_LOCATION="$LOCATION/maps"
mscs-overviewer-bin=/usr/bin/overviewer.py
mscs-overviewer-url=http://overviewer.org
mscs-maps-location=/opt/mscs/maps
mscs-maps-url=my.minecraftserver.com
After you've tinkered the settings to your liking, run:

16
mscs
View File

@ -15,21 +15,17 @@
# Get executable name
PROG=$(basename $0)
# Load the mscs default file if it exists.
MSCS_DEFAULTS="/etc/default/mscs"
if [ -r $MSCS_DEFAULTS ]; then
. $MSCS_DEFAULTS
MSCS_ARGS="-c $MSCS_DEFAULTS "
fi
# Setup the default user name.
USER_NAME=${USER_NAME:-minecraft}
USER_NAME="minecraft"
# Setup the default installation location.
LOCATION=${LOCATION:-"/opt/mscs"}
LOCATION="/opt/mscs"
# Setup the default location of the mscs.defaults file.
MSCS_DEFAULTS="$LOCATION/mscs.defaults"
# Setup the arguments to the msctl script.
MSCS_ARGS="-p $PROG -l $LOCATION $MSCS_ARGS $@"
MSCS_ARGS="-p $PROG -l $LOCATION -c $MSCS_DEFAULTS $@"
# Run the msctl script.
if [ "$USER_NAME" = "$(whoami)" ]; then

215
msctl
View File

@ -403,12 +403,20 @@ getValue() {
if [ -e "$1" ]; then
# Find the key/value combo.
KEY=$($PERL -ne '
$_ =~ s/[\x22\x27\r]//;
if ($_ =~ /^('$2')=.*$/i) { print lc $1; }
# Remove single and double quotes plus CR and LF.
$_ =~ s/[\x22\x27\r\n]//g;
# Remove comments.
$_ =~ s/^\s*\x23.*//;
# Extract the key.
if ($_ =~ /^\s*('$2')\s*=\s*.*$/i) { print lc $1; }
' $1)
VALUE=$($PERL -ne '
$_ =~ s/[\x22\x27\r]//;
if ($_ =~ /^'$2'=(.*)$/i) { print $1; }
# Remove single and double quotes plus CR and LF.
$_ =~ s/[\x22\x27\r\n]//g;
# Remove comments.
$_ =~ s/^\s*\x23.*//;
# Extract the value.
if ($_ =~ /^\s*'$2'\s*=\s*(.*)$/i) { print $1; }
' $1)
fi
# Return the value if found, the default value if not.
@ -446,6 +454,16 @@ setValue() {
fi
}
# ---------------------------------------------------------------------------
# Get the value of a key in the mscs.defaults file.
#
# @param 1 The key to get.
# @param 2 The default value.
# ---------------------------------------------------------------------------
getDefaultsValue() {
getValue "$MSCS_DEFAULTS" "$1" "$2"
}
# ---------------------------------------------------------------------------
# Get the value of the EULA boolean.
#
@ -1660,31 +1678,108 @@ while [ "$1" != "${1#-}" ]; do
shift
done
# Override Global Variables
# Override Default Values
# ---------------------------------------------------------------------------
# Override global variables below by adding them to the specified file. If
# the file does not exist, the default values below will be used.
# Configuration files are checked in the following order. First file found is
# sourced and the rest are discarded:
# Override the default values by adding them to one of the following files. If
# none of the files exist, the default values in the script will be used (see
# below). Possible files are checked in the following order:
# command line option "-c".
# $HOME/mscs.conf
# $HOME/.config/mscs/mscs.conf
if [ -r "$MSCS_DEFAULTS_CL" ]; then
# $HOME/mscs.defaults
# $HOME/.config/mscs/mscs.defaults
if [ -n "$MSCS_DEFAULTS_CL" ]; then
MSCS_DEFAULTS="$MSCS_DEFAULTS_CL"
elif [ -r "$HOME/mscs.conf" ]; then
MSCS_DEFAULTS="$HOME/mscs.conf"
elif [ -r "$HOME/.config/mscs/mscs.conf" ]; then
MSCS_DEFAULTS="$HOME/.config/mscs/mscs.conf"
elif [ -r "$HOME/mscs.defaults" ]; then
MSCS_DEFAULTS="$HOME/mscs.defaults"
elif [ -r "$HOME/.config/mscs/mscs.defaults" ]; then
MSCS_DEFAULTS="$HOME/.config/mscs/mscs.defaults"
fi
# Default values in the script can be overridden by adding certain key/value
# pairs to one of the mscs.defaults files mentioned above. Default values in
# the script will be used unless overridden in one these files.
#
# The following keys are available:
# mscs-location - Location of the mscs files.
# mscs-worlds-location - Location of world files.
# mscs-versions-url - URL to download the version_manifest.json file.
# mscs-versions-json - Location of the version_manifest.json file.
# mscs-versions-duration - Duration (in minutes) to keep the version_manifest.json file before updating.
# mscs-detailed-listing - Properties to return for detailed listings.
# mscs-default-world - Default world name.
# mscs-default-port - Default Port.
# mscs-default-ip - Default IP address.
# mscs-default-version-type - Default version type (release or snapshot).
# mscs-default-client-version - Default version of the client software.
# mscs-default-client-jar - Default .jar file for the client software.
# mscs-default-client-url - Default download URL for the client software.
# mscs-default-client-location - Default location of the client .jar file.
# mscs-default-server-version - Default version of the server software.
# mscs-default-server-jar - Default .jar file for the server software.
# mscs-default-server-url - Default download URL for the server software.
# mscs-default-server-args - Default arguments to for a world server.
# mscs-default-initial-memory - Default initial amount of memory for a world server.
# mscs-default-maximum-memory - Default maximum amount of memory for a world server.
# mscs-default-server-location - Default location of the server .jar file.
# mscs-default-server-command - Default command to run for a world server.
# mscs-backup-location - Location to store backup files.
# mscs-backup-log - Lcation of the backup log file.
# mscs-backup-duration - Length in days that backups survive.
# mscs-log-duration - Length in days that logs survive.
# mscs-enable-mirror - Enable the mirror option by default for worlds (default disabled).
# mscs-mirror-path - Default path for the mirror files.
# mscs-overviewer-bin - Location of Overviewer.
# mscs-overviewer-url - URL for Overviewer.
# mscs-maps-location - Location of Overviewer generated map files.
# mscs-maps-url - URL for accessing Overviewer generated maps.
#
# The following variables may be used in some of the key values:
# $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-location=/opt/mscs
# mscs-worlds-location=/opt/mscs/worlds
# mscs-versions-url=https://launchermeta.mojang.com/mc/game/version_manifest.json
# mscs-versions-json=/opt/mscs/version_manifest.json
# mscs-versions-duration=1440
# mscs-default-world=world
# mscs-default-port=25565
# mscs-default-ip=
# mscs-default-version-type=release
# mscs-default-client-version=$CURRENT_VERSION
# mscs-default-client-jar=$CLIENT_VERSION.jar
# mscs-default-client-url=https://s3.amazonaws.com/Minecraft.Download/versions/$CLIENT_VERSION/$CLIENT_VERSION.jar
# mscs-default-client-location=/opt/mscs/.minecraft/versions/$CLIENT_VERSION
# mscs-default-server-version=$CURRENT_VERSION
# mscs-default-server-jar=minecraft_server.$SERVER_VERSION.jar
# mscs-default-server-url=https://s3.amazonaws.com/Minecraft.Download/versions/$SERVER_VERSION/minecraft_server.$SERVER_VERSION.jar
# mscs-default-server-args=nogui
# mscs-default-initial-memory=128M
# mscs-default-maximum-memory=2048M
# mscs-default-server-location=/opt/mscs/server
# mscs-default-server-command=$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS
# mscs-backup-location=/opt/mscs/backups
# mscs-backup-log=/opt/mscs/backups/backup.log
# mscs-backup-duration=15
# mscs-log-duration=15
# mscs-detailed-listing=motd server-ip server-port max-players level-type online-mode
# mscs-enable-mirror=0
# mscs-mirror-path=/dev/shm/mscs
# mscs-overviewer-bin=/usr/bin/overviewer.py
# mscs-overviewer-url=http://overviewer.org
# mscs-maps-location=/opt/mscs/maps
# mscs-maps-url=http://minecraft.server.com/maps
# Server Location
# ---------------------------------------------------------------------------
# The default location of server software and data.
LOCATION="$HOME/mscs"
# Override the default values if the default file exists.
[ -r "$MSCS_DEFAULTS" ] && . "$MSCS_DEFAULTS"
LOCATION=$(getDefaultsValue 'mscs-location' $HOME'/mscs')
# Override with command-line location option.
[ -n "$LOCATION_CL" ] && LOCATION="$LOCATION_CL"
@ -1693,29 +1788,29 @@ LOCATION="$HOME/mscs"
# Minecraft Versions information
# ---------------------------------------------------------------------------
MINECRAFT_VERSIONS_URL=https://launchermeta.mojang.com/mc/game/version_manifest.json
MINECRAFT_VERSIONS_URL=$(getDefaultsValue 'mscs-versions-url' 'https://launchermeta.mojang.com/mc/game/version_manifest.json')
# Minecraft Server Settings
# ---------------------------------------------------------------------------
# Default settings if not provided in the world's mscs.properties file.
DEFAULT_WORLD='world'
DEFAULT_PORT='25565'
DEFAULT_IP=''
DEFAULT_VERSION_TYPE='release'
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=$HOME'/.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'/server'
DEFAULT_SERVER_COMMAND='$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS'
# The server settings for each world can be customized by adding certain
# key/value pairs to the world's mscs.properties file.
# Settings used if not provided in the world's mscs.properties file.
DEFAULT_WORLD=$(getDefaultsValue 'mscs-default-world' 'world')
DEFAULT_PORT=$(getDefaultsValue 'mscs-default-port' '25565')
DEFAULT_IP=$(getDefaultsValue 'mscs-default-ip' '')
DEFAULT_VERSION_TYPE=$(getDefaultsValue 'mscs-default-version-type' 'release')
DEFAULT_CLIENT_VERSION=$(getDefaultsValue 'mscs-default-client-version' '$CURRENT_VERSION')
DEFAULT_CLIENT_JAR=$(getDefaultsValue 'mscs-default-client-jar' '$CLIENT_VERSION.jar')
DEFAULT_CLIENT_URL=$(getDefaultsValue 'mscs-default-client-url' 'https://s3.amazonaws.com/Minecraft.Download/versions/$CLIENT_VERSION/$CLIENT_VERSION.jar')
DEFAULT_CLIENT_LOCATION=$(getDefaultsValue 'mscs-default-client-location' $HOME'/.minecraft/versions/$CLIENT_VERSION')
DEFAULT_SERVER_VERSION=$(getDefaultsValue 'mscs-default-server-version' '$CURRENT_VERSION')
DEFAULT_SERVER_JAR=$(getDefaultsValue 'mscs-default-server-jar' 'minecraft_server.$SERVER_VERSION.jar')
DEFAULT_SERVER_URL=$(getDefaultsValue 'mscs-default-server-url' 'https://s3.amazonaws.com/Minecraft.Download/versions/$SERVER_VERSION/minecraft_server.$SERVER_VERSION.jar')
DEFAULT_SERVER_ARGS=$(getDefaultsValue 'mscs-default-server-args' 'nogui')
DEFAULT_INITIAL_MEMORY=$(getDefaultsValue 'mscs-default-initial-memory' '128M')
DEFAULT_MAXIMUM_MEMORY=$(getDefaultsValue 'mscs-default-maximum-memory' '2048M')
DEFAULT_SERVER_LOCATION=$(getDefaultsValue 'mscs-default-server-location' $LOCATION'/server')
DEFAULT_SERVER_COMMAND=$(getDefaultsValue 'mscs-default-server-command' '$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERVER_LOCATION/$SERVER_JAR $SERVER_ARGS')
# Each world server can override the default values in a similar manner by
# adding certain key/value pairs to the world's mscs.properties file.
#
# The following keys are available:
# mscs-enabled - Enable or disable the world server.
@ -1733,8 +1828,7 @@ DEFAULT_SERVER_COMMAND='$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERV
# 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:
# Like above, the following variables may be used in some of the key values:
# $JAVA - The Java virtual machine.
# $CURRENT_VERSION - The current Mojang Minecraft release version.
# $CLIENT_VERSION - The version of the client software.
@ -1764,30 +1858,30 @@ DEFAULT_SERVER_COMMAND='$JAVA -Xms$INITIAL_MEMORY -Xmx$MAXIMUM_MEMORY -jar $SERV
# World (Server Instance) Configuration
# ---------------------------------------------------------------------------
# The location to store files for each world server.
WORLDS_LOCATION="$LOCATION/worlds"
WORLDS_LOCATION=$(getDefaultsValue 'mscs-worlds-location' $LOCATION'/worlds')
# The location to store the version_manifest.json file.
VERSIONS_JSON="$DEFAULT_SERVER_LOCATION/version_manifest.json"
VERSIONS_JSON=$(getDefaultsValue 'mscs-versions-json' $LOCATION'/version_manifest.json')
# The duration (in minutes) to keep the version_manifest.json file before updating.
VERSIONS_DURATION=1440
VERSIONS_DURATION=$(getDefaultsValue 'mscs-versions-duration' '1440')
# Backup Configuration
# ---------------------------------------------------------------------------
# Location to store backups.
BACKUP_LOCATION="$LOCATION/backups"
BACKUP_LOCATION=$(getDefaultsValue 'mscs-backup-location' $LOCATION'/backups')
# Location of the backup log file.
BACKUP_LOG="$BACKUP_LOCATION/backup.log"
BACKUP_LOG=$(getDefaultsValue 'mscs-backup-log' $BACKUP_LOCATION'/backup.log')
# Length in days that backups survive.
BACKUP_DURATION=15
BACKUP_DURATION=$(getDefaultsValue 'mscs-backup-duration' '15')
# Server Log Configuration
# ---------------------------------------------------------------------------
# Length in days that logs survive.
LOG_DURATION=15
LOG_DURATION=$(getDefaultsValue 'mscs-log-duration' '15')
# Listing options
# ---------------------------------------------------------------------------
# Server properties for detailed listing (list).
DETAILED_LISTING_PROPERTIES="motd server-ip server-port max-players level-type online-mode"
DETAILED_LISTING_PROPERTIES=$(getDefaultsValue 'mscs-detailed-listing' 'motd server-ip server-port max-players level-type online-mode')
# Mirror Image Options
# ---------------------------------------------------------------------------
@ -1802,25 +1896,18 @@ DETAILED_LISTING_PROPERTIES="motd server-ip server-port max-players level-type o
#
# 0 - Do not use a mirror image, default.
# 1 - Use a mirror image.
ENABLE_MIRROR=0
ENABLE_MIRROR=$(getDefaultsValue 'mscs-enable-mirror' '0')
# The location to store the mirror image.
#
# NOTE: This is usually a ramdisk, e.g. /dev/shm on Debian/Ubuntu.
MIRROR_PATH="/dev/shm/mscs"
MIRROR_PATH=$(getDefaultsValue 'mscs-mirror-path' '/dev/shm/mscs')
# Minecraft Overviewer Mapping Software Options
# ---------------------------------------------------------------------------
OVERVIEWER_BIN=$(which overviewer.py)
OVERVIEWER_URL="http://overviewer.org"
MAPS_URL="http://minecraft.server.com/maps"
MAPS_LOCATION="$LOCATION/maps"
# Do additional overrides if the default file exists.
# Override the default values if the default file exists.
[ -r "$MSCS_DEFAULTS" ] && . "$MSCS_DEFAULTS"
# Override with command-line location option.
[ -n "$LOCATION_CL" ] && LOCATION="$LOCATION_CL"
OVERVIEWER_BIN=$(getDefaultsValue 'mscs-overviewer-bin' $(which overviewer.py))
OVERVIEWER_URL=$(getDefaultsValue 'mscs-overviewer-url' 'http://overviewer.org')
MAPS_LOCATION=$(getDefaultsValue 'mscs-maps-location' $LOCATION'/maps')
MAPS_URL=$(getDefaultsValue 'mscs-maps-url' 'http://minecraft.server.com/maps')
# Respond to the command line arguments.
# ---------------------------------------------------------------------------

85
update.d/10-old-defaults Normal file
View File

@ -0,0 +1,85 @@
#!/bin/sh
convert_defaults() {
printf "Converting defaults file: $1\n"
# Copy the old defaults file to the new location.
cp $1 $2
# Edit the defaults file in place at its new location.
perl -i -ne '
%mscs = (
"LOCATION" => "mscs-location",
"WORLDS_LOCATION" => "mscs-worlds-location",
"MINECRAFT_VERSIONS_URL" => "mscs-versions-url",
"VERSIONS_JSON" => "mscs-versions-json",
"VERSIONS_DURATION" => "mscs-versions-duration",
"DETAILED_LISTING_PROPERTIES" => "mscs-detailed-listing",
"DEFAULT_WORLD" => "mscs-default-world",
"DEFAULT_PORT" => "mscs-default-port",
"DEFAULT_IP" => "mscs-default-ip",
"DEFAULT_VERSION_TYPE" => "mscs-default-version-type",
"DEFAULT_CLIENT_VERSION" => "mscs-default-client-version",
"DEFAULT_CLIENT_JAR" => "mscs-default-client-jar",
"DEFAULT_CLIENT_URL" => "mscs-default-client-url",
"DEFAULT_CLIENT_LOCATION" => "mscs-default-client-location",
"DEFAULT_SERVER_VERSION" => "mscs-default-server-version",
"DEFAULT_SERVER_JAR" => "mscs-default-server-jar",
"DEFAULT_SERVER_URL" => "mscs-default-server-url",
"DEFAULT_SERVER_ARGS" => "mscs-default-server-args",
"DEFAULT_INITIAL_MEMORY" => "mscs-default-initial-memory",
"DEFAULT_MAXIMUM_MEMORY" => "mscs-default-maximum-memory",
"DEFAULT_SERVER_LOCATION" => "mscs-default-server-location",
"DEFAULT_SERVER_COMMAND" => "mscs-default-server-command",
"BACKUP_LOCATION" => "mscs-backup-location",
"BACKUP_LOG" => "mscs-backup-log",
"BACKUP_DURATION" => "mscs-backup-duration",
"LOG_DURATION" => "mscs-log-duration",
"ENABLE_MIRROR" => "mscs-enable-mirror",
"MIRROR_PATH" => "mscs-mirror-path",
"OVERVIEWER_BIN" => "mscs-overviewer-bin",
"OVERVIEWER_URL" => "mscs-overviewer-url",
"MAPS_LOCATION" => "mscs-maps-location",
"MAPS_URL" => "mscs-maps-url"
);
# Strip CR and LF.
$_ =~ s/[\r\n]//g;
# Look for recognized key/value sets and other patterns to convert the
# old defaults file to the new format.
if ($_ =~ /^\s*(\w+)\s*=\s*(.*)/) {
# Found a key/value set, test to see if it is one that can be converted.
if (defined $mscs{$1}) {
# Convert this key/value set.
print "$mscs{$1}=$2\n";
}
else {
# Turn this unrecognized key/value set into a comment.
print "\x23 $_\n";
}
}
elsif ($_ =~ /^\s*\x23/) {
# Found a comment, print the line as is.
print "$_\n";
}
elsif (length $_ > 0) {
# Turn this unrecognized line into a comment.
print "\x23 $_\n";
}
else {
# Line was blank.
print "\n"
}
' $2
# Add a comment to the new defaults file.
printf "# Automatically updated with old-defaults on %s\n%s\n" \
"$(date)" "$(cat $2)" > $2
# Remove the old defaults file.
rm $1
}
test -s /etc/default/mscs && \
convert_defaults /etc/default/mscs /opt/mscs/mscs.defaults
test -s ~/mscs.conf && \
convert_defaults ~/mscs.conf ~/mscs.defaults
test -s ~/.config/mscs/mscs.conf && \
convert_defaults ~/.config/mscs/mscs.conf ~/.config/mscs/mscs.defaults