From a4d68608fa3a39eb69a8cc5c225258daaea55305 Mon Sep 17 00:00:00 2001 From: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br> Date: Thu, 13 Nov 2014 16:51:55 -0200 Subject: [PATCH] Fix #2293: Accept two names for the MC linux distro Signed-off-by: Diego Giovane Pasqualin <dpasqualin@c3sl.ufpr.br> --- .../collected-data/inventory/distro.tree | 34 +++++++++++++------ 1 file changed, 23 insertions(+), 11 deletions(-) diff --git a/agent/gen-scripts/collected-data/inventory/distro.tree b/agent/gen-scripts/collected-data/inventory/distro.tree index 4566b8d..4094344 100755 --- a/agent/gen-scripts/collected-data/inventory/distro.tree +++ b/agent/gen-scripts/collected-data/inventory/distro.tree @@ -19,21 +19,33 @@ # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, # USA. -DISTRO=$(cut -sd ' ' -f1 /etc/issue | head -n 1) +DISTRO=$(cut -sd ' ' -f1 /etc/issue | head -n 1 2>/dev/null) -if test -f "/etc/le_version"; then - printf "Linux Educacional $(cat /etc/le_version)" - (dpkg -l minicom-client-config | grep -q '^ii' || - dpkg -l minicom-server-config | grep -q '^ii') > /dev/null 2>&1 && printf " mc" - printf "\n" +# Return 0 if package $1 is installed on the system, >0 otherwise +function isInstalled () { + dpkg --get-selections | grep "$1" | grep -q 'install$' +} + +# Linux Comunicações +if isInstalled "minicom-client-config" || + isInstalled 'minicom-server-config'; then + printf "Linux Comunicações" + test -f "/etc/mc_version" && printf " $(cat /etc/mc_version)" + printf "\n" +# Linux Educacional > 3 +elif test -f "/etc/le_version"; then + printf "Linux Educacional $(cat /etc/le_version)\n" +# Linux Educacional < 3 elif test "${DISTRO}" = "Ubuntu" -a -f "/usr/lib/edu/fbedu/tutorial.htm"; then - printf "Linux Educacional\n" -elif test "${DISTRO}" = "Mandriva" -o "${DISTRO}" = "Fedora"; then - head -n 1 /etc/issue + printf "Linux Educacional\n" +# Mandriva or Fedora +elif test "${DISTRO}" = "Mandriva" -o "${DISTRO}" = "Fedora"; then + head -n 1 /etc/issue +# Other... elif test "${DISTRO}" = "Welcome"; then - cut -sd "\\" -f1 /etc/issue | cut -d ' ' -f3- + cut -sd "\\" -f1 /etc/issue | cut -d ' ' -f3- else - cut -sd "\\" -f1 /etc/issue + cut -sd "\\" -f1 /etc/issue fi exit $? -- GitLab