hst-install.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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 10, 11
  11. # Ubuntu 20.04, 22.04
  12. # AlmaLinux, EuroLinux, Red Hat EnterPrise Linux, Rocky Linux 8, 9
  13. #
  14. # ======================================================== #
  15. # Am I root?
  16. if [ "x$(id -u)" != 'x0' ]; then
  17. echo 'Error: this script can only be executed by root'
  18. exit 1
  19. fi
  20. # Check admin user account
  21. if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ -z "$1" ]; then
  22. echo "Error: user admin exists"
  23. echo
  24. echo 'Please remove admin user before proceeding.'
  25. echo 'If you want to do it automatically run installer with -f option:'
  26. echo "Example: bash $0 --force"
  27. exit 1
  28. fi
  29. # Check admin group
  30. if [ ! -z "$(grep ^admin: /etc/group)" ] && [ -z "$1" ]; then
  31. echo "Error: group admin exists"
  32. echo
  33. echo 'Please remove admin group before proceeding.'
  34. echo 'If you want to do it automatically run installer with -f option:'
  35. echo "Example: bash $0 --force"
  36. exit 1
  37. fi
  38. # Detect OS
  39. if [ -e "/etc/os-release" ] && [ ! -e "/etc/redhat-release" ]; then
  40. type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '=')
  41. if [ "$type" = "ubuntu" ]; then
  42. # Check if lsb_release is installed
  43. if [ -e '/usr/bin/lsb_release' ]; then
  44. release="$(lsb_release -s -r)"
  45. VERSION='ubuntu'
  46. else
  47. echo "lsb_release is currently not installed, please install it:"
  48. echo "apt-get update && apt-get install lsb-release"
  49. exit 1
  50. fi
  51. elif [ "$type" = "debian" ]; then
  52. release=$(cat /etc/debian_version | grep -o "[0-9]\{1,2\}" | head -n1)
  53. VERSION='debian'
  54. fi
  55. elif [ -e "/etc/os-release" ] && [ -e "/etc/redhat-release" ]; then
  56. type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '"')
  57. if [ "$type" = "rhel" ]; then
  58. release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
  59. VERSION='rhel'
  60. elif [ "$type" = "almalinux" ]; then
  61. release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
  62. VERSION='almalinux'
  63. elif [ "$type" = "eurolinux" ]; then
  64. release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
  65. VERSION='eurolinux'
  66. elif [ "$type" = "rocky" ]; then
  67. release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
  68. VERSION='rockylinux'
  69. fi
  70. else
  71. type="NoSupport"
  72. fi
  73. no_support_message() {
  74. echo "****************************************************"
  75. echo "Your operating system (OS) is not supported by"
  76. echo "Hestia Control Panel. Officially supported releases:"
  77. echo "****************************************************"
  78. echo " Debian 10, 11"
  79. echo " Ubuntu 20.04, 22.04 LTS"
  80. # Commenting this out for now
  81. # echo " AlmaLinux, EuroLinux, Red Hat EnterPrise Linux, Rocky Linux 8,9"
  82. echo ""
  83. exit 1
  84. }
  85. if [ "$type" = "NoSupport" ]; then
  86. no_support_message
  87. fi
  88. check_wget_curl() {
  89. # Check wget
  90. if [ -e '/usr/bin/wget' ]; then
  91. if [ -e '/etc/redhat-release' ]; then
  92. wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-rhel.sh -O hst-install-rhel.sh
  93. if [ "$?" -eq '0' ]; then
  94. bash hst-install-rhel.sh $*
  95. exit
  96. else
  97. echo "Error: hst-install-rhel.sh download failed."
  98. exit 1
  99. fi
  100. else
  101. wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh -O hst-install-$type.sh
  102. if [ "$?" -eq '0' ]; then
  103. bash hst-install-$type.sh $*
  104. exit
  105. else
  106. echo "Error: hst-install-$type.sh download failed."
  107. exit 1
  108. fi
  109. fi
  110. fi
  111. # Check curl
  112. if [ -e '/usr/bin/curl' ]; then
  113. if [ -e '/etc/redhat-release' ]; then
  114. curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-rhel.sh
  115. if [ "$?" -eq '0' ]; then
  116. bash hst-install-rhel.sh $*
  117. exit
  118. else
  119. echo "Error: hst-install-rhel.sh download failed."
  120. exit 1
  121. fi
  122. else
  123. curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh
  124. if [ "$?" -eq '0' ]; then
  125. bash hst-install-$type.sh $*
  126. exit
  127. else
  128. echo "Error: hst-install-$type.sh download failed."
  129. exit 1
  130. fi
  131. fi
  132. fi
  133. }
  134. # Check for supported operating system before proceeding with download
  135. # of OS-specific installer, and throw error message if unsupported OS detected.
  136. if [[ "$release" =~ ^(10|11|20.04|22.04)$ ]]; then
  137. check_wget_curl $*
  138. elif [[ -e "/etc/redhat-release" ]] && [[ "$release" =~ ^(8|9)$ ]]; then
  139. check_wget_curl $*
  140. else
  141. no_support_message
  142. fi
  143. exit