Closed camalot closed 2 years ago
My workaround for this:
on the host machine i set up a chron job in /etc/cron.d/minecraft-whitelist-ops.job
NOTE: mc_user is an account on the host machine that has permission to the whitelist script
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/mnt/container_data/minecraft/curseforge/data/
MAILTO=root
*/5 * * * * mc_user whitelist.sh >> /dev/null 2>&1
I pull the whitelist and ops list, and if there are changes, I use rcon to reload the whitelist.
#!/bin/env bash
# data directory on the host
data_dir="/mnt/container_data/minecraft/curseforge/data"
# whitelist file on the host
whitelist_file=${data_dir}/whitelist.json
# ops file on the host
opslist_file=${data_dir}/ops.json
# get the md5 of the whitelist file
wl_md5=`md5sum ${whitelist_file} | awk '{ print $1 }'`
# get the md5 of the ops file
ops_md5=`md5sum ${opslist_file} | awk '{ print $1 }'`
# get the new whitelist file
curl -X GET -s \
--output ${whitelist_file} \
http://andeddu.local/minecraft/whitelist.json
# get the new ops file
curl -X GET -s \
--output ${opslist_file} \
http://andeddu.local/minecraft/ops.json
# get the new md5 of the whitelist file
new_wl_md5=`md5sum ${whitelist_file} | awk '{ print $1 }'`
# get the new md5 of the ops file
new_ops_md5=`md5sum ${opslist_file} | awk '{ print $1 }'`
# if the md5s don't match, then we need to update the whitelist
if [ "${wl_md5}" != "${new_wl_md5}" ] || [ "${ops_md5}" != "${new_ops_md5}" ] ; then
echo "Whitelist updated!"
docker run -v ${data_dir}:/data itzg/rcon-cli --config /data/.rcon-cli.yaml whitelist reload
else
echo "Whitelist unchanged."
fi
in the container i set up 2 simlinks on the filesystem:
ln -s /data/ops.json /data/FeedTheBeast/SIMPLE-SERVER-FILES-0.3.20/ops.json
ln -s /data/whitelist.json /data/FeedTheBeast/SIMPLE-SERVER-FILES-0.3.20/whitelist.json
This makes the server version of the files always be the /data/
version, and the cronjob keeps the files updated with any changes that come from the url.
The data from the url is populated via a database, but how ever you wanted to populate it would work. You could save your files on a github gist, for example and have it pull from that.
This issue is stale because it has been open 30 days with no activity. Please add a comment describing the reason to keep this issue open.
Describe the problem
If the
/data/ops.json
or/data/whitelist.json
already exists, andOPS_FILE
/WHITELIST_FILE
are URLS, they are not downloaded to replace the existing files.instead of a copy from
/data/ops.json
to the server directory, why not just use a symlink? example:ln -s /data/whitelist.json /data/FeedTheBeast/ServerFiles/whitelist.json
.Would also be great if there was a way to have it recheck the remote file periodically, so a server restart isn't required to update the whitelist. (this is probably an additional feature)
Container definition
Container logs
log output if the files exist:
log output if they do not already exist: