Browse Source

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
Daniel Gibbs 3 years ago
parent
commit
2cebdfea66

+ 1 - 1
.github/workflows/detals-check-generate-matrix.sh

@@ -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"

+ 1 - 1
.github/workflows/serverlist-validate.sh

@@ -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$')"

+ 1 - 0
lgsm/data/serverlist.csv

@@ -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

+ 2 - 2
linuxgsm.sh

@@ -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