22
22
: " ${SERVER_PORT:= 25565} "
23
23
: " ${RCON_HOST:= localhost} "
24
24
: " ${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
+
27
47
: " ${RCON_RETRIES:= 5} "
28
48
: " ${RCON_RETRY_INTERVAL:= 10s} "
29
49
: " ${EXCLUDES:=* .jar,cache,logs} " # Comma separated list of glob(3) patterns
@@ -49,7 +69,6 @@ export TZ
49
69
50
70
export RCON_HOST
51
71
export RCON_PORT
52
- export RCON_PASSWORD
53
72
export XDG_CONFIG_HOME
54
73
export SRC_DIR
55
74
export DEST_DIR
@@ -383,25 +402,6 @@ rclone() {
383
402
# # main ##
384
403
# #########
385
404
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
-
405
405
if [[ $PRE_BACKUP_SCRIPT ]]; then
406
406
PRE_BACKUP_SCRIPT_FILE=/tmp/pre-backup
407
407
printf ' #!/bin/bash\n\n%s' " $PRE_BACKUP_SCRIPT " > " $PRE_BACKUP_SCRIPT_FILE "
0 commit comments