#!/bin/sh
# PES6 online (servidor PES6.es): Wine resuelve nombres con el /etc/hosts de Linux, no con el de la botella,
# y Batocera regenera /etc/hosts en cada arranque (S26system). Se reescriben las entradas al lanzar PES6.
# IP tomada del fichero hosts oficial de pes6.es/downloads (2026-10-01).
[ "$1" = "gameStart" ] || exit 0
[ "$2" = "windows" ] || exit 0
[ "$5" = "/userdata/roms/windows/Pes6.pc" ] || exit 0
IP=46.101.172.11
for h in pes6gate-ec.winning-eleven.net we9stun.winning-eleven.net; do
  sed -i "/[[:space:]]$h\([[:space:]]\|\$\)/d" /etc/hosts
  printf '%s\t%s\n' "$IP" "$h" >> /etc/hosts
done
echo "$(date) hosts PES6.es -> $IP" >> /userdata/system/logs/pes6-online.log
