serverlist-validate.sh 977 B

12345678910111213141516171819202122232425
  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. exit "${exitcode}"