hst-install.sh 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. #!/bin/bash
  2. # Hestia installation wrapper
  3. # https://www.hestiacp.com
  4. #
  5. # Currently Supported Operating Systems:
  6. #
  7. # Debian 8, 9, 10
  8. # Ubuntu 16.04, 18.04
  9. #
  10. # Am I root?
  11. if [ "x$(id -u)" != 'x0' ]; then
  12. echo 'Error: this script can only be executed by root'
  13. exit 1
  14. fi
  15. # Check admin user account
  16. if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ -z "$1" ]; then
  17. echo "Error: user admin exists"
  18. echo
  19. echo 'Please remove admin user before proceeding.'
  20. echo 'If you want to do it automatically run installer with -f option:'
  21. echo "Example: bash $0 --force"
  22. exit 1
  23. fi
  24. # Check admin group
  25. if [ ! -z "$(grep ^admin: /etc/group)" ] && [ -z "$1" ]; then
  26. echo "Error: group admin exists"
  27. echo
  28. echo 'Please remove admin group before proceeding.'
  29. echo 'If you want to do it automatically run installer with -f option:'
  30. echo "Example: bash $0 --force"
  31. exit 1
  32. fi
  33. # Detect OS
  34. if [ -e "/etc/os-release" ]; then
  35. type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '=')
  36. if [ "$type" = "ubuntu" ]; then
  37. # Check if lsb_release is installed
  38. if [ -e '/usr/bin/lsb_release' ]; then
  39. release="$(lsb_release -s -r)"
  40. VERSION='ubuntu'
  41. else
  42. echo "lsb_release is currently not installed, please install it:"
  43. echo "apt-get update && apt-get install lsb_release"
  44. exit 1
  45. fi
  46. elif [ "$type" = "debian" ]; then
  47. release=$(cat /etc/debian_version|grep -o "[0-9]\{1,2\}"|head -n1)
  48. VERSION='debian'
  49. fi
  50. else
  51. type="NoSupport"
  52. fi
  53. no_support_message(){
  54. echo "****************************************************"
  55. echo "Your operating system (OS) is not supported by"
  56. echo "Hestia Control Panel. Officially supported releases:"
  57. echo "****************************************************"
  58. echo " Debian 8, 9, 10"
  59. echo " Ubuntu 16.04 LTS, 18.04 LTS"
  60. echo ""
  61. exit 1;
  62. }
  63. if [ "$type" = "NoSupport" ]; then
  64. no_support_message
  65. fi
  66. check_wget_curl(){
  67. # Check wget
  68. if [ -e '/usr/bin/wget' ]; then
  69. wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh -O hst-install-$type.sh
  70. if [ "$?" -eq '0' ]; then
  71. bash hst-install-$type.sh $*
  72. exit
  73. else
  74. echo "Error: hst-install-$type.sh download failed."
  75. exit 1
  76. fi
  77. fi
  78. # Check curl
  79. if [ -e '/usr/bin/curl' ]; then
  80. curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh
  81. if [ "$?" -eq '0' ]; then
  82. bash hst-install-$type.sh $*
  83. exit
  84. else
  85. echo "Error: hst-install-$type.sh download failed."
  86. exit 1
  87. fi
  88. fi
  89. }
  90. # Check for supported operating system before proceeding with download
  91. # of OS-specific installer, and throw error message if unsupported OS detected.
  92. if [[ "$release" =~ ^(8|9|10|16.04|18.04)$ ]]; then
  93. check_wget_curl $*
  94. else
  95. no_support_message
  96. fi
  97. exit