vst-install.sh 2.4 KB

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