diff --git a/msm b/msm index de334b0..bb02cef 100755 --- a/msm +++ b/msm @@ -14,10 +14,48 @@ source "msm.config" +WHITELIST="white-list.txt" +BANNED_IPS="banned-ips.txt" +BANNED_PLAYERS="banned-players.txt" + # See http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit for # more information on debain init.d scripts, which may help you understand # this script. +### Utility Functions + +# Esecutes the command "$1" as SERVER_USER +as_user() { + if [ $(whoami) == $SERVER_USER ] ; then + bash -c "$1" + else + su - $SERVER_USER -s /bin/bash -c "$1" + fi +} + +manager_create_server() { + local regex="[a-zA-Z0-9\-_]+" + + if [[ $1 =~ $regex ]]; then + if [[ -e ${SERVER_STORAGE_PATH}/$1 ]]; then + echo "A server with that name already exists." + exit 1 + else + printf "Creating server directory... " + as_user "mkdir -p ${SERVER_STORAGE_PATH}/$1" + as_user "touch $SERVER_STORAGE_PATH/$1/$WHITELIST" + as_user "touch $SERVER_STORAGE_PATH/$1/$BANNED_IPS" + as_user "touch $SERVER_STORAGE_PATH/$1/$BANNED_PLAYERS" + echo "Done." + fi + else + echo -e "Invalid name: may only contain letters, numbers, a dash or an underscore." + fi +} + + +### Script Options + case "$1" in start) # Required start option, for debian init.d scripts @@ -30,6 +68,8 @@ case "$1" in ;; create) # Create a new server + manager_create_server $2 + ;; delete) # Delete an existing server, with confirmation diff --git a/msm.config b/msm.config index 22c8c01..985ae73 100644 --- a/msm.config +++ b/msm.config @@ -1,19 +1,19 @@ #!/bin/bash # User which manages all servers -SERVER_USER="minecraft" +SERVER_USER="marcus" # A base path to use in the rest of this config file (if you choose) STORAGE_PATH="/opt/msm" # Where new servers are stored -SERVERS_PATH="${STORAGE_PATH}/servers" +SERVER_STORAGE_PATH="${STORAGE_PATH}/servers" # Where RAM enambled worlds are stored -RAMDISK_PATH="" +RAMDISK_STORAGE_PATH="" # Where runnable jar files for use by servers are stored -JAR_PATH="${STORAGE_PATH}/jars" +JAR_STORAGE_PATH="${STORAGE_PATH}/jars" # Where "WorldEdit snapshot" compatible world backups are stored WORLD_ARCHIVE_PATH="${STORAGE_PATH}/archives/worlds"