Giter VIP home page Giter VIP logo

msm's Introduction

Minecraft Server Manager

A single init script which makes running multiple Minecraft/Bukkit servers easier for us admins.

Quick Installers

Install MSM on a debian box:

wget -q http://git.io/Sxpr9g -O /tmp/msm && bash /tmp/msm

Or install MSM under RedHat:

wget -q http://git.io/lu0ULA -O /tmp/msm && bash /tmp/msm

Or suggest a new platform.

Getting Started

  • Install MSM on your box.
  • Visit the docs for help with getting started.
  • Fork and contribute your own modifications.
  • Not a coder? Post an issue with your idea for MSM instead.
  • Read the changelog to get a picture of how MSM has evolved over time.

MSM is released under the GPLv3 licence, which is included in the repository here. I'm open to suggestions where licencing is concerned.

Features

As well as starting, stopping and restarting MSM has the following features:

  • One script handles multiple servers, run two or more servers on one machine.
  • Can create and start new servers with a single command, downloads the jars for you.
  • Periodically makes WorldEdit snapshot compatible backups of your worlds.
  • Backup the entire server directory for complete protection.
  • Load world's into RAM for faster access (reduces lag).
  • Easily configurable global defaults, with per server overrides if needed.
  • Apply server commands to one, multiple, or all servers in one go (useful for whitelisting a player on all servers.)
  • Tab completion for all commands, makes everything faster and getting started a breeze.
  • Keep server logs organsied by periodically "rolling" them.
  • Organises jar files into groups (such as minecraft and craftbukkit) and links each server to a single jar. Includes automated download of new versions.
  • Plethora of in-game commands (whitelist, blacklist, operator, gamemode, kick, say, time, toggledownfall, save)
  • Send commands straight to the server via the command line.

Support

  1. If you find a problem with MSM and you think the problem is one that requires changing code submit an issue via GitHub.

Upcoming features

  • QuickBackup: If you store your backups non-locally (maybe on a NAS), QuickBackup optionally creates a backup locally for speed, and then moves it after your players are building again! My initial testing shows a 54 second network backup confaltes to 23 seconds of in-game time.
  • Restore: Roll-back to an old world or whole server backup automatically.

Versioning

MSM uses semantic version numbers to better describe what code one might have installed, and indicate backwards incompatible changes.

Releases will be numbered in the following format:

<major>.<minor>.<patch>

And constructed with the following guidelines:

  • Breaking backward compatibility bumps the major (and resets the minor and patch)
  • New additions without breaking backward compatibility bumps the minor (and resets the patch)
  • Bug fixes and misc changes bumps the patch

For more information on SemVer, visit http://semver.org/.

Acknowledgements

This code grew out of an old version of Ahtenus' Minecraft Init Script.

msm's People

Contributors

brahmlower avatar cebarks avatar coosh avatar danaak avatar dbbnrl avatar dbergl avatar donkers avatar endofcake avatar fsmaxb avatar irontetsubo avatar johannesm avatar jvz avatar kadah avatar kbmorris avatar localstatic avatar m-d-m avatar morbeo avatar next-door-tech avatar nikush avatar pflueg avatar renderorange avatar stooj avatar tcyrus avatar tlindsay42 avatar touratica avatar troglogeek avatar x3rax avatar zachlatta avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

msm's Issues

oom issues when loading into /dev/shm

Hi Marcus,

I get really bad stability in my kernel when loading a map into the ram. I think my hacks have really messed this all up. I will need to start again. I havent had a chance to read the entire code, can you just let me know if there are any checks done prior to loading things into ram? How much data is normally loaded into the ram? I could debug all of this but thats a days work and I know you have the answer.

I got a feeling theres a bug in the way I set up the OS im using, first time on arch linux. Tempted to ditch the whole project of a Make script and start it again in Debian/RHEL. What distro are you developing this all on?

Cheers!
Simon

Idea: Combine server.conf with server.properties

It may be an improving idea to have all msm server level configuration–which currently resides in server.conf–just add to the functionality of server.properties. All variables could prefixed with "msm" to avoid confusion.

This could reduce the number of files in the server directory, and–from the code's point of view–combine the loading of msm server variables with regular Minecraft server properties since they would both be in one file which could be read easily.

It may be a bad idea when we realise Mojang could change how this works at any time, or specify some new property that might overwrite our own, or otherwise throw a spanner in the works.

Anyway just thought I'd create an issue to remember my thoughts on this point.

Improve new world creation location

Servers always create new worlds in the current directory according to the running jar. In MSM's case this is the server directory. The problem is we really want worlds to be in the worldstorage directory. We cannot change the behaviour of the server, but we can fool it.

Before starting a server MSM creates symbolic links in the server directory pointing to worlds in the worldstorage directory. If the world that the server is going to use exists in world storage, the link is made in the server directory, the server sees that link as the world and all is fine. If the world does not yet exist, there is no link and so the new world folder gets created in the wrong place.

The solution: By inspecting the server.properties file we can glean the name of the world a server is expecting to use, and before it starts create an empty folder in world storage with the same name. The link will then get created, and the server will still create the world files—in the correct place—via the dynamic link.

command_jargorup_delete

Hello,

In the /etc/init.d/msm file, on line 2491 jargroup is misspelled and therefore the jargroup delete command does not work, it gives the error. /usr/local/bin/msm: line 2491: command_jargorup_delete: command not found

Thanks,
bren

Worlds In RAM Problem?

On typing "msm worlds ram " the world isn't recognized or something of the sort,
Resulting in this.

msm oldauscraft worlds ram Survival
Adding RAM flag to world "Chaos"... Done.
Copying world to RAM... Done.

AND

msm oldauscraft worlds ram s
Removing RAM flag from world "Chaos"... Done.
Removing world "Chaos" from RAM... Done.

Every single world is changed to Chaos.
And so only one world can be put into and removed from the RAMDisk.

Using 0.5.1 Beta
If you need any configs reply here.

Support multiple Minecraft versions for log output

MSM watches server logs to determine when an action has been completed. What is logged for a particular action may change in future Minecraft versions, or may be different for Bukkit, or another bespoke server type.

Currently MSM keeps current with the latest Minecraft log style, which means each user would have to maintain a config for older versions, or not upgrade.

A solution may be to have a separate config file in MSM for each Minecraft version, and allow user to create and submit their own for inclusion in MSM.

Create a better distinction between global and other variables

Errors are sometimes introduced by shadowing global variables with typical names. This destroys values and is difficult—currently, without full test coverage—to detect.

A good solution would be to refactor all global variables to use capital letters.

"su: user does not exist" error when creating servers

When creating a server with the "msm server create" command on Arch Linux, I get a "user does not exist" error.

$ sudo msm server create minecraft
Creating server directory... Done.
Downloading latest version... Done.
Existing version "/opt/msm/jars/minecraft/2012-07-21-17-46-19-minecraft_server.jar" was already up to date.
su: user  does not exist
Server "minecraft" is now using "/opt/msm/jars/minecraft/2012-07-21-17-45-40-minecraft_server.jar".

Implement protection against non-existent server files

When listing whitelisted, blacklisted or operator players, it's easier to just display the contents of the files that store the names respectively. There is currently no check before cat-ing the contents, which could return a file not found string.

A check should be made before hand to determine whether to cat the file contents to a variable or not.

It is probably the case that the "file not found" output would go to stderr, and therefore leave the stdout as an empty string. However this implied feature is not very readable, and the code would benefit from a good obvious logic statement before hand.

init() bug - first found server path is empty

The server_path[0] is empty because the init script uses the local variable server_path.

Changing the 2 lines with the local var to server_path1 solves the issue:
while IFS= read -r -d $'\0' server_path1; do
local name=$(basename $server_path1)

Worlds in RAM can lose data in 1 contrived circumstance

I experienced a problem (not a bug) using Ahtenus' script that will also occur in MSM. The ultimate effect is the loss of world changes since the in RAM world was last synced back to disk.

The problem is syncing from RAM to disk only happens in two places: when msm <server> worlds to disk or msm <server> stop is called. In the event that the server is stopped in any other way the world will not be synced back to disk, and will be overridden by the disk version when starting the server again.

RAM-to-disk syncing needs to be more aggressive to protect against these edge cases. I suggest invoking to-disk syncing whenever the java process stops lilke:

java ... -jar server.jar ; rsync world_ram_path world_disk_path

This would always run, if someone entered the /sop in-game command–as I discovered the problem–or if the server crashed. It would not run however if the screen process was killed, but that would involve busy waiting for the process to die.


Ultimately we need to know on start up which version of a world is the latest. This can be inferred to some degree, but a "latest" flag in the RAM or disk version would make things certain. Or it could be deduced from modified times if rsync effects those.

Note: the latest flag does not avoid the need to sync to disk when a server stops, since a host crash would cause data loss the to RAM version.

Improve server starting output

Currently the server output when starting is Starting... and then Done. when finished.

There is a whole host of things that might go wrong, and if any do the output will just hang on Starting....

A good improvement would be to output information for each stage involved in starting up, and then output errors when something goes awry.

Processes left running when stopping server

When I stop a server, I still get two processes running from the script, but it has terminated:

xxxxx@supermicro:~/test$ msm bukkit stop
Issued the warning "SERVER SHUTTING DOWN IN 10 SECONDS!" to players.
Shutting down... Now.
Forcing save... Done.
Stopping the server... Done.
Synchronising worlds in RAM to disk... Done.
xxxxx@supermicro:~/test$ ps aux
...
xxxxx   16385  0.0  0.0  11420  1524 pts/3    S    09:09   0:00 /bin/bash /usr/local/bin/msm bukkit stop
xxxxx   16388  0.0  0.0   5396   660 pts/3    S    09:09   0:00 tail --follow --lines=100 --sleep-interval=0.1 /opt/msm/servers/bukkit/server.log
...

Not yet found the cause for this. Any hints?

Vulnerable to similar screen sessions

As seen in issue #23 (specifically this comment) MSM fails to stop servers when multiple screen sessions are found matching the expected name. Guards must be put in place to gracefully deal with this problem or eliminate it.

A solution may be to append salt data to the screen name on each start up, save that to file and check it subsequently. Or just be damn sure a screen session is dead when stopping servers.

DEFAULT_SERVER_CONF is not set

DEFAULT_SERVER_CONF is not set for the bash_completion file. It is set in the init file though. It should either be in the msm.conf which the bash_completion file sources or the bash_completion file itself

Every command lists all servers

I just updated to 0.3.1 beta. Now every time I run a command from MSM, it lists all the servers seen by MSM. Example:

root@box:~# msm server list
server: survival
server: creative
creative
survival
root@box:~# msm creative status
server: survival
server: creative
Server "creative" is running.
root@box:~# msm survival status
server: survival
server: creative
Server "survival" is running.
root@box:~# msm help
server: survival
server: creative
Usage: /usr/local/bin/msm command:

--Setup Commands------------------------------------------------
  server list                                   List servers
  server create <name>                          Creates a new Minecraft server
. . .
. . .

msm all worlds todisk

Using the name 'all' for selecting all servers does not work, which means that the cron jobs fails as they are using "msm all ..."

global stop command hangs, server doesn't stop

When issuing the global stop command, "msm stop" the command hangs at "Ensuring server "server" has stopped..." In-game, the server shut-down warning is issued however the server does not shut down.

Improve command user enforcement

As highlighted in issue #23 commands seem to be performing less than satisfactorily when an inappropriate user calls it. Commands continue to execute but fail at each stage.

Less granular checking is necessary, in other words each command should check the user before doing anything.

Use logrotate instead of custom script

Why don't you use logrotate for rolling over logs?
It's directly built into debian and supports restarting services and loads of other stuff.
You don't even need a cronjob, single file in /etc/logrotate.d and you're done.
It has loads of config options.

Create server and set jargroup do not create jar symlinks

Problem

Commands using server_set_jar() like msm server create <server-name> or msm <server-name> jar minecraft
throw an su error (user does not exist) and will not generate symlinks to the latest jar-file in the jargroup(s).

Cause

Wrong variable name used in https://github.com/marcuswhybrow/minecraft-server-manager/blob/master/init/msm#L1019; used ${SERVER_USER[$1]} but should be ${SERVER_USER_NAME[$1]}, therefore su gets passed a blank username if the defaults from msm.conf are used.

Fix

Change ${SERVER_USER[$1]} to ${SERVER_USER_NAME[$1]} in line 1019 of /init/msm

Add zip to the requirements

I noticed that my backups were failing, which was the result of my not having zip installed. It may be a good idea to add it to the list of requirements, just to reduce any confusion.

World Backup

When using the command: msm all worlds backup or a server specific alternative: msm worlds backup the script fails to backup the world files to the specified directory configured using WORLD_ARCHIVE_PATH.

The zip command is functioning as log and full server backup functionality are working.

Also returning the config variable to its default value of /opt/msm/archives/worlds appears not to work either.

The server was set up using the very useful installation guide.

Stop/restart commands hang when using snapshot 12w27a

When using the most recent snapshot (12w27a) using the stop or restart command hangs waiting for the server to stop. I suspect this is because when the server stop the log message is different but am not sure.

Creating new server?

I don't understand/ it doesn't work.

Does this script install the server.jar or do I get it myself? And if I do get it myself where exactly do I put it? It would be great for this script to be specific when something doesn't go as planned. There aren't even any errors as to why my server isn't even starting.

Right now its just stuck at "Starting server"

I'm trying to run a server from scratch, so I use the create new server command. The script didn't install the minecraft_server.jar so I went ahead and installed it myself. I threw it in the jar folder and still nothing. Nothing happens. The documentation doesn't really help either....

Connected user names randomly truncated

When I run the command to list all online players for a server, sometimes they are randomly truncated. Recent example:

root@box:~# msm survival connected
server: survival
server: creative
Kekembas17, Delvanix, Neotanger

"Neotanger" should be "Neotangerine". I've also seen it truncate other users--mainly "Kekembas17" there.

I'm currently using 0.3.1 beta, but this has also occurred with previous version 0.2.15 before I upgraded.

Also, the two server listings are related to issue #32 that I just posted.

Thanks!

use insserv

In the installation documentation you use update-rc.d to create the rc.d links.
Because of dependency based booting in debian squeeze insserv should be used instead.
link

Sometimes symlinks are not created for worlds

Needs exploration, but in the case I observed all three worlds were in worldstorage, and world and world_nether were linked correctly. world_the_end would not get a link created for it.

Server World Backup

Forgive me if this is a stupid question, but I'm not entirely clear on the world backup functionality.

I've read the installation wiki page and I'm a bit confused with the comment about the "worldstorage" folder. I've also read issue #26 regarding the problem with where world data is stored, but as far as I can tell there is no "worldstorage" folder anywhere in my setup. Furthermore, I see that the cron job is running the scheduled backup command at 5:02AM, but nothing is being backed up when it happens (ie - I see no world files in the archives--just logs).

Otherwise, the script is running great! Thanks for all your work! : )

touch: cannot touch `': No such file or directory

When starting any server the following is output:

touch: cannot touch `': No such file or directory
Maintaining world symbolic links... Done.
Starting server... 

I believe $SERVER_FLAG_ACTIVE is undefined in the server_set_active function but I've no idea where to define it?

Also, possibly related to the above issue, the output finishes with Starting server.... If I hit CTRL+C and check the server log the server has started normally but msm doesn't seem to recognise that it did.

cron problems

how do i get the cron to work with centos. I managed to get this to start a server but I cannot get it to backup or anything. I used the install guide.

Script does not handle Worlds with spaces

When world contains spaces, it randomly creates directories/not working when starting the server.
Not sure if i got all the places in this diff:

diff msm024 /etc/init.d/msm 
161c161
<       as_user ${server_user_name[${world_server_id[$1]}]} "mkdir -p ${world_ramdisk_path[$1]} && rsync -rt --exclude '$WORLD_FLAG_INRAM' \"${world_path[$1]}/\" \"${world_ramdisk_path[$1]}\""

---
>       as_user ${server_user_name[${world_server_id[$1]}]} "mkdir -p \"${world_ramdisk_path[$1]}\" && rsync -rt --exclude '$WORLD_FLAG_INRAM' \"${world_path[$1]}/\" \"${world_ramdisk_path[$1]}\""
378c378
<           if ${world_inram[$i]} && [ -L ${world_link[$i]} ]; then

---
>           if ${world_inram[$i]} && [ -L "${world_link[$i]}" ]; then
398c398
<           if [ -e ${world_ramdisk_path[$i]} ]; then

---
>           if [ -e "${world_ramdisk_path[$i]}" ]; then
1395,1396c1395,1396
<           local name=$(basename $path)
<           server_world_init $1 $id $name

---
>           local name=$(basename "$path")
>           server_world_init $1 $id "$name"
1413,1414c1413,1414
<           local name=$(basename $path)
<           server_world_init $1 $id $name

---
>           local name=$(basename "$path")
>           server_world_init $1 $id "$name"
1509c1509
<       local name=$(basename $path)

---
>       local name=$(basename "$path")

Implement Helpful Error Messages

Provide better error messages other than "Invalid command." when a user gets a command mostly correct save an argument or some such.

Typo in save_all

Line 1273 has a typo... (confrim)

CONFIRM_SAVE_ALL) server_confrim_save_all[$1]="$value";;

Auto adjust RAM

Instead of hardcoding Xms and Xmx to 1024M you could do some autodetection like this

# Total memory
memory_kb=`awk '/MemTotal/{print $2}' /proc/meminfo`

# Calculate minimum memory
memory_min=$(($memory_kb/100*30))
# Calculate maximum memory
memory_max=$(($memory_kb/100*80))

java -jar -Xms${memory_min}K -Xmx${memory_max}K ....

It's good practice not to set min and max to the same, this way more than one minecraft server can run. The can change their size in RAM depending on how many players there are in each world.
If only one world is played it can use all the RAM it wants.

The minimum should be adjusted to the number of worlds running. With 4 worlds for example, it should be 20% (=80% of RAM).
With 6 worlds and 20% the server would start to swap, so it should be 13%.

Installation document throws error during server creation

# msm server create server1
Creating server directory... Done.
Downloading latest version... wget: unrecognized option `--trust-server-names'
Usage: wget [OPTION]... [URL]...

Try `wget --help' for more options.
Done.
Failed. No files were downloaded.`

I updated my wget version to the latest with the same issue. This is on my cloud server running Centos 5

Remove log line end characters once, not many times

When getting a line from the server log, it ends with three invisible characters which can throw a spanner in the works when it comes to string matching.

The code should be refactored to do this all the time, and not just when necessary after a call to the relevant function.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.