serverlist-validate.sh 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/bash
  2. echo "Checking that all the game servers are listed in all csv files"
  3. echo "this check will ensure serverlist.csv has the same number of lines (-2 lines) as the other csv files"
  4. # count the number of lines in the serverlist.csv
  5. cd "${datadir}" || exit
  6. serverlistcount="$(tail -n +2 serverlist.csv | wc -l)"
  7. echo "serverlistcount: $serverlistcount"
  8. # get list of all csv files starting with ubunutu debian centos
  9. csvlist="$(ls -1 | grep -E '^(ubuntu|debian|centos|rhel|almalinux|rocky).*\.csv$')"
  10. # loop though each csv file and make sure the number of lines is the same as the serverlistcount
  11. for csv in $csvlist; do
  12. csvcount="$(wc -l < "${csv}")"
  13. csvcount=$((csvcount - 2))
  14. if [ "$csvcount" -ne "$serverlistcount" ]; then
  15. echo "ERROR: $csv ($csvcount) does not match serverlist.csv ($serverlistcount)"
  16. exitcode=1
  17. else
  18. echo "OK: $csv ($csvcount) and serverlist.csv ($serverlistcount) match"
  19. fi
  20. done
  21. # Compare all game servers listed in serverlist.csv to $shortname-icon.png files in ${datadir}/gameicons
  22. # if the game server is listed in serverlist.csv then it will have a $shortname-icon.png file
  23. # loop though shortname in serverlist.csv
  24. echo ""
  25. echo "Checking that all the game servers listed in serverlist.csv have a shortname-icon.png file"
  26. for shortname in $(tail -n +2 serverlist.csv | cut -d ',' -f1); do
  27. # check if $shortname-icon.png exists
  28. if [ ! -f "gameicons/${shortname}-icon.png" ]; then
  29. echo "ERROR: gameicons/${shortname}-icon.png does not exist"
  30. exitcode=1
  31. else
  32. echo "OK: gameicons/${shortname}-icon.png exists"
  33. fi
  34. done
  35. exit ${exitcode}