hst-install.sh 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. #!/bin/bash
  2. # Hestia installation wrapper
  3. # https://www.hestiacp.com
  4. #
  5. # Currently Supported Operating Systems:
  6. #
  7. # Debian 8, 9
  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. case $(head -n1 /etc/issue | cut -f 1 -d ' ') in
  35. Debian) type="debian" ;;
  36. Ubuntu) type="ubuntu" ;;
  37. *) type="NoSupport" ;;
  38. esac
  39. # Detect release for Debian
  40. if [ "$type" = "debian" ]; then
  41. release=$(cat /etc/debian_version|grep -o [0-9]|head -n1)
  42. VERSION='debian'
  43. elif [ "$type" = "ubuntu" ]; then
  44. release="$(lsb_release -s -r)"
  45. VERSION='ubuntu'
  46. fi
  47. no_support_message(){
  48. echo "****************************************************"
  49. echo "Your operating system (OS) is not supported by"
  50. echo "Hestia Control Panel. Officially supported releases:"
  51. echo "****************************************************"
  52. echo " Debian 8, 9"
  53. echo " Ubuntu 16.04 LTS, 18.04 LTS"
  54. echo ""
  55. exit 1;
  56. }
  57. if [ "$type" = "NoSupport" ]; then
  58. no_support_message
  59. fi
  60. check_wget_curl(){
  61. # Check wget
  62. if [ -e '/usr/bin/wget' ]; then
  63. wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh -O hst-install-$type.sh
  64. if [ "$?" -eq '0' ]; then
  65. bash hst-install-$type.sh $*
  66. exit
  67. else
  68. echo "Error: hst-install-$type.sh download failed."
  69. exit 1
  70. fi
  71. fi
  72. # Check curl
  73. if [ -e '/usr/bin/curl' ]; then
  74. curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/master/install/hst-install-$type.sh
  75. if [ "$?" -eq '0' ]; then
  76. bash hst-install-$type.sh $*
  77. exit
  78. else
  79. echo "Error: hst-install-$type.sh download failed."
  80. exit 1
  81. fi
  82. fi
  83. }
  84. # Check for supported operating system before proceeding with download
  85. # of OS-specific installer, and throw error message if unsupported OS detected.
  86. if [[ "$release" =~ ^(8|9|16.04|18.04)$ ]]; then
  87. check_wget_curl $*
  88. else
  89. no_support_message
  90. fi
  91. exit