2022-11-01 15:23:03 -07:00
|
|
|
#!/bin/bash
|
|
|
|
# Get list of configured servers
|
|
|
|
# One server per line, includes router
|
2023-03-27 09:27:46 -07:00
|
|
|
SERVERS="$(docker-compose -f /home/joey/homelab/jafner-net/config/minecraft/docker-compose.yml config --services)"
|
2022-11-01 15:23:03 -07:00
|
|
|
|
|
|
|
# exporter-minecraft: Create comma-separated list for EXPORT_SERVERS
|
|
|
|
EXPORT_SERVERS=""
|
|
|
|
for server in $SERVERS
|
|
|
|
do
|
|
|
|
if [ $server != "router" ]
|
|
|
|
then EXPORT_SERVERS="${EXPORT_SERVERS}${EXPORT_SERVERS:+,}$server"
|
|
|
|
fi
|
|
|
|
done
|
2023-03-27 09:27:46 -07:00
|
|
|
echo "EXPORT_SERVERS=\"$EXPORT_SERVERS\"" > /home/joey/homelab/jafner-net/config/monitoring/exporter-minecraft.env
|
2022-11-01 15:23:03 -07:00
|
|
|
|
|
|
|
# router: Create valid and correct mapping command for mc-router
|
|
|
|
# example: command: --mapping=vanilla.jafner.net=vanilla:25565,e9.jafner.net=e9:25565,fan.jafner.net=fan:25565,vanilla2.jafner.net=vanilla2:25565,bmcp.jafner.net=bmcp:25565 --api-binding=0.0.0.0:25566
|
|
|
|
MAPPINGS=""
|
|
|
|
|
|
|
|
for server in $SERVERS
|
|
|
|
do
|
|
|
|
#MAPPING="$server.jafner.net=$server:25565"
|
|
|
|
#echo $MAPPING
|
|
|
|
if [ $server != "router" ]
|
2022-11-08 19:43:04 -08:00
|
|
|
then MAPPINGS="${MAPPINGS}${MAPPINGS:+,}$server.jafner.net=$server:25565"
|
2022-11-01 15:23:03 -07:00
|
|
|
fi
|
|
|
|
done
|
|
|
|
|
|
|
|
#COMMAND="command: --mapping=$MAPPINGS --api-binding=0.0.0.0:25566"
|
2023-03-27 09:27:46 -07:00
|
|
|
sed -i "s/--mapping=[^ ]\+/--mapping=$MAPPINGS/m" /home/joey/homelab/jafner-net/config/minecraft/docker-compose.yml
|