mirror of
https://github.com/Tiiffi/mcrcon.git
synced 2025-10-27 11:21:07 -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
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
Example:
|
||||
|
||||
12
mcrcon.1
12
mcrcon.1
@ -1,7 +1,7 @@
|
||||
.\" Process this file with
|
||||
.\" 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
|
||||
mcrcon \- sends rcon commands to a Minecraft server
|
||||
.SH SYNOPSIS
|
||||
@ -34,6 +34,16 @@ Output raw packets (for debugging and custom handling)
|
||||
Output version information
|
||||
.PP
|
||||
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
|
||||
Make rcon connection in terminal mode using default port
|
||||
.RS
|
||||
|
||||
20
mcrcon.c
20
mcrcon.c
@ -140,11 +140,14 @@ int main(int argc, char *argv[])
|
||||
int opt, ret = 0;
|
||||
int terminal_mode = 0;
|
||||
|
||||
char *host = NULL;
|
||||
char *pass = NULL;
|
||||
char *port = "25575";
|
||||
char *host = getenv("MCRCON_HOST");
|
||||
char *pass = getenv("MCRCON_PASS");
|
||||
char *port = getenv("MCRCON_PORT");
|
||||
|
||||
if (!port)
|
||||
port = "25575";
|
||||
|
||||
if(argc < 2)
|
||||
if(argc < 2 && host == NULL && pass == NULL)
|
||||
usage();
|
||||
|
||||
// default getopt error handler enabled
|
||||
@ -247,11 +250,16 @@ void usage(void)
|
||||
" -s\t\tSilent mode (do not print received packets)\n"
|
||||
" -c\t\tDisable colors\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
|
||||
);
|
||||
|
||||
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(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