distrocheck.sh 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. #!/bin/sh
  2. #############################################
  3. # HPCC SYSTEMS software Copyright (C) 2012 HPCC Systems®.
  4. #
  5. # Licensed under the Apache License, Version 2.0 (the "License");
  6. # you may not use this file except in compliance with the License.
  7. # You may obtain a copy of the License at
  8. # http://www.apache.org/licenses/LICENSE-2.0
  9. #
  10. # Unless required by applicable law or agreed to in writing, software
  11. # distributed under the License is distributed on an "AS IS" BASIS,
  12. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. # See the License for the specific language governing permissions and
  14. #
  15. # limitations under the 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. elif [ -e /etc/system-release ]; then
  28. grep -q -i "Amazon Linux" /etc/system-release
  29. if [ $? = 0 ]; then
  30. echo -n "RPM"
  31. exit 1;
  32. fi
  33. fi
  34. cat /etc/*release > temp.txt
  35. ############### RPM DISTROS ##################
  36. # Distribution is openSuse
  37. VALUE=`grep -c -i 'suse' temp.txt`
  38. if [ $VALUE -ge 1 ]; then
  39. echo -n "RPM"
  40. rm temp.txt
  41. exit 1;
  42. fi
  43. # Distribution is Centos
  44. VALUE=`grep -c -i 'centos' temp.txt`
  45. if [ $VALUE -ge 1 ]; then
  46. echo -n "RPM"
  47. rm temp.txt
  48. exit 1;
  49. fi
  50. # Distribution is Mandriva
  51. VALUE=`grep -c -i 'mandr' temp.txt`
  52. if [ $VALUE -ge 1 ]; then
  53. echo -n "RPM"
  54. rm temp.txt
  55. exit 1;
  56. fi
  57. # Distribution is Redhat
  58. VALUE=`grep -c -i 'redhat' temp.txt`
  59. if [ $VALUE -ge 1 ]; then
  60. echo -n "RPM"
  61. rm temp.txt
  62. exit 1;
  63. fi
  64. ############### DEB DISTROS ##################
  65. # Distribution is Ubuntu
  66. VALUE=`grep -c -i 'ubuntu' temp.txt`
  67. if [ $VALUE -ge 1 ]; then
  68. echo -n "DEB"
  69. rm temp.txt
  70. exit 2;
  71. fi
  72. # Distribution is Debian
  73. VALUE=`grep -c -i 'DEBian' temp.txt`
  74. if [ $VALUE -ge 1 ]; then
  75. echo -n "DEB"
  76. rm temp.txt
  77. exit 2;
  78. fi
  79. ############## OTHER DISTROS #################
  80. # Distribution is Gentoo
  81. VALUE=`grep -c -i 'gentoo' temp.txt`
  82. if [ $VALUE -ge 1 ]; then
  83. echo -n "TGZ"
  84. rm temp.txt
  85. exit 4;
  86. fi