diff --git a/bash_completion/msm b/bash_completion/msm index 362fb47..ba91f31 100644 --- a/bash_completion/msm +++ b/bash_completion/msm @@ -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) @@ -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 @@ -259,4 +264,4 @@ _msm() { return 0 } -complete -F _msm msm \ No newline at end of file +complete -F _msm msm diff --git a/init/msm b/init/msm index 0d5bcf4..9185bd4 100755 --- a/init/msm +++ b/init/msm @@ -1981,6 +1981,25 @@ command_server_console() { fi } +# Sets a parameter in the config file if it exists, otherwise inserts the +# paramerter. +# $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 @@ -2752,7 +2771,7 @@ main() { register_command " cmd " "command_server_cmd" register_command " cmdlog " "command_server_cmdlog" register_command " console" "command_server_console" - + register_command " config " "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. diff --git a/msm.conf b/msm.conf index ef16cd1..cf151df 100644 --- a/msm.conf +++ b/msm.conf @@ -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" @@ -220,4 +221,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: .+" \ No newline at end of file +DEFAULT_CONFIRM_XP_FAIL_INVALID_AMOUNT="Invalid exp count: .+" +