serverlist-validate.sh 939 B

12345678910111213141516171819202122
  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 "lgsm/data" || 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. exit ${exitcode}