distrocheck.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. #!/bin/sh
  2. #############################################
  3. # Copyright (C) 2011 HPCC Systems.
  4. #
  5. # All rights reserved. This program is free software: you can redistribute it and/or modify
  6. # it under the terms of the GNU Affero General Public License as
  7. # published by the Free Software Foundation, either version 3 of the
  8. # License, or (at your option) any later version.
  9. #
  10. # This program is distributed in the hope that it will be useful,
  11. # but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. # GNU Affero General Public License for more details.
  14. #
  15. # You should have received a copy of the GNU Affero General Public License
  16. # along with All rights reserved. This program is free software: you can redistribute program. If not, see <http://www.gnu.org/licenses/>.
  17. #############################################
  18. if [ -e /etc/debian_version ]; then
  19. echo -n "DEB"
  20. exit 2;
  21. elif [ -e /etc/redhat-release ]; then
  22. echo -n "RPM"
  23. exit 1;
  24. elif [ -e /etc/SuSE-release ]; then
  25. echo -n "RPM"
  26. exit 1;
  27. fi
  28. cat /etc/*release > temp.txt
  29. ############### RPM DISTROS ##################
  30. # Distribution is openSuse
  31. VALUE=`grep -c -i 'suse' temp.txt`
  32. if [ $VALUE -ge 1 ]; then
  33. echo -n "RPM"
  34. rm temp.txt
  35. exit 1;
  36. fi
  37. # Distribution is Centos
  38. VALUE=`grep -c -i 'centos' temp.txt`
  39. if [ $VALUE -ge 1 ]; then
  40. echo -n "RPM"
  41. rm temp.txt
  42. exit 1;
  43. fi
  44. # Distribution is Mandriva
  45. VALUE=`grep -c -i 'mandr' temp.txt`
  46. if [ $VALUE -ge 1 ]; then
  47. echo -n "RPM"
  48. rm temp.txt
  49. exit 1;
  50. fi
  51. # Distribution is Redhat
  52. VALUE=`grep -c -i 'redhat' temp.txt`
  53. if [ $VALUE -ge 1 ]; then
  54. echo -n "RPM"
  55. rm temp.txt
  56. exit 1;
  57. fi
  58. ############### DEB DISTROS ##################
  59. # Distribution is Ubuntu
  60. VALUE=`grep -c -i 'ubuntu' temp.txt`
  61. if [ $VALUE -ge 1 ]; then
  62. echo -n "DEB"
  63. rm temp.txt
  64. exit 2;
  65. fi
  66. # Distribution is Debian
  67. VALUE=`grep -c -i 'DEBian' temp.txt`
  68. if [ $VALUE -ge 1 ]; then
  69. echo -n "DEB"
  70. rm temp.txt
  71. exit 2;
  72. fi
  73. ############## OTHER DISTROS #################
  74. # Distribution is Gentoo
  75. VALUE=`grep -c -i 'gentoo' temp.txt`
  76. if [ $VALUE -ge 1 ]; then
  77. echo -n "TGZ"
  78. rm temp.txt
  79. exit 4;
  80. fi