Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,10 @@ Typically, a cronjob for *MinecraftStats* will look like this:
*/10 * * * * cd /path/to/mcstats ; python3 update.py config.json
```

#### Mirroring Remote Files

An example script is available in the `contrib` directory to sync the required files from a remote or hosted Minecraft server using the FTP protocol.

#### Windows

If you're using Windows to run your server... figure something out! There's probably some task scheduler available that you can use.
Expand Down
1 change: 1 addition & 0 deletions contrib/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*.config
12 changes: 12 additions & 0 deletions contrib/ftpsync.config.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# Location of MinecraftStats webroot
WEBROOT=/var/www/MinecraftStats

# Target destination for synched files from Minecraft server
MIRRORPATH=/var/minecraft/serverroot

# Minecraft server "level-name" in server.properties (usually "world")
LEVELNAME='world'

FTPHOST=ftp.example.com
FTPUSER=username
FTPPASS=password
28 changes: 28 additions & 0 deletions contrib/ftpsync.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#!/bin/sh

# This script will pull the necessary stats files from a remote or hosted
# Minecraft server using ftp and mirror them locally so that the MinecraftStats
# script can successfully run.
#
# This script requires the `lftp` utility which is almost certainly available
# in your OS package repository. This tool will only transfer new or changed
# files, making it very efficient and fast on subsequent runs.
#
# Edit the config values in the `ftpsync.config` file and then run this
# script.

. "$(dirname -- "$0")/ftpsync.config" || exit 1

# Sync files group and world readable so that the web server can view them
umask 022

# Create the mirror path if it doesn't already exist
mkdir -p "$MIRRORPATH" || exit 1

# Sync the files from the Minecraft Server
cd "$MIRRORPATH"
lftp -u $FTPUSER,$FTPPASS $FTPHOST -e "mirror -r -I ops.json -I usercache.json -I server.properties -I banned-players.json -I server-icon.png . .; mirror -r $LEVELNAME/stats $LEVELNAME/; mirror -r $LEVELNAME/advancements $LEVELNAME/; bye"

# Run MinecraftStats
cd "$WEBROOT"
python3 update.py config.json