Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Modify/Add server.properties with server shutdown forced #46

Merged
merged 2 commits into from
Jul 11, 2012
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 7 additions & 2 deletions bash_completion/msm
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ _msm() {
__init_server "${COMP_WORDS[1]}"

if [[ $COMP_CWORD == 2 ]]; then
options="start stop restart status connected worlds logroll backup jar whitelist blacklist operator gamemode kick say time toggledownfall give xp save cmd cmdlog console"
options="start stop restart status connected worlds logroll backup jar whitelist blacklist operator gamemode kick say time toggledownfall give xp save cmd cmdlog console config"
else
case "${COMP_WORDS[2]}" in
stop|restart)
Expand Down Expand Up @@ -247,6 +247,11 @@ _msm() {
options="on off all"
fi
;;
config)
if [[ $COMP_CWORD == 3 ]]; then
options="$(more $SERVER_CONF | sed 's/=.*$//' | grep -v '#')";
fi
;;
esac

fi
Expand All @@ -259,4 +264,4 @@ _msm() {
return 0
}

complete -F _msm msm
complete -F _msm msm
26 changes: 24 additions & 2 deletions init/msm
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ CONF="${MSM_CONF:-/etc/msm.conf}"


### The Minecraft Server Manager version, use "msm version" to check yours.
VERSION="0.4.0"
VERSION="0.4.w0"


### Config variables the user should not need/want to change
Expand Down Expand Up @@ -1980,6 +1980,28 @@ command_server_console() {
fi
}

# Sets a parameter in the config file if it exists otherwise inserts the
# paramerter.
# if the server is running it will do a restart to ensure the parameter is
# loaded
# $1: The server ID
# $2: The parameter
# $3: The value to set it to
command_set_config() {
if server_is_running "$1"; then
echo "Server is running, please stop the server before running this command: sudo msm "${SERVER_NAME[$1]}" stop"
else
if [[ -f "${SERVER_CONF[$1]}" ]]; then
if grep "$2" ${SERVER_CONF[$1]} >/dev/null; then
sed -i /$2=/s/.*/"$2=$3"/g ${SERVER_CONF[$1]}
else
echo "$2=$3" >> ${SERVER_CONF[$1]}
fi
echo "To see these changes please restart this server with: sudo msm "${SERVER_NAME[$1]}" start";
fi

fi
}

### Main Functions

Expand Down Expand Up @@ -2742,7 +2764,7 @@ main() {
register_command "<name:server> cmd <strings>" "command_server_cmd"
register_command "<name:server> cmdlog <strings>" "command_server_cmdlog"
register_command "<name:server> console" "command_server_console"

register_command "<name:server> config <string> <string>" "command_set_config"
# This function call matches the user input to a registered command
# signature, and then calls that commands handler function with positional
# arguments containing any variable strings.
Expand Down
4 changes: 3 additions & 1 deletion msm.conf
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ USERNAME="minecraft"

# Where new servers are stored
SERVER_STORAGE_PATH="/opt/msm/servers"
DEFAULT_SERVER_CONF="server.properties"

# Where runnable jar files for use by servers are stored
JAR_STORAGE_PATH="/opt/msm/jars"
Expand Down Expand Up @@ -218,4 +219,5 @@ DEFAULT_CONFIRM_XP="CONSOLE: Giving .+ exp to .+"
DEFAULT_CONFIRM_XP_FAIL_NO_USER="Can't find user .+"

# The message logged when the experience amount given is an invalid format
DEFAULT_CONFIRM_XP_FAIL_INVALID_AMOUNT="Invalid exp count: .+"
DEFAULT_CONFIRM_XP_FAIL_INVALID_AMOUNT="Invalid exp count: .+"