aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Kočí <cynerd@email.cz>2015-11-07 16:03:52 +0100
committerKarel Kočí <cynerd@email.cz>2015-11-07 16:03:52 +0100
commit9e2636ae5da397ea69d521f2b2036cee3e428754 (patch)
treee06b91369e162fd2e8fbab8960cfe4512294cfb5
parenta3fb3236cdb6b8c9359f0706e00c8f2e9cb1b467 (diff)
downloadmcserver-wrapper-9e2636ae5da397ea69d521f2b2036cee3e428754.tar.gz
mcserver-wrapper-9e2636ae5da397ea69d521f2b2036cee3e428754.tar.bz2
mcserver-wrapper-9e2636ae5da397ea69d521f2b2036cee3e428754.zip
Update README.md
Also server configuration variable folder renamed to more precise directory.
-rw-r--r--README.md89
-rw-r--r--example.conf2
-rwxr-xr-xmcwrapper11
3 files changed, 71 insertions, 31 deletions
diff --git a/README.md b/README.md
index a6d147d..38bbe09 100644
--- a/README.md
+++ b/README.md
@@ -12,20 +12,32 @@ Requires:
Usage
-----------------
```
-mcwrapper ACTION {IDENTIFIER} [args...]
- This script is executing Minecraft server and reads its output. From output is extracted server
- status and list of online players.
-
- ACTION
- start Starts server specified with IDENTIFIER. As arguments takes command line for starting
- Minecraft server.
- stop Sends stop command to Minecraf server specified with IDENTIFIER.
- say Sends arguments to server chat as server message. Server is specified using IDENTIFIER.
-
- IDENTIFIER
- Identifier can be any word without spaces and preferably without special characters.
- It is used for identifying server instances, so that multiple servers can run with
- this wrapper on single system.
+mcwrapper [arguments...] ACTION ...
+ This script is executing Minecraft server and reads its output. From output is
+ extracted server status and list of online players.
+
+ arguments
+ -h, --help
+ Prints this help text.
+ -v, --verbose
+ Increase verbose level of output.
+ -q, --quiet
+ Decrease verbose level of output.
+
+ Common action arguments
+ IDENTIFIER
+ Identifier for new server instance. This allows multiple server
+ instances running with this wrapper.
+ Identifier is word without spaces and preferably without special
+ characters.
+
+ ACTION and it's arguments
+ start INDETIFIER
+ Start server under "IDENTIFIER"
+ stop IDENTIFIER
+ Sends stop command to server under "IDENTIFIER"
+ say IDENTIFIER {message...}
+ Sends message to server chat
```
How it works
@@ -33,12 +45,11 @@ How it works
Script is reading Minercraft server standard and error output. It's looking for
known lines that signals change of server output and players joining and leaving.
Minecraft server output is well designed for information parsing. Informations are
-in default exported to folder /dev/shm/mcwrapper_IDENTIFIER where IDENTIFIER is
-specified as argument to script. From now on will be replaced with *.
+in exported to directory specified in configuration as `status`.
###Status file
-This file is in default configuration in path `/dev/shm/mcwrapper_*/status`.
-If it exists, it contains in what status is server in the moment.
+This file is in status directory named as `status`. If it exists, it specifies in
+what status is server in the moment.
Status can be:
* Starting
* Running
@@ -47,12 +58,40 @@ Status can be:
If file not exists, then server is not running at all.
###Players file
-This file in in default configuration in path `/dev/shm/mcwrapper_*/players` If
-server is running, it constains online players. Player name per line. If server
-isn't runnint, it content don't have to be valid.
+This file in in status directory named as `players`. If server is running, it
+contains online players. Player name per line. If server isn't running, it
+content don't have to be valid.
##Input pipe
-This is unit pipe. In default configuration is in path
-`/dev/shm/mcwrapper_*/input_pipe`. This pipe is input to Minercraft server
-standard input. If you have write access rights (default 640), then you can send
-any command to Minecraft server by writing to this pipe.
+This is unix pipe. This file is located in status directory and named as
+`input_pipe`. This pipe is input to Minercraft server standard input. If you have
+write access rights (default 640), then you can send any command to Minecraft
+server by writing to this pipe.
+
+Configuration
+-----------------
+You can use `example.conf` as base configuration. Configuration file is in fact
+Python3 script that is executed and its variables are used as configuration.
+Script is searching for configuration in these files (in order of precedence):
+ * mcwrapper.conf
+ * mcwrapper.conf
+ * ~/.mcwrapper.conf
+ * ~/.config/mcwrapper.conf
+ * /etc/mcwrapper.conf
+
+### identifier
+This option is string defining identifier of server. If this option is define, no
+IDENTIFIER argument is expected on command line. If you have only one server, use
+this to make command line commands shorter.
+
+### server
+This variable is expected to be of type dictionary and contains configurations per
+server. See example.conf for example. Options for servers are these:
+#### directory
+Defines directory where will be server executed. This way you can start server from
+any directory and it will always start server in right one.
+#### command
+Defines command to start Minecraft server in `directory`.
+#### status
+Defines directory in which will be placed all status files generated by this
+wrapper.
diff --git a/example.conf b/example.conf
index 8edfc6c..6b8cf8f 100644
--- a/example.conf
+++ b/example.conf
@@ -6,7 +6,7 @@ identifier = 'exampleserver'
server = dict()
server["exampleserver"] = {
- "folder": '~/minecraft',
+ "directory": '~/minecraft',
"command": "java -jar mcs.jar nogui",
"status": '/dev/shm/mcwrapper-exampleserver',
}
diff --git a/mcwrapper b/mcwrapper
index 5235a8e..dd6faee 100755
--- a/mcwrapper
+++ b/mcwrapper
@@ -181,9 +181,9 @@ def mcexec():
if type(conf.command) != str:
conf.command = ' '.join(conf.command)
if conf.verbose_level >= 1:
- print("Folder: " + conf.folder)
+ print("Folder: " + conf.directory)
print("Start command: " + conf.command)
- os.chdir(conf.folder)
+ os.chdir(conf.directory)
prc = subprocess.Popen(conf.command, stdin=subprocess.PIPE,
stdout=subprocess.PIPE, stderr=subprocess.STDOUT, shell=True)
inputThread = __InputThread__(prc.stdin)
@@ -204,7 +204,8 @@ def __signal_term__(_signo, _stack_frame):
def print_help():
print('mcwrapper [arguments...] ACTION ...')
- print(' This script is executing Minecraft server and reads its output.')
+ print(' This script is executing Minecraft server and reads its output. From output is')
+ print(' extracted server status and list of online players.')
print('')
print(' arguments')
print(' -h, --help')
@@ -288,9 +289,9 @@ if __name__ == '__main__':
sys.exit('Error: No configuration associated with identifier: ' + conf.identifier)
# Set configurations for server
try:
- conf.folder
+ conf.directory
except AttributeError:
- sys.exit('Missing "folder" config')
+ sys.exit('Missing "directory" config')
try:
conf.command
except AttributeError: