2222: " ${SERVER_PORT:= 25565} "
2323: " ${RCON_HOST:= localhost} "
2424: " ${RCON_PORT:= 25575} "
25- : " ${RCON_PASSWORD_FILE:= } "
26- : " ${RCON_PASSWORD:= minecraft} "
25+
26+ if ! [[ -v RCON_PASSWORD ]] && ! [[ -v RCON_PASSWORD_FILE ]] && [[ -f " ${SRC_DIR} /.rcon-cli.env" ]]; then
27+ . " ${SRC_DIR} /.rcon-cli.env"
28+ # shellcheck disable=SC2154
29+ # since it comes from rcon-cli
30+ RCON_PASSWORD=" $password "
31+ elif [[ -v RCON_PASSWORD_FILE ]]; then
32+ if [ ! -e " ${RCON_PASSWORD_FILE} " ]; then
33+ log ERROR " Initial RCON password file ${RCON_PASSWORD_FILE} does not seems to exist."
34+ log ERROR " Please ensure your configuration."
35+ log ERROR " If you are using Docker Secrets feature, please check this for further information: "
36+ log ERROR " https://docs.docker.com/engine/swarm/secrets"
37+ exit 1
38+ else
39+ RCON_PASSWORD=$( cat " ${RCON_PASSWORD_FILE} " )
40+ fi
41+ elif ! [[ -v RCON_PASSWORD ]]; then
42+ # Legacy default
43+ RCON_PASSWORD=minecraft
44+ fi
45+ export RCON_PASSWORD
46+
2747: " ${RCON_RETRIES:= 5} "
2848: " ${RCON_RETRY_INTERVAL:= 10s} "
2949: " ${EXCLUDES:=* .jar,cache,logs} " # Comma separated list of glob(3) patterns
@@ -49,7 +69,6 @@ export TZ
4969
5070export RCON_HOST
5171export RCON_PORT
52- export RCON_PASSWORD
5372export XDG_CONFIG_HOME
5473export SRC_DIR
5574export DEST_DIR
@@ -383,25 +402,6 @@ rclone() {
383402# # main ##
384403# #########
385404
386- if [[ $RCON_PASSWORD_FILE ]]; then
387- if [ ! -e ${RCON_PASSWORD_FILE} ]; then
388- log ERROR " Initial RCON password file ${RCON_PASSWORD_FILE} does not seems to exist."
389- log ERROR " Please ensure your configuration."
390- log ERROR " If you are using Docker Secrets feature, please check this for further information: "
391- log ERROR " https://docs.docker.com/engine/swarm/secrets"
392- exit 1
393- else
394- RCON_PASSWORD=$( cat ${RCON_PASSWORD_FILE} )
395- export RCON_PASSWORD
396- fi
397- fi
398-
399- if [[ $PRE_SAVE_ALL_SCRIPT ]]; then
400- PRE_SAVE_ALL_SCRIPT_FILE=/tmp/pre-save-all
401- printf ' #!/bin/bash\n\n%s' " $PRE_SAVE_ALL_SCRIPT " > " $PRE_SAVE_ALL_SCRIPT_FILE "
402- chmod 700 " $PRE_SAVE_ALL_SCRIPT_FILE "
403- fi
404-
405405if [[ $PRE_BACKUP_SCRIPT ]]; then
406406 PRE_BACKUP_SCRIPT_FILE=/tmp/pre-backup
407407 printf ' #!/bin/bash\n\n%s' " $PRE_BACKUP_SCRIPT " > " $PRE_BACKUP_SCRIPT_FILE "
0 commit comments