vst-install.sh 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. #!/bin/bash
  2. # Vesta installation wrapper
  3. # http://vestacp.com
  4. #
  5. # Currently Supported Operating Systems:
  6. #
  7. # RHEL 5, RHEL 6
  8. # CentOS 5, CentOS 6
  9. # Debian 7
  10. # Ubuntu LTS, Ubuntu 13.04, Ubuntu 13.10
  11. #
  12. # Am I root?
  13. if [ "x$(id -u)" != 'x0' ]; then
  14. echo 'Error: this script can only be executed by root'
  15. exit 1
  16. fi
  17. # Check admin user account
  18. if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ -z "$1" ]; then
  19. echo "Error: user admin exists"
  20. echo
  21. echo 'Please remove admin user account before proceeding.'
  22. echo 'If you want to do it automatically run installer with -f option:'
  23. echo "Example: bash $0 --force"
  24. exit 1
  25. fi
  26. # Check admin user account
  27. if [ ! -z "$(grep ^admin: /etc/group)" ] && [ -z "$1" ]; then
  28. echo "Error: group admin exists"
  29. echo
  30. echo 'Please remove admin user account before proceeding.'
  31. echo 'If you want to do it automatically run installer with -f option:'
  32. echo "Example: bash $0 --force"
  33. exit 1
  34. fi
  35. # Check OS type
  36. if [ -e '/etc/redhat-release' ]; then
  37. type="rhel"
  38. fi
  39. if [ -e '/etc/lsb-release' ] && [ -e '/etc/debian_version' ]; then
  40. type="ubuntu"
  41. fi
  42. if [ -z "$type" ]; then
  43. os=$(head -n1 /etc/issue | cut -f 1 -d ' ')
  44. if [ "$os" == 'Debian' ]; then
  45. type="debian"
  46. fi
  47. fi
  48. # Check type
  49. if [ -z "$type" ]; then
  50. echo 'Error: only RHEL,CentOS, Ubuntu LTS and Debian 7 is supported'
  51. exit 1
  52. fi
  53. # Check wget
  54. if [ -e '/usr/bin/wget' ]; then
  55. wget http://vestacp.com/pub/vst-install-$type.sh -O vst-install-$type.sh
  56. if [ "$?" -eq '0' ]; then
  57. bash vst-install-$type.sh $*
  58. exit
  59. else
  60. echo "Error: vst-install-$type.sh download failed."
  61. exit 1
  62. fi
  63. fi
  64. # Check curl
  65. if [ -e '/usr/bin/curl' ]; then
  66. curl -O http://vestacp.com/pub/vst-install-$type.sh
  67. if [ "$?" -eq '0' ]; then
  68. bash vst-install-$type.sh $*
  69. exit
  70. else
  71. echo "Error: vst-install-$type.sh download failed."
  72. exit 1
  73. fi
  74. fi
  75. # Let's try to install wget automaticaly
  76. if [ "$type" = 'rhel' ]; then
  77. yum -y install wget
  78. if [ $? -ne 0 ]; then
  79. echo "Error: can't install wget"
  80. exit 1
  81. fi
  82. else
  83. apt-get -y install wget
  84. if [ $? -ne 0 ]; then
  85. echo "Error: can't install wget"
  86. exit 1
  87. fi
  88. fi
  89. # OK, last try
  90. if [ -e '/usr/bin/wget' ]; then
  91. wget http://vestacp.com/pub/vst-install-$type.sh -O vst-install-$type.sh
  92. if [ "$?" -eq '0' ]; then
  93. bash vst-install-$type.sh $*
  94. exit
  95. else
  96. echo "Error: vst-install-$type.sh download failed."
  97. exit 1
  98. fi
  99. else
  100. echo "Error: /usr/bin/wget not found"
  101. exit 1
  102. fi
  103. exit