1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
|
MINECRAFT-WRAPPER
=================
Python server wrapper for extracting informations about server status and list of
online players.
Requires:
-----------------
* Unix-like OS (preferred an only tested is Linux)
* Python3
* Dependencies for Minecraft server (Java)
Usage
-----------------
```
mcwrapper [arguments...] IDENTIFIER
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.
IDENTIFIER
Identifier for new server. This allows multiple servers running with this
wrapper. Identifier is word without spaces and preferably without special
characters.
```
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 exported to directory specified in configuration as `status`.
###Status file
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
* Stopping
If file not exists, then server is not running at all.
###Players file
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 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.
### timeout
Numerical value, specifying time in minutes after which will be server
automatically shutdown if no player is on server. If value is less or equal zero,
automatic shutdown is disabled. If value is not specified in configuration file, 0
is used.
|