mirror of
https://github.com/msmhq/msm.git
synced 2024-08-30 18:12:35 +00:00
Sketched out the create command.
This commit is contained in:
40
msm
40
msm
@ -14,10 +14,48 @@
|
|||||||
|
|
||||||
source "msm.config"
|
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
|
# 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
|
# more information on debain init.d scripts, which may help you understand
|
||||||
# this script.
|
# 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
|
case "$1" in
|
||||||
start)
|
start)
|
||||||
# Required start option, for debian init.d scripts
|
# Required start option, for debian init.d scripts
|
||||||
@ -30,6 +68,8 @@ case "$1" in
|
|||||||
;;
|
;;
|
||||||
create)
|
create)
|
||||||
# Create a new server
|
# Create a new server
|
||||||
|
manager_create_server $2
|
||||||
|
|
||||||
;;
|
;;
|
||||||
delete)
|
delete)
|
||||||
# Delete an existing server, with confirmation
|
# Delete an existing server, with confirmation
|
||||||
|
@ -1,19 +1,19 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# User which manages all servers
|
# 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)
|
# A base path to use in the rest of this config file (if you choose)
|
||||||
STORAGE_PATH="/opt/msm"
|
STORAGE_PATH="/opt/msm"
|
||||||
|
|
||||||
# Where new servers are stored
|
# Where new servers are stored
|
||||||
SERVERS_PATH="${STORAGE_PATH}/servers"
|
SERVER_STORAGE_PATH="${STORAGE_PATH}/servers"
|
||||||
|
|
||||||
# Where RAM enambled worlds are stored
|
# Where RAM enambled worlds are stored
|
||||||
RAMDISK_PATH=""
|
RAMDISK_STORAGE_PATH=""
|
||||||
|
|
||||||
# Where runnable jar files for use by servers are stored
|
# 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
|
# Where "WorldEdit snapshot" compatible world backups are stored
|
||||||
WORLD_ARCHIVE_PATH="${STORAGE_PATH}/archives/worlds"
|
WORLD_ARCHIVE_PATH="${STORAGE_PATH}/archives/worlds"
|
||||||
|
Reference in New Issue
Block a user