distrocheck.sh 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  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. 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