hst-install.sh 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  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 11, 12
  11. # Ubuntu 20.04, 22.04, 24.04 LTS
  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" ] && [ ! -e "/etc/redhat-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. else
  54. type="NoSupport"
  55. fi
  56. else
  57. type="NoSupport"
  58. fi
  59. no_support_message() {
  60. echo "****************************************************"
  61. echo "Your operating system (OS) is not supported by"
  62. echo "Hestia Control Panel. Officially supported releases:"
  63. echo "****************************************************"
  64. echo " Debian 11, 12"
  65. echo " Ubuntu 22.04, 24.04 LTS"
  66. echo ""
  67. exit 1
  68. }
  69. if [ "$type" = "NoSupport" ]; then
  70. no_support_message
  71. fi
  72. check_wget_curl() {
  73. # Check wget
  74. if [ -e '/usr/bin/wget' ]; then
  75. wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh -O hst-install-$type.sh
  76. if [ "$?" -eq '0' ]; then
  77. bash hst-install-$type.sh $*
  78. exit
  79. else
  80. echo "Error: hst-install-$type.sh download failed."
  81. exit 1
  82. fi
  83. # fi
  84. fi
  85. # Check curl
  86. if [ -e '/usr/bin/curl' ]; then
  87. curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh
  88. if [ "$?" -eq '0' ]; then
  89. bash hst-install-$type.sh $*
  90. exit
  91. else
  92. echo "Error: hst-install-$type.sh download failed."
  93. exit 1
  94. fi
  95. # fi
  96. fi
  97. }
  98. # Check for supported operating system before proceeding with download
  99. # of OS-specific installer, and throw error message if unsupported OS detected.
  100. if [[ "$release" =~ ^(11|12|22.04|24.04)$ ]]; then
  101. check_wget_curl $*
  102. else
  103. no_support_message
  104. fi
  105. exit