hst-install.sh 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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. # elif [ -e "/etc/os-release" ] && [ -e "/etc/redhat-release" ]; then
  57. # type=$(grep "^ID=" /etc/os-release | cut -f 2 -d '"')
  58. # if [ "$type" = "rhel" ]; then
  59. # release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
  60. # VERSION='rhel'
  61. # elif [ "$type" = "almalinux" ]; then
  62. # release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
  63. # VERSION='almalinux'
  64. # elif [ "$type" = "eurolinux" ]; then
  65. # release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
  66. # VERSION='eurolinux'
  67. # elif [ "$type" = "rocky" ]; then
  68. # release=$(cat /etc/redhat-release | cut -f 1 -d '.' | awk '{print $3}')
  69. # VERSION='rockylinux'
  70. # fi
  71. else
  72. type="NoSupport"
  73. fi
  74. no_support_message() {
  75. echo "****************************************************"
  76. echo "Your operating system (OS) is not supported by"
  77. echo "Hestia Control Panel. Officially supported releases:"
  78. echo "****************************************************"
  79. echo " Debian 11, 12"
  80. echo " Ubuntu 20.04, 22.04, 24.04 LTS"
  81. # Commenting this out for now
  82. # echo " AlmaLinux, EuroLinux, Red Hat EnterPrise Linux, Rocky Linux 8,9"
  83. echo ""
  84. exit 1
  85. }
  86. if [ "$type" = "NoSupport" ]; then
  87. no_support_message
  88. fi
  89. check_wget_curl() {
  90. # Check wget
  91. if [ -e '/usr/bin/wget' ]; then
  92. # if [ -e '/etc/redhat-release' ]; then
  93. # wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-rhel.sh -O hst-install-rhel.sh
  94. # if [ "$?" -eq '0' ]; then
  95. # bash hst-install-rhel.sh $*
  96. # exit
  97. # else
  98. # echo "Error: hst-install-rhel.sh download failed."
  99. # exit 1
  100. # fi
  101. # else
  102. wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh -O hst-install-$type.sh
  103. if [ "$?" -eq '0' ]; then
  104. bash hst-install-$type.sh $*
  105. exit
  106. else
  107. echo "Error: hst-install-$type.sh download failed."
  108. exit 1
  109. fi
  110. # fi
  111. fi
  112. # Check curl
  113. if [ -e '/usr/bin/curl' ]; then
  114. # if [ -e '/etc/redhat-release' ]; then
  115. # curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-rhel.sh
  116. # if [ "$?" -eq '0' ]; then
  117. # bash hst-install-rhel.sh $*
  118. # exit
  119. # else
  120. # echo "Error: hst-install-rhel.sh download failed."
  121. # exit 1
  122. # fi
  123. # else
  124. curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh
  125. if [ "$?" -eq '0' ]; then
  126. bash hst-install-$type.sh $*
  127. exit
  128. else
  129. echo "Error: hst-install-$type.sh download failed."
  130. exit 1
  131. fi
  132. # fi
  133. fi
  134. }
  135. # Check for supported operating system before proceeding with download
  136. # of OS-specific installer, and throw error message if unsupported OS detected.
  137. if [[ "$release" =~ ^(11|12|20.04|22.04|24.04)$ ]]; then
  138. check_wget_curl $*
  139. # elif [[ -e "/etc/redhat-release" ]] && [[ "$release" =~ ^(8|9)$ ]]; then
  140. # check_wget_curl $*
  141. else
  142. no_support_message
  143. fi
  144. exit