serverlist-validate.sh 1.6 KB

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