hst-install.sh 3.1 KB

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