From 2cebdfea66a8ef43050104c1e18bbebf365ba41d Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Sun, 11 Jun 2023 16:24:04 +0100 Subject: [PATCH] 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 --- .github/workflows/detals-check-generate-matrix.sh | 2 +- .github/workflows/serverlist-validate.sh | 2 +- lgsm/data/serverlist.csv | 1 + linuxgsm.sh | 4 ++-- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/.github/workflows/detals-check-generate-matrix.sh b/.github/workflows/detals-check-generate-matrix.sh index 66f2bd072..14cbb6ee7 100755 --- a/.github/workflows/detals-check-generate-matrix.sh +++ b/.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" diff --git a/.github/workflows/serverlist-validate.sh b/.github/workflows/serverlist-validate.sh index b43e803e0..50b2da712 100755 --- a/.github/workflows/serverlist-validate.sh +++ b/.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$')" diff --git a/lgsm/data/serverlist.csv b/lgsm/data/serverlist.csv index 8b2b5c705..7888c7983 100644 --- a/lgsm/data/serverlist.csv +++ b/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 diff --git a/linuxgsm.sh b/linuxgsm.sh index d8a28d604..b5786e70d 100755 --- a/linuxgsm.sh +++ b/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