From 8ee03daf03f0ab6e17519b91ecf2712649c39868 Mon Sep 17 00:00:00 2001 From: Daniel Gibbs Date: Tue, 15 Aug 2023 01:35:50 +0100 Subject: [PATCH] feat: add virtual environment to info_distro, info_game, and info_stats modules - Added code to retrieve the virtual environment using systemd-detect-virt command. - Updated the condition for RHEL based distros in info_distro module. - Removed code related to country code retrieval from external IP address in info_game module. - Added virtual environment field to the payload sent to Google Analytics and LinuxGSM API in info_stats module. --- lgsm/modules/info_distro.sh | 7 ++++++- lgsm/modules/info_game.sh | 14 -------------- lgsm/modules/info_stats.sh | 6 ++++-- 3 files changed, 10 insertions(+), 17 deletions(-) diff --git a/lgsm/modules/info_distro.sh b/lgsm/modules/info_distro.sh index 8c29a4ca2..ee84d39f2 100644 --- a/lgsm/modules/info_distro.sh +++ b/lgsm/modules/info_distro.sh @@ -73,7 +73,12 @@ for distro_info in "${distro_info_array[@]}"; do fi done -# some RHEL based distros use 8.4 instead of just 8. +# Get virtual environment +if [ "$(command -v systemd-detect-virt 2> /dev/null)" ]; then + virtualenvironment="$(systemd-detect-virt)" +fi + +# Some RHEL based distros use 8.4 instead of just 8. if [[ "${distroidlike}" == *"rhel"* ]] || [ "${distroid}" == "rhel" ]; then distroversioncsv="${distroversionrh}" else diff --git a/lgsm/modules/info_game.sh b/lgsm/modules/info_game.sh index 5a7eb5942..2bfdc10e7 100644 --- a/lgsm/modules/info_game.sh +++ b/lgsm/modules/info_game.sh @@ -2397,20 +2397,6 @@ else extip="$(cat "${tmpdir}/extip.txt")" fi -# Country code of external IP address -if [ ! -f "${tmpdir}/countrycode.txt" ]; then - countrycode="$(curl --connect-timeout 10 -s https://ipapi.co/country 2> /dev/null)" - exitcode=$? - # if curl passes add extip to externalip.txt - if [ "${exitcode}" == "0" ]; then - echo "${countrycode}" > "${tmpdir}/countrycode.txt" - else - echo "Unable to get external IP address" - fi -else - countrycode="$(cat "${tmpdir}/countrycode.txt")" -fi - # Alert IP address if [ "${displayip}" ]; then alertip="${displayip}" diff --git a/lgsm/modules/info_stats.sh b/lgsm/modules/info_stats.sh index ac145a37f..f012efeb2 100644 --- a/lgsm/modules/info_stats.sh +++ b/lgsm/modules/info_stats.sh @@ -82,7 +82,8 @@ curl -X POST "https://www.google-analytics.com/mp/collect?api_secret=A-OzP02TSMW \"uuidhardware\": \"${uuidhardware}\", \"uuidinstall\": \"${uuidinstall}\", \"uuidinstance\": \"${uuidinstance}\", - \"version\": \"${version}\" + \"version\": \"${version}\", + \"virtualenvironment\": \"${virtualenvironment}\" } } ] @@ -108,7 +109,8 @@ curl -i -X POST https://stats.linuxgsm.com/api/event \ \"servercpufreq\": \"${cpufreqency} x${cpucores}\", \"serverdisk\": \"${totalspace}\", \"serverram\": \"${physmemtotal}\", - \"version\": \"${version}\" + \"version\": \"${version}\", + \"virtualenvironment\": \"${virtualenvironment}\" }" ## Alert Stats.