diff --git a/agent/gen-scripts/collected-data/inventory/distro.tree b/agent/gen-scripts/collected-data/inventory/distro.tree index 4566b8dba7c652b3ac6ec62fb1f98e893f2f6394..4094344f2f1d50cfd60d7c934178852f94c37aef 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 $?