feat: add header to serverlist.csv (#4231)

* feat: add header to serverlist.csv

added header to serverlistto help ansible and other tools better work with the csv file

* feat: update serverlist menu

The script now skips the first line of the serverlist file when generating the list for 'list' and 'install' commands. This ensures that the header is not included in the output.

* fix: check details

* fix serverlist validate test
This commit is contained in:
Daniel Gibbs 2023-06-11 16:24:04 +01:00 committed by GitHub
parent fa24b08370
commit 2cebdfea66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 5 additions and 4 deletions

View File

@ -18,7 +18,7 @@ while read -r line; do
echo -n "\"shortname\":" >> "shortnamearray.json"
echo -n "\"${shortname}\"" >> "shortnamearray.json"
echo -n "}," >> "shortnamearray.json"
done < serverlist.csv
done < <(tail -n +2 serverlist.csv)
sed -i '$ s/.$//' "shortnamearray.json"
echo -n "]" >> "shortnamearray.json"
echo -n "}" >> "shortnamearray.json"

View File

@ -3,7 +3,7 @@ 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 "lgsm/data" || exit
serverlistcount="$(wc -l < serverlist.csv)"
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$')"

View File

@ -1,3 +1,4 @@
shortname,gameservername,gamename,os
ac,acserver,Assetto Corsa,ubuntu-22.04
ahl,ahlserver,Action Half-Life,ubuntu-22.04
ahl2,ahl2server,Action: Source,ubuntu-22.04

1 ac shortname acserver gameservername Assetto Corsa gamename ubuntu-22.04 os
1 shortname gameservername gamename os
2 ac ac acserver acserver Assetto Corsa Assetto Corsa ubuntu-22.04 ubuntu-22.04
3 ahl ahl ahlserver ahlserver Action Half-Life Action Half-Life ubuntu-22.04 ubuntu-22.04
4 ahl2 ahl2 ahl2server ahl2server Action: Source Action: Source ubuntu-22.04 ubuntu-22.04

View File

@ -347,11 +347,11 @@ if [ "${shortname}" == "core" ]; then
if [ "${userinput}" == "list" ] || [ "${userinput}" == "l" ]; then
{
tail -n +1 "${serverlist}" | awk -F "," '{print $2 "\t" $3}'
tail -n +2 "${serverlist}" | awk -F "," '{print $2 "\t" $3}'
} | column -s $'\t' -t | more
exit
elif [ "${userinput}" == "install" ] || [ "${userinput}" == "i" ]; then
tail -n +1 "${serverlist}" | awk -F "," '{print $1 "," $2 "," $3}' > "${serverlistmenu}"
tail -n +2 "${serverlist}" | awk -F "," '{print $1 "," $2 "," $3}' > "${serverlistmenu}"
fn_install_menu result "LinuxGSM" "Select game server to install." "${serverlistmenu}"
userinput="${result}"
fn_server_info