Browse Source
Fixes and improves server list validation scripts
Addresses issues in the server list validation scripts:
- Fixes potential issues with parsing curl custom arguments in telegram alerts.
- Corrects the shortname array generation.
- Implements more robust checks for validating game icons.
- Ensures the consistency of server counts across different CSV files.
pull/4854/head
Daniel Gibbs
4 months ago
Failed to extract signature
4 changed files with
27 additions and
12 deletions
.github/workflows/details-check-generate-matrix.sh
.github/workflows/serverlist-validate-game-icons.sh
.github/workflows/serverlist-validate.sh
lgsm/modules/alert_telegram.sh
@ -14,10 +14,12 @@ while read -r line; do
export gamename
distro = $( echo " $line " | awk -F, '{ print $4 }' )
export distro
echo -n "{" >> "shortnamearray.json"
echo -n "\"shortname\":" >> "shortnamearray.json"
echo -n " \" ${ shortname } \" " >> "shortnamearray.json"
echo -n "}," >> "shortnamearray.json"
{
echo -n "{" ;
echo -n "\"shortname\":" ;
echo -n " \" ${ shortname } \" " ;
echo -n "}," ;
} >> "shortnamearray.json"
done < <( tail -n +2 serverlist.csv)
sed -i '$ s/.$//' "shortnamearray.json"
echo -n "]" >> "shortnamearray.json"
@ -2,6 +2,8 @@
cd " ${ datadir } " || exit
exitcode = 0
echo ""
echo "Checking that all the game servers listed in serverlist.csv have a shortname-icon.png file"
for shortname in $( tail -n +2 serverlist.csv | cut -d ',' -f1) ; do
@ -16,9 +18,11 @@ done
echo ""
echo "Checking if an unexpected gameicon exists"
for gameicon in $( ls -1 gameicons) ; do
shopt -s nullglob
for gameiconpath in gameicons/*; do
gameicon = " $( basename " ${ gameiconpath } " ) "
# check if $gameicon is in serverlist.csv
if ! grep -q " ${ gameicon %-icon.png } " serverlist.csv; then
if ! grep -q -F " ${ gameicon %-icon.png } " serverlist.csv; then
echo " ERROR: gameicon ${ gameicon } is not in serverlist.csv "
exitcode = 1
else
@ -28,7 +32,7 @@ done
echo ""
echo "Checking that the number of gameicons matches the number of servers in serverlist.csv"
gameiconcount = " $( ls -1 gameicons | wc -l) "
gameiconcount = " $( find gameicons -mindepth 1 -maxdepth 1 -type f | wc -l) "
serverlistcount = " $( tail -n +2 serverlist.csv | wc -l) "
if [ " ${ gameiconcount } " -ne " ${ serverlistcount } " ] ; then
echo " ERROR: game icons ( ${ gameiconcount } ) does not match serverlist.csv ( $serverlistcount ) "
@ -37,4 +41,4 @@ else
echo " OK: gameiconcount ( $gameiconcount ) matches serverlistcount ( $serverlistcount ) "
fi
exit ${ exitcode }
exit " ${ exitcode } "
@ -3,12 +3,15 @@ echo "Checking that all the game servers are listed in all csv files"
echo "this check will ensure serverlist.csv has the same number of lines (-2 lines) as the other csv files"
# count the number of lines in the serverlist.csv
cd " ${ datadir } " || exit
exitcode = 0
serverlistcount = " $( tail -n +2 serverlist.csv | wc -l) "
echo " serverlistcount: $serverlistcount "
# get list of all csv files starting with ubunutu debian centos
csvlist = " $( ls -1 | grep -E '^(ubuntu|debian|centos|rhel|almalinux|rocky).*\.csv$' ) "
shopt -s nullglob
csvlist = ( ubuntu*.csv debian*.csv centos*.csv rhel*.csv almalinux*.csv rocky*.csv)
# loop though each csv file and make sure the number of lines is the same as the serverlistcount
for csv in $csvlist ; do
for csv in " ${ csvlist [@] } " ; do
csvcount = " $( wc -l < " ${ csv } " ) "
csvcount = $(( csvcount - 2 ))
if [ " $csvcount " -ne " $serverlistcount " ] ; then
@ -35,4 +38,4 @@ for shortname in $(tail -n +2 serverlist.csv | cut -d ',' -f1); do
fi
done
exit ${ exitcode }
exit " ${ exitcode } "
@ -43,7 +43,13 @@ EOF
)
fn_print_dots "Sending Telegram alert"
telegramsend = $( curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d " $( echo -n " ${ json } " | jq -c .) " ${ curlcustomstring } " https:// ${ telegramapi } /bot ${ telegramtoken } /sendMessage " | grep "error_code" )
curlcustomargs = ( )
if [ -n " ${ curlcustomstring } " ] ; then
read -r -a curlcustomargs <<< " ${ curlcustomstring } "
fi
telegramsend = $( curl --connect-timeout 3 -sSL -H "Content-Type: application/json" -X POST -d " $( echo -n " ${ json } " | jq -c .) " " ${ curlcustomargs [@] } " " https:// ${ telegramapi } /bot ${ telegramtoken } /sendMessage " | grep "error_code" )
if [ -n " ${ telegramsend } " ] ; then
fn_print_fail_nl " Sending Telegram alert: ${ telegramsend } "