hst-install.sh 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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 22.04, 24.04 LTS"
  81. echo ""
  82. exit 1
  83. }
  84. if [ "$type" = "NoSupport" ]; then
  85. no_support_message
  86. fi
  87. check_wget_curl() {
  88. # Check wget
  89. if [ -e '/usr/bin/wget' ]; then
  90. # if [ -e '/etc/redhat-release' ]; then
  91. # wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-rhel.sh -O hst-install-rhel.sh
  92. # if [ "$?" -eq '0' ]; then
  93. # bash hst-install-rhel.sh $*
  94. # exit
  95. # else
  96. # echo "Error: hst-install-rhel.sh download failed."
  97. # exit 1
  98. # fi
  99. # else
  100. wget -q https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh -O hst-install-$type.sh
  101. if [ "$?" -eq '0' ]; then
  102. bash hst-install-$type.sh $*
  103. exit
  104. else
  105. echo "Error: hst-install-$type.sh download failed."
  106. exit 1
  107. fi
  108. # fi
  109. fi
  110. # Check curl
  111. if [ -e '/usr/bin/curl' ]; then
  112. # if [ -e '/etc/redhat-release' ]; then
  113. # curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-rhel.sh
  114. # if [ "$?" -eq '0' ]; then
  115. # bash hst-install-rhel.sh $*
  116. # exit
  117. # else
  118. # echo "Error: hst-install-rhel.sh download failed."
  119. # exit 1
  120. # fi
  121. # else
  122. curl -s -O https://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install-$type.sh
  123. if [ "$?" -eq '0' ]; then
  124. bash hst-install-$type.sh $*
  125. exit
  126. else
  127. echo "Error: hst-install-$type.sh download failed."
  128. exit 1
  129. fi
  130. # fi
  131. fi
  132. }
  133. # Check for supported operating system before proceeding with download
  134. # of OS-specific installer, and throw error message if unsupported OS detected.
  135. if [[ "$release" =~ ^(11|12|22.04|24.04)$ ]]; then
  136. check_wget_curl $*
  137. # elif [[ -e "/etc/redhat-release" ]] && [[ "$release" =~ ^(8|9)$ ]]; then
  138. # check_wget_curl $*
  139. else
  140. no_support_message
  141. fi
  142. exit