mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-28 11:51:08 -04:00
Added support for setting basic options with environment variables.
This commit is contained in:
@ -33,6 +33,12 @@ Option:
|
|||||||
-v Output version information
|
-v Output version information
|
||||||
```
|
```
|
||||||
|
|
||||||
|
Server address, port and password can be set using following environment variables:
|
||||||
|
MCRCON_HOST
|
||||||
|
MCRCON_PORT
|
||||||
|
MCRCON_PASS
|
||||||
|
|
||||||
|
Command-line options will override environment variables.
|
||||||
Commands with arguments must be enclosed in quotes.
|
Commands with arguments must be enclosed in quotes.
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|||||||
12
mcrcon.1
12
mcrcon.1
@ -1,7 +1,7 @@
|
|||||||
.\" Process this file with
|
.\" Process this file with
|
||||||
.\" groff -man -Tascii mcrcon.1
|
.\" groff -man -Tascii mcrcon.1
|
||||||
.\"
|
.\"
|
||||||
.TH MCRCON 1 "November 2016" "Version 0.0.6"
|
.TH MCRCON 1 "December 2016" "Version 0.0.6"
|
||||||
.SH NAME
|
.SH NAME
|
||||||
mcrcon \- sends rcon commands to a Minecraft server
|
mcrcon \- sends rcon commands to a Minecraft server
|
||||||
.SH SYNOPSIS
|
.SH SYNOPSIS
|
||||||
@ -34,6 +34,16 @@ Output raw packets (for debugging and custom handling)
|
|||||||
Output version information
|
Output version information
|
||||||
.PP
|
.PP
|
||||||
Commands with arguments must be enclosed in quotes.
|
Commands with arguments must be enclosed in quotes.
|
||||||
|
.SH ENVIRONMENTAL VARIABLES
|
||||||
|
Server address, port and password can be set using following environment variables:
|
||||||
|
.PP
|
||||||
|
\fBMCRCON_HOST
|
||||||
|
.br
|
||||||
|
\fBMCRCON_PORT
|
||||||
|
.br
|
||||||
|
\fBMCRCOM_PASS\fR
|
||||||
|
.PP
|
||||||
|
Note that command-line options will override environment variables.
|
||||||
.SH EXAMPLES
|
.SH EXAMPLES
|
||||||
Make rcon connection in terminal mode using default port
|
Make rcon connection in terminal mode using default port
|
||||||
.RS
|
.RS
|
||||||
|
|||||||
20
mcrcon.c
20
mcrcon.c
@ -140,11 +140,14 @@ int main(int argc, char *argv[])
|
|||||||
int opt, ret = 0;
|
int opt, ret = 0;
|
||||||
int terminal_mode = 0;
|
int terminal_mode = 0;
|
||||||
|
|
||||||
char *host = NULL;
|
char *host = getenv("MCRCON_HOST");
|
||||||
char *pass = NULL;
|
char *pass = getenv("MCRCON_PASS");
|
||||||
char *port = "25575";
|
char *port = getenv("MCRCON_PORT");
|
||||||
|
|
||||||
if(argc < 2)
|
if (!port)
|
||||||
|
port = "25575";
|
||||||
|
|
||||||
|
if(argc < 2 && host == NULL && pass == NULL)
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
// default getopt error handler enabled
|
// default getopt error handler enabled
|
||||||
@ -247,11 +250,16 @@ void usage(void)
|
|||||||
" -s\t\tSilent mode (do not print received packets)\n"
|
" -s\t\tSilent mode (do not print received packets)\n"
|
||||||
" -c\t\tDisable colors\n"
|
" -c\t\tDisable colors\n"
|
||||||
" -r\t\tOutput raw packets (debugging and custom handling)\n"
|
" -r\t\tOutput raw packets (debugging and custom handling)\n"
|
||||||
" -v\t\tOutput version information\n"
|
" -v\t\tOutput version information\n\n"
|
||||||
|
"Server address, port and password can be set using following environment variables:\n"
|
||||||
|
" MCRCON_HOST\n"
|
||||||
|
" MCRCON_PORT\n"
|
||||||
|
" MCRCON_PASS\n\n"
|
||||||
,stdout
|
,stdout
|
||||||
);
|
);
|
||||||
|
|
||||||
puts("\nCommands with arguments must be enclosed in quotes.\n");
|
puts("Command-line options will override environment variables.");
|
||||||
|
puts("Rcon commands with arguments must be enclosed in quotes.\n");
|
||||||
puts("Example:\n\t"IN_NAME" -H my.minecraft.server -p password \"say Server is restarting!\" save-all stop\n");
|
puts("Example:\n\t"IN_NAME" -H my.minecraft.server -p password \"say Server is restarting!\" save-all stop\n");
|
||||||
puts(VER_STR"\nReport bugs to tiiffi_at_gmail_dot_com or https://github.com/Tiiffi/mcrcon/issues/\n");
|
puts(VER_STR"\nReport bugs to tiiffi_at_gmail_dot_com or https://github.com/Tiiffi/mcrcon/issues/\n");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user