hst-install-ubuntu.sh 71 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018
  1. #!/bin/bash
  2. # Hestia Ubuntu installer v1.0
  3. #----------------------------------------------------------#
  4. # Variables&Functions #
  5. #----------------------------------------------------------#
  6. export PATH=$PATH:/sbin
  7. export DEBIAN_FRONTEND=noninteractive
  8. RHOST='apt.hestiacp.com'
  9. GPG='gpg.hestiacp.com'
  10. VERSION='ubuntu'
  11. HESTIA='/usr/local/hestia'
  12. LOG="/root/hst_install_backups/hst_install-$(date +%d%m%Y%H%M).log"
  13. memory=$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])
  14. hst_backups="/root/hst_install_backups/$(date +%d%m%Y%H%M)"
  15. spinner="/-\|"
  16. os='ubuntu'
  17. release="$(lsb_release -s -r)"
  18. codename="$(lsb_release -s -c)"
  19. architecture="$(uname -m)"
  20. HESTIA_INSTALL_DIR="$HESTIA/install/deb"
  21. VERBOSE='no'
  22. # Define software versions
  23. HESTIA_INSTALL_VER='1.4.10~alpha'
  24. pma_v='5.1.1'
  25. rc_v="1.4.11"
  26. multiphp_v=("5.6" "7.0" "7.1" "7.2" "7.3" "7.4" "8.0")
  27. fpm_v="7.4"
  28. mariadb_v="10.5"
  29. # Defining software pack for all distros
  30. software="apache2 apache2.2-common apache2-suexec-custom apache2-utils
  31. apparmor-utils awstats bc bind9 bsdmainutils bsdutils clamav-daemon
  32. cron curl dnsutils dovecot-imapd dovecot-pop3d e2fslibs e2fsprogs exim4
  33. exim4-daemon-heavy expect fail2ban flex ftp git idn imagemagick
  34. libapache2-mod-fcgid libapache2-mod-php$fpm_v libapache2-mod-rpaf
  35. lsof mc mariadb-client mariadb-common mariadb-server nginx
  36. php$fpm_v php$fpm_v-cgi php$fpm_v-common php$fpm_v-curl
  37. php$fpm_v-mysql php$fpm_v-imap php$fpm_v-ldap php$fpm_v-apcu phppgadmin
  38. php$fpm_v-pgsql php$fpm_v-zip php$fpm_v-bz2 php$fpm_v-cli php$fpm_v-gd
  39. php$fpm_v-imagick php$fpm_v-intl php$fpm_v-json php$fpm_v-mbstring
  40. php$fpm_v-opcache php$fpm_v-pspell php$fpm_v-readline php$fpm_v-xml
  41. postgresql postgresql-contrib proftpd-basic quota rrdtool rssh spamassassin sudo hestia=${HESTIA_INSTALL_VER}
  42. hestia-nginx hestia-php vim-common vsftpd whois zip acl sysstat setpriv
  43. ipset libonig5 libzip5 openssh-server lsb-release zstd"
  44. installer_dependencies="apt-transport-https curl dirmngr gnupg wget software-properties-common ca-certificates"
  45. # Defining help function
  46. help() {
  47. echo "Usage: $0 [OPTIONS]
  48. -a, --apache Install Apache [yes|no] default: yes
  49. -w, --phpfpm Install PHP-FPM [yes|no] default: yes
  50. -o, --multiphp Install Multi-PHP [yes|no] default: no
  51. -v, --vsftpd Install Vsftpd [yes|no] default: yes
  52. -j, --proftpd Install ProFTPD [yes|no] default: no
  53. -k, --named Install Bind [yes|no] default: yes
  54. -m, --mysql Install MariaDB [yes|no] default: yes
  55. -g, --postgresql Install PostgreSQL [yes|no] default: no
  56. -x, --exim Install Exim [yes|no] default: yes
  57. -z, --dovecot Install Dovecot [yes|no] default: yes
  58. -c, --clamav Install ClamAV [yes|no] default: yes
  59. -t, --spamassassin Install SpamAssassin [yes|no] default: yes
  60. -i, --iptables Install Iptables [yes|no] default: yes
  61. -b, --fail2ban Install Fail2ban [yes|no] default: yes
  62. -q, --quota Filesystem Quota [yes|no] default: no
  63. -d, --api Activate API [yes|no] default: yes
  64. -r, --port Change Backend Port default: 8083
  65. -l, --lang Default language default: en
  66. -y, --interactive Interactive install [yes|no] default: yes
  67. -s, --hostname Set hostname
  68. -e, --email Set admin email
  69. -p, --password Set admin password
  70. -D, --with-debs Path to Hestia debs
  71. -f, --force Force installation
  72. -h, --help Print this help
  73. Example: bash $0 -e [email protected] -p p4ssw0rd --multiphp yes"
  74. exit 1
  75. }
  76. # Defining file download function
  77. download_file() {
  78. wget $1 -q --show-progress --progress=bar:force
  79. }
  80. # Defining password-gen function
  81. gen_pass() {
  82. head /dev/urandom | tr -dc A-Za-z0-9 | head -c 16
  83. }
  84. # Defining return code check function
  85. check_result() {
  86. if [ $1 -ne 0 ]; then
  87. echo "Error: $2"
  88. exit $1
  89. fi
  90. }
  91. # Defining function to set default value
  92. set_default_value() {
  93. eval variable=\$$1
  94. if [ -z "$variable" ]; then
  95. eval $1=$2
  96. fi
  97. if [ "$variable" != 'yes' ] && [ "$variable" != 'no' ]; then
  98. eval $1=$2
  99. fi
  100. }
  101. # Defining function to set default language value
  102. set_default_lang() {
  103. if [ -z "$lang" ]; then
  104. eval lang=$1
  105. fi
  106. lang_list="ar az bg bs cs da de el en es fa fi fr hr hu id it ja ka ko nl no pl pt pt-br ro
  107. ru sr sv th tr uk ur vi zh-cn zh-tw"
  108. if !(echo $lang_list |grep -w $lang > /dev/null 2>&1); then
  109. eval lang=$1
  110. fi
  111. }
  112. # Define the default backend port
  113. set_default_port() {
  114. if [ -z "$port" ]; then
  115. eval port=$1
  116. fi
  117. }
  118. # Write configuration KEY/VALUE pair to $HESTIA/conf/hestia.conf
  119. write_config_value() {
  120. local key="$1"
  121. local value="$2"
  122. echo "$key='$value'" >> $HESTIA/conf/hestia.conf
  123. }
  124. # Sort configuration file values
  125. # Write final copy to $HESTIA/conf/hestia.conf for active usage
  126. # Duplicate file to $HESTIA/conf/defaults/hestia.conf to restore known good installation values
  127. sort_config_file(){
  128. sort $HESTIA/conf/hestia.conf -o /tmp/updconf
  129. mv $HESTIA/conf/hestia.conf $HESTIA/conf/hestia.conf.bak
  130. mv /tmp/updconf $HESTIA/conf/hestia.conf
  131. rm -f $HESTIA/conf/hestia.conf.bak
  132. if [ ! -d "$HESTIA/conf/defaults/" ]; then
  133. mkdir -p "$HESTIA/conf/defaults/"
  134. fi
  135. cp $HESTIA/conf/hestia.conf $HESTIA/conf/defaults/hestia.conf
  136. }
  137. #----------------------------------------------------------#
  138. # Verifications #
  139. #----------------------------------------------------------#
  140. # Creating temporary file
  141. tmpfile=$(mktemp -p /tmp)
  142. # Translating argument to --gnu-long-options
  143. for arg; do
  144. delim=""
  145. case "$arg" in
  146. --apache) args="${args}-a " ;;
  147. --phpfpm) args="${args}-w " ;;
  148. --vsftpd) args="${args}-v " ;;
  149. --proftpd) args="${args}-j " ;;
  150. --named) args="${args}-k " ;;
  151. --mysql) args="${args}-m " ;;
  152. --postgresql) args="${args}-g " ;;
  153. --exim) args="${args}-x " ;;
  154. --dovecot) args="${args}-z " ;;
  155. --clamav) args="${args}-c " ;;
  156. --spamassassin) args="${args}-t " ;;
  157. --iptables) args="${args}-i " ;;
  158. --fail2ban) args="${args}-b " ;;
  159. --multiphp) args="${args}-o " ;;
  160. --quota) args="${args}-q " ;;
  161. --port) args="${args}-r " ;;
  162. --lang) args="${args}-l " ;;
  163. --interactive) args="${args}-y " ;;
  164. --api) args="${args}-d " ;;
  165. --hostname) args="${args}-s " ;;
  166. --email) args="${args}-e " ;;
  167. --password) args="${args}-p " ;;
  168. --force) args="${args}-f " ;;
  169. --with-debs) args="${args}-D " ;;
  170. --help) args="${args}-h " ;;
  171. *) [[ "${arg:0:1}" == "-" ]] || delim="\""
  172. args="${args}${delim}${arg}${delim} ";;
  173. esac
  174. done
  175. eval set -- "$args"
  176. # Parsing arguments
  177. while getopts "a:w:v:j:k:m:g:d:x:z:c:t:i:b:r:o:q:l:y:s:e:p:D:fh" Option; do
  178. case $Option in
  179. a) apache=$OPTARG ;; # Apache
  180. w) phpfpm=$OPTARG ;; # PHP-FPM
  181. o) multiphp=$OPTARG ;; # Multi-PHP
  182. v) vsftpd=$OPTARG ;; # Vsftpd
  183. j) proftpd=$OPTARG ;; # Proftpd
  184. k) named=$OPTARG ;; # Named
  185. m) mysql=$OPTARG ;; # MariaDB
  186. g) postgresql=$OPTARG ;; # PostgreSQL
  187. x) exim=$OPTARG ;; # Exim
  188. z) dovecot=$OPTARG ;; # Dovecot
  189. c) clamd=$OPTARG ;; # ClamAV
  190. t) spamd=$OPTARG ;; # SpamAssassin
  191. i) iptables=$OPTARG ;; # Iptables
  192. b) fail2ban=$OPTARG ;; # Fail2ban
  193. q) quota=$OPTARG ;; # FS Quota
  194. r) port=$OPTARG ;; # Backend Port
  195. l) lang=$OPTARG ;; # Language
  196. d) api=$OPTARG ;; # Activate API
  197. y) interactive=$OPTARG ;; # Interactive install
  198. s) servername=$OPTARG ;; # Hostname
  199. e) email=$OPTARG ;; # Admin email
  200. p) vpass=$OPTARG ;; # Admin password
  201. D) withdebs=$OPTARG ;; # Hestia debs path
  202. f) force='yes' ;; # Force install
  203. h) help ;; # Help
  204. *) help ;; # Print help (default)
  205. esac
  206. done
  207. # Defining default software stack
  208. set_default_value 'nginx' 'yes'
  209. set_default_value 'apache' 'yes'
  210. set_default_value 'phpfpm' 'yes'
  211. set_default_value 'multiphp' 'no'
  212. set_default_value 'vsftpd' 'yes'
  213. set_default_value 'proftpd' 'no'
  214. set_default_value 'named' 'yes'
  215. set_default_value 'mysql' 'yes'
  216. set_default_value 'postgresql' 'no'
  217. set_default_value 'exim' 'yes'
  218. set_default_value 'dovecot' 'yes'
  219. if [ $memory -lt 1500000 ]; then
  220. set_default_value 'clamd' 'no'
  221. set_default_value 'spamd' 'no'
  222. elif [ $memory -lt 3000000 ]; then
  223. set_default_value 'clamd' 'no'
  224. set_default_value 'spamd' 'yes'
  225. else
  226. set_default_value 'clamd' 'yes'
  227. set_default_value 'spamd' 'yes'
  228. fi
  229. set_default_value 'iptables' 'yes'
  230. set_default_value 'fail2ban' 'yes'
  231. set_default_value 'quota' 'no'
  232. set_default_value 'interactive' 'yes'
  233. set_default_value 'api' 'yes'
  234. set_default_port '8083'
  235. set_default_lang 'en'
  236. # Checking software conflicts
  237. if [ "$proftpd" = 'yes' ]; then
  238. vsftpd='no'
  239. fi
  240. if [ "$exim" = 'no' ]; then
  241. clamd='no'
  242. spamd='no'
  243. dovecot='no'
  244. fi
  245. if [ "$iptables" = 'no' ]; then
  246. fail2ban='no'
  247. fi
  248. # Checking root permissions
  249. if [ "x$(id -u)" != 'x0' ]; then
  250. check_result 1 "Script can be run executed only by root"
  251. fi
  252. # Checking admin user account
  253. if [ ! -z "$(grep ^admin: /etc/passwd /etc/group)" ] && [ -z "$force" ]; then
  254. echo 'Please remove admin user account before proceeding.'
  255. echo 'If you want to do it automatically run installer with -f option:'
  256. echo -e "Example: bash $0 --force\n"
  257. check_result 1 "User admin exists"
  258. fi
  259. # Check if a default webserver was set
  260. if [ $apache = 'no' ] && [ $nginx = 'no' ]; then
  261. check_result 1 "No web server was selected"
  262. fi
  263. # Clear the screen once launch permissions have been verified
  264. clear
  265. # Configure apt to retry downloading on error
  266. if [ ! -f /etc/apt/apt.conf.d/80-retries ]; then
  267. echo "APT::Acquire::Retries \"3\";" > /etc/apt/apt.conf.d/80-retries
  268. fi
  269. # Welcome message
  270. echo "Welcome to the Hestia Control Panel installer!"
  271. echo
  272. echo "Please wait, the installer is now checking for missing dependencies..."
  273. echo
  274. # Update apt repository
  275. apt-get -qq update
  276. # Creating backup directory
  277. mkdir -p $hst_backups
  278. # Pre-install packages
  279. echo "[ * ] Installing dependencies..."
  280. apt-get -y install $installer_dependencies >> $LOG
  281. check_result $? "Package installation failed, check log file for more details."
  282. # Check repository availability
  283. wget --quiet "https://$GPG/deb_signing.key" -O /dev/null
  284. check_result $? "Unable to connect to the Hestia APT repository"
  285. # Check installed packages
  286. tmpfile=$(mktemp -p /tmp)
  287. dpkg --get-selections > $tmpfile
  288. conflicts_pkg="exim4 mariadb-server apache2 nginx hestia postfix ufw"
  289. # Drop postfix from the list if exim should not be installed
  290. if [ "$exim" = 'no' ]; then
  291. conflicts_pkg=$(echo $conflicts_pkg | sed 's/postfix//g' | xargs)
  292. fi
  293. for pkg in $conflicts_pkg; do
  294. if [ ! -z "$(grep $pkg $tmpfile)" ]; then
  295. conflicts="$pkg* $conflicts"
  296. fi
  297. done
  298. rm -f $tmpfile
  299. if [ ! -z "$conflicts" ] && [ -z "$force" ]; then
  300. echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
  301. echo
  302. echo 'WARNING: The following packages are already installed'
  303. echo "$conflicts"
  304. echo
  305. echo 'It is highly recommended that you remove them before proceeding.'
  306. echo
  307. echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
  308. echo
  309. read -p 'Would you like to remove the conflicting packages? [y/n] ' answer
  310. if [ "$answer" = 'y' ] || [ "$answer" = 'Y' ]; then
  311. apt-get -qq purge $conflicts -y
  312. check_result $? 'apt-get remove failed'
  313. unset $answer
  314. else
  315. check_result 1 "Hestia Control Panel should be installed on a clean server."
  316. fi
  317. fi
  318. # Check network configuration
  319. if [ -d /etc/netplan ] && [ -z "$force" ]; then
  320. if [ -z "$(ls -A /etc/netplan)" ]; then
  321. echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
  322. echo
  323. echo 'WARNING: Your network configuration may not be set up correctly.'
  324. echo 'Details: The netplan configuration directory is empty.'
  325. echo ''
  326. echo 'You may have a network configuration file that was created using'
  327. echo 'systemd-networkd.'
  328. echo ''
  329. echo 'It is strongly recommended to migrate to netplan, which is now the'
  330. echo 'default network configuration system in newer releases of Ubuntu.'
  331. echo ''
  332. echo 'While you can leave your configuration as-is, please note that you'
  333. echo 'will not be able to use additional IPs properly.'
  334. echo ''
  335. echo 'If you wish to continue and force the installation,'
  336. echo 'run this script with -f option:'
  337. echo "Example: bash $0 --force"
  338. echo
  339. echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
  340. echo
  341. check_result 1 "Unable to detect netplan configuration."
  342. fi
  343. fi
  344. # Validate whether installation script matches release version before continuing with install
  345. if [ -z "$withdebs" ] || [ ! -d "$withdebs" ]; then
  346. release_branch_ver=$(curl -s https://raw.githubusercontent.com/hestiacp/hestiacp/release/src/deb/hestia/control |grep "Version:" |awk '{print $2}')
  347. if [ "$HESTIA_INSTALL_VER" != "$release_branch_ver" ]; then
  348. echo
  349. echo -e "\e[91mInstallation aborted\e[0m"
  350. echo "===================================================================="
  351. echo -e "\e[33mERROR: Install script version does not match package version!\e[0m"
  352. echo -e "\e[33mPlease download the installer from the release branch in order to continue:\e[0m"
  353. echo ""
  354. echo -e "\e[33mhttps://raw.githubusercontent.com/hestiacp/hestiacp/release/install/hst-install.sh\e[0m"
  355. echo ""
  356. echo -e "\e[33mTo test pre-release versions, build the .deb packages and re-run the installer:\e[0m"
  357. echo -e " \e[33m./hst_autocompile.sh \e[1m--hestia branchname no\e[21m\e[0m"
  358. echo -e " \e[33m./hst-install.sh .. \e[1m--with-debs /tmp/hestiacp-src/debs\e[21m\e[0m"
  359. echo ""
  360. check_result 1 "Installation aborted"
  361. fi
  362. fi
  363. case $architecture in
  364. x86_64)
  365. ARCH="amd64"
  366. ;;
  367. aarch64)
  368. ARCH="arm64"
  369. if [ -z "$withdebs" ] || [ ! -d "$withdebs" ]; then
  370. echo
  371. echo -e "\e[91mInstallation aborted\e[0m"
  372. echo "===================================================================="
  373. echo -e "\e[33mERROR: HestiaCP on ARM is currently not supported with install from ATP!\e[0m"
  374. echo -e "\e[33mPlease compile your own packages for HestiaCP. \e[0m"
  375. echo -e "\e[33mPlease follow the instructions at: \e[0m"
  376. echo -e " \e[33mhttps://docs.hestiacp.com/development/panel.html#compiling\e[21m\e[0m"
  377. echo ""
  378. check_result 1 "Installation aborted"
  379. fi
  380. ;;
  381. *)
  382. echo
  383. echo -e "\e[91mInstallation aborted\e[0m"
  384. echo "===================================================================="
  385. echo -e "\e[33mERROR: $architecture is currently not supported!\e[0m"
  386. echo -e "\e[33mPlease verify the achitecture used is currenlty supported\e[0m"
  387. echo ""
  388. echo -e "\e[33mhttps://github.com/hestiacp/hestiacp/blob/main/README.md\e[0m"
  389. echo ""
  390. check_result 1 "Installation aborted"
  391. esac
  392. #----------------------------------------------------------#
  393. # Brief Info #
  394. #----------------------------------------------------------#
  395. install_welcome_message() {
  396. DISPLAY_VER=$(echo $HESTIA_INSTALL_VER | sed "s|~alpha||g" | sed "s|~beta||g")
  397. echo
  398. echo ' _ _ _ _ ____ ____ '
  399. echo ' | | | | ___ ___| |_(_) __ _ / ___| _ \ '
  400. echo ' | |_| |/ _ \/ __| __| |/ _` | | | |_) | '
  401. echo ' | _ | __/\__ \ |_| | (_| | |___| __/ '
  402. echo ' |_| |_|\___||___/\__|_|\__,_|\____|_| '
  403. echo " "
  404. echo " Hestia Control Panel "
  405. if [[ "$HESTIA_INSTALL_VER" =~ "beta" ]]; then
  406. echo " BETA RELEASE "
  407. fi
  408. if [[ "$HESTIA_INSTALL_VER" =~ "alpha" ]]; then
  409. echo " DEVELOPMENT SNAPSHOT "
  410. echo " NOT INTENDED FOR PRODUCTION USE "
  411. echo " USE AT YOUR OWN RISK "
  412. fi
  413. echo " ${DISPLAY_VER} "
  414. echo " www.hestiacp.com "
  415. echo
  416. echo "========================================================================"
  417. echo
  418. echo "Thank you for downloading Hestia Control Panel! In a few moments,"
  419. echo "we will begin installing the following components on your server:"
  420. echo
  421. }
  422. # Printing nice ASCII logo
  423. clear
  424. install_welcome_message
  425. # Web stack
  426. echo ' - NGINX Web / Proxy Server'
  427. if [ "$apache" = 'yes' ] && [ "$nginx" = 'no' ] ; then
  428. echo ' - Apache Web Server'
  429. fi
  430. if [ "$apache" = 'yes' ] && [ "$nginx" = 'yes' ] ; then
  431. echo ' - Apache Web Server (as backend)'
  432. fi
  433. if [ "$phpfpm" = 'yes' ] && [ "$multiphp" = 'no' ]; then
  434. echo ' - PHP-FPM Application Server'
  435. fi
  436. if [ "$multiphp" = 'yes' ]; then
  437. phpfpm='yes'
  438. echo ' - Multi-PHP Environment'
  439. fi
  440. # DNS stack
  441. if [ "$named" = 'yes' ]; then
  442. echo ' - Bind DNS Server'
  443. fi
  444. # Mail stack
  445. if [ "$exim" = 'yes' ]; then
  446. echo -n ' - Exim Mail Server'
  447. if [ "$clamd" = 'yes' ] || [ "$spamd" = 'yes' ] ; then
  448. echo -n ' + '
  449. if [ "$clamd" = 'yes' ]; then
  450. echo -n 'ClamAV '
  451. fi
  452. if [ "$spamd" = 'yes' ]; then
  453. if [ "$clamd" = 'yes' ]; then
  454. echo -n '+ '
  455. fi
  456. echo -n 'SpamAssassin'
  457. fi
  458. fi
  459. echo
  460. if [ "$dovecot" = 'yes' ]; then
  461. echo ' - Dovecot POP3/IMAP Server'
  462. fi
  463. fi
  464. # Database stack
  465. if [ "$mysql" = 'yes' ]; then
  466. echo ' - MariaDB Database Server'
  467. fi
  468. if [ "$postgresql" = 'yes' ]; then
  469. echo ' - PostgreSQL Database Server'
  470. fi
  471. # FTP stack
  472. if [ "$vsftpd" = 'yes' ]; then
  473. echo ' - Vsftpd FTP Server'
  474. fi
  475. if [ "$proftpd" = 'yes' ]; then
  476. echo ' - ProFTPD FTP Server'
  477. fi
  478. # Firewall stack
  479. if [ "$iptables" = 'yes' ]; then
  480. echo -n ' - Firewall (Iptables)'
  481. fi
  482. if [ "$iptables" = 'yes' ] && [ "$fail2ban" = 'yes' ]; then
  483. echo -n ' + Fail2Ban Access Monitor'
  484. fi
  485. echo -e "\n"
  486. echo "========================================================================"
  487. echo -e "\n"
  488. # Asking for confirmation to proceed
  489. if [ "$interactive" = 'yes' ]; then
  490. read -p 'Would you like to continue with the installation? [Y/N]: ' answer
  491. if [ "$answer" != 'y' ] && [ "$answer" != 'Y' ]; then
  492. echo 'Goodbye'
  493. exit 1
  494. fi
  495. # Asking for contact email
  496. if [ -z "$email" ]; then
  497. read -p 'Please enter admin email address: ' email
  498. fi
  499. # Asking to set FQDN hostname
  500. if [ -z "$servername" ]; then
  501. read -p "Please enter FQDN hostname [$(hostname -f)]: " servername
  502. fi
  503. fi
  504. # Generating admin password if it wasn't set
  505. if [ -z "$vpass" ]; then
  506. vpass=$(gen_pass)
  507. fi
  508. # Set hostname if it wasn't set
  509. if [ -z "$servername" ]; then
  510. servername=$(hostname -f)
  511. fi
  512. # Set FQDN if it wasn't set
  513. mask1='(([[:alnum:]](-?[[:alnum:]])*)\.)'
  514. mask2='*[[:alnum:]](-?[[:alnum:]])+\.[[:alnum:]]{2,}'
  515. if ! [[ "$servername" =~ ^${mask1}${mask2}$ ]]; then
  516. if [ ! -z "$servername" ]; then
  517. servername="$servername.example.com"
  518. else
  519. servername="example.com"
  520. fi
  521. echo "127.0.0.1 $servername" >> /etc/hosts
  522. fi
  523. # Set email if it wasn't set
  524. if [ -z "$email" ]; then
  525. email="admin@$servername"
  526. fi
  527. # Defining backup directory
  528. echo -e "Installation backup directory: $hst_backups"
  529. # Print Log File Path
  530. echo "Installation log file: $LOG"
  531. # Print new line
  532. echo
  533. #----------------------------------------------------------#
  534. # Checking swap #
  535. #----------------------------------------------------------#
  536. # Checking swap on small instances
  537. if [ -z "$(swapon -s)" ] && [ $memory -lt 1000000 ]; then
  538. fallocate -l 1G /swapfile
  539. chmod 600 /swapfile
  540. mkswap /swapfile
  541. swapon /swapfile
  542. echo "/swapfile none swap sw 0 0" >> /etc/fstab
  543. fi
  544. #----------------------------------------------------------#
  545. # Install repository #
  546. #----------------------------------------------------------#
  547. # Define apt conf location
  548. apt=/etc/apt/sources.list.d
  549. # Updating system
  550. echo "Adding required repositories to proceed with installation:"
  551. echo
  552. # Installing Nginx repo
  553. echo "[ * ] NGINX"
  554. echo "deb [arch=$ARCH] https://nginx.org/packages/mainline/$VERSION/ $codename nginx" > $apt/nginx.list
  555. apt-key adv --fetch-keys 'https://nginx.org/keys/nginx_signing.key' > /dev/null 2>&1
  556. # Installing sury PHP repo
  557. echo "[ * ] PHP"
  558. LC_ALL=C.UTF-8 add-apt-repository -y ppa:ondrej/php > /dev/null 2>&1
  559. # Installing sury Apache2 repo
  560. if [ "$apache" = 'yes' ]; then
  561. echo "[ * ] Apache2"
  562. echo "deb http://ppa.launchpad.net/ondrej/apache2/ubuntu $codename main" > $apt/apache2.list
  563. fi
  564. # Installing MariaDB repo
  565. if [ "$mysql" = 'yes' ]; then
  566. echo "[ * ] MariaDB"
  567. echo "deb [arch=$ARCH] https://mirror.mva-n.net/mariadb/repo/$mariadb_v/$VERSION $codename main" > $apt/mariadb.list
  568. apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc' > /dev/null 2>&1
  569. fi
  570. # Installing HestiaCP repo
  571. echo "[ * ] Hestia Control Panel"
  572. if [ "$ARCH" = "amd64" ]; then
  573. echo "deb https://$RHOST/ $codename main" > $apt/hestia.list
  574. else
  575. echo "# deb https://$RHOST/ $codename main" > $apt/hestia.list
  576. echo -e "\e[91m[ ! ] HestiaCP on ARM is currently in Development.\e[0m"
  577. echo -e "\e[91m This will mean that we don't provide any packages and you are responisble\e[0m"
  578. echo -e "\e[91m for building the packages your self. To build your own packeges see\e[0m"
  579. echo -e "\e[91m https://docs.hestiacp.com/development/panel.html#compiling\e[0m"
  580. fi
  581. apt-key adv --keyserver keyserver.ubuntu.com --recv-keys A189E93654F0B0E5 > /dev/null 2>&1
  582. # Installing PostgreSQL repo
  583. if [ "$postgresql" = 'yes' ]; then
  584. echo "[ * ] PostgreSQL"
  585. echo "deb [arch=$ARCH] https://apt.postgresql.org/pub/repos/apt/ $codename-pgdg main" > $apt/postgresql.list
  586. apt-key adv --fetch-keys 'https://www.postgresql.org/media/keys/ACCC4CF8.asc' > /dev/null 2>&1
  587. fi
  588. # Echo for a new line
  589. echo
  590. # Updating system
  591. echo -ne "Updating currently installed packages, please wait... "
  592. apt-get -qq update
  593. apt-get -y upgrade >> $LOG &
  594. BACK_PID=$!
  595. # Check if package installation is done, print a spinner
  596. spin_i=1
  597. while kill -0 $BACK_PID > /dev/null 2>&1 ; do
  598. printf "\b${spinner:spin_i++%${#spinner}:1}"
  599. sleep 0.5
  600. done
  601. # Do a blank echo to get the \n back
  602. echo
  603. # Check Installation result
  604. wait $BACK_PID
  605. check_result $? 'apt-get upgrade failed'
  606. #----------------------------------------------------------#
  607. # Backup #
  608. #----------------------------------------------------------#
  609. # Creating backup directory tree
  610. mkdir -p $hst_backups
  611. cd $hst_backups
  612. mkdir nginx apache2 php vsftpd proftpd bind exim4 dovecot clamd
  613. mkdir spamassassin mysql postgresql hestia
  614. # Backup nginx configuration
  615. systemctl stop nginx > /dev/null 2>&1
  616. cp -r /etc/nginx/* $hst_backups/nginx > /dev/null 2>&1
  617. # Backup Apache configuration
  618. systemctl stop apache2 > /dev/null 2>&1
  619. cp -r /etc/apache2/* $hst_backups/apache2 > /dev/null 2>&1
  620. rm -f /etc/apache2/conf.d/* > /dev/null 2>&1
  621. # Backup PHP-FPM configuration
  622. systemctl stop php*-fpm > /dev/null 2>&1
  623. cp -r /etc/php/* $hst_backups/php/ > /dev/null 2>&1
  624. # Backup Bind configuration
  625. systemctl stop bind9 > /dev/null 2>&1
  626. cp -r /etc/bind/* $hst_backups/bind > /dev/null 2>&1
  627. # Backup Vsftpd configuration
  628. systemctl stop vsftpd > /dev/null 2>&1
  629. cp /etc/vsftpd.conf $hst_backups/vsftpd > /dev/null 2>&1
  630. # Backup ProFTPD configuration
  631. systemctl stop proftpd > /dev/null 2>&1
  632. cp /etc/proftpd/* $hst_backups/proftpd > /dev/null 2>&1
  633. # Backup Exim configuration
  634. systemctl stop exim4 > /dev/null 2>&1
  635. cp -r /etc/exim4/* $hst_backups/exim4 > /dev/null 2>&1
  636. # Backup ClamAV configuration
  637. systemctl stop clamav-daemon > /dev/null 2>&1
  638. cp -r /etc/clamav/* $hst_backups/clamav > /dev/null 2>&1
  639. # Backup SpamAssassin configuration
  640. systemctl stop spamassassin > /dev/null 2>&1
  641. cp -r /etc/spamassassin/* $hst_backups/spamassassin > /dev/null 2>&1
  642. # Backup Dovecot configuration
  643. systemctl stop dovecot > /dev/null 2>&1
  644. cp /etc/dovecot.conf $hst_backups/dovecot > /dev/null 2>&1
  645. cp -r /etc/dovecot/* $hst_backups/dovecot > /dev/null 2>&1
  646. # Backup MySQL/MariaDB configuration and data
  647. systemctl stop mysql > /dev/null 2>&1
  648. killall -9 mysqld > /dev/null 2>&1
  649. mv /var/lib/mysql $hst_backups/mysql/mysql_datadir > /dev/null 2>&1
  650. cp -r /etc/mysql/* $hst_backups/mysql > /dev/null 2>&1
  651. mv -f /root/.my.cnf $hst_backups/mysql > /dev/null 2>&1
  652. # Backup Hestia
  653. systemctl stop hestia > /dev/null 2>&1
  654. cp -r $HESTIA/* $hst_backups/hestia > /dev/null 2>&1
  655. apt-get -y purge hestia hestia-nginx hestia-php > /dev/null 2>&1
  656. rm -rf $HESTIA > /dev/null 2>&1
  657. #----------------------------------------------------------#
  658. # Package Includes #
  659. #----------------------------------------------------------#
  660. if [ "$phpfpm" = 'yes' ]; then
  661. fpm="php$fpm_v php$fpm_v-common php$fpm_v-bcmath php$fpm_v-cli
  662. php$fpm_v-curl php$fpm_v-fpm php$fpm_v-gd php$fpm_v-intl
  663. php$fpm_v-mysql php$fpm_v-soap php$fpm_v-xml php$fpm_v-zip
  664. php$fpm_v-mbstring php$fpm_v-json php$fpm_v-bz2 php$fpm_v-pspell
  665. php$fpm_v-imagick"
  666. software="$software $fpm"
  667. fi
  668. #----------------------------------------------------------#
  669. # Package Excludes #
  670. #----------------------------------------------------------#
  671. # Excluding packages
  672. software=$(echo "$software" | sed -e "s/apache2.2-common//")
  673. if [ "$apache" = 'no' ]; then
  674. software=$(echo "$software" | sed -e "s/apache2 //")
  675. software=$(echo "$software" | sed -e "s/apache2-bin//")
  676. software=$(echo "$software" | sed -e "s/apache2-utils//")
  677. software=$(echo "$software" | sed -e "s/apache2-suexec-custom//")
  678. software=$(echo "$software" | sed -e "s/apache2.2-common//")
  679. software=$(echo "$software" | sed -e "s/libapache2-mod-rpaf//")
  680. software=$(echo "$software" | sed -e "s/libapache2-mod-fcgid//")
  681. software=$(echo "$software" | sed -e "s/libapache2-mod-php$fpm_v//")
  682. fi
  683. if [ "$vsftpd" = 'no' ]; then
  684. software=$(echo "$software" | sed -e "s/vsftpd//")
  685. fi
  686. if [ "$proftpd" = 'no' ]; then
  687. software=$(echo "$software" | sed -e "s/proftpd-basic//")
  688. software=$(echo "$software" | sed -e "s/proftpd-mod-vroot//")
  689. fi
  690. if [ "$named" = 'no' ]; then
  691. software=$(echo "$software" | sed -e "s/bind9//")
  692. fi
  693. if [ "$exim" = 'no' ]; then
  694. software=$(echo "$software" | sed -e "s/exim4 //")
  695. software=$(echo "$software" | sed -e "s/exim4-daemon-heavy//")
  696. software=$(echo "$software" | sed -e "s/dovecot-imapd//")
  697. software=$(echo "$software" | sed -e "s/dovecot-pop3d//")
  698. software=$(echo "$software" | sed -e "s/clamav-daemon//")
  699. software=$(echo "$software" | sed -e "s/spamassassin//")
  700. fi
  701. if [ "$clamd" = 'no' ]; then
  702. software=$(echo "$software" | sed -e "s/clamav-daemon//")
  703. fi
  704. if [ "$spamd" = 'no' ]; then
  705. software=$(echo "$software" | sed -e "s/spamassassin//")
  706. fi
  707. if [ "$dovecot" = 'no' ]; then
  708. software=$(echo "$software" | sed -e "s/dovecot-imapd//")
  709. software=$(echo "$software" | sed -e "s/dovecot-pop3d//")
  710. fi
  711. if [ "$mysql" = 'no' ]; then
  712. software=$(echo "$software" | sed -e "s/mariadb-server//")
  713. software=$(echo "$software" | sed -e "s/mariadb-client//")
  714. software=$(echo "$software" | sed -e "s/mariadb-common//")
  715. software=$(echo "$software" | sed -e "s/php$fpm_v-mysql//")
  716. if [ "$multiphp" = 'yes' ]; then
  717. for v in "${multiphp_v[@]}"; do
  718. software=$(echo "$software" | sed -e "s/php$v-mysql//")
  719. software=$(echo "$software" | sed -e "s/php$v-bz2//")
  720. done
  721. fi
  722. fi
  723. if [ "$postgresql" = 'no' ]; then
  724. software=$(echo "$software" | sed -e "s/postgresql-contrib//")
  725. software=$(echo "$software" | sed -e "s/postgresql//")
  726. software=$(echo "$software" | sed -e "s/php$fpm_v-pgsql//")
  727. if [ "$multiphp" = 'yes' ]; then
  728. for v in "${multiphp_v[@]}"; do
  729. software=$(echo "$software" | sed -e "s/php$v-pgsql//")
  730. done
  731. fi
  732. software=$(echo "$software" | sed -e "s/phppgadmin//")
  733. fi
  734. if [ "$fail2ban" = 'no' ]; then
  735. software=$(echo "$software" | sed -e "s/fail2ban//")
  736. fi
  737. if [ "$iptables" = 'no' ]; then
  738. software=$(echo "$software" | sed -e "s/ipset//")
  739. software=$(echo "$software" | sed -e "s/fail2ban//")
  740. fi
  741. if [ "$phpfpm" = 'yes' ]; then
  742. software=$(echo "$software" | sed -e "s/php$fpm_v-cgi//")
  743. software=$(echo "$software" | sed -e "s/libapache2-mod-ruid2//")
  744. software=$(echo "$software" | sed -e "s/libapache2-mod-php$fpm_v//")
  745. fi
  746. if [ -d "$withdebs" ]; then
  747. software=$(echo "$software" | sed -e "s/hestia-nginx//")
  748. software=$(echo "$software" | sed -e "s/hestia-php//")
  749. software=$(echo "$software" | sed -e "s/hestia=${HESTIA_INSTALL_VER}//")
  750. fi
  751. if [ "$release" = '18.04' ]; then
  752. software=$(echo "$software" | sed -e "s/libonig5/libonig4/")
  753. software=$(echo "$software" | sed -e "s/libzip5/libzip4/")
  754. fi
  755. if [ "$release" = '20.04' ]; then
  756. software=$(echo "$software" | sed -e "s/setpriv/util-linux/")
  757. software=$(echo "$software" | sed -e "s/rssh//")
  758. fi
  759. #----------------------------------------------------------#
  760. # Disable Apparmor on LXC #
  761. #----------------------------------------------------------#
  762. if grep --quiet lxc /proc/1/environ; then
  763. if [ -f /etc/init.d/apparmor ]; then
  764. systemctl stop apparmor > /dev/null 2>&1
  765. systemctl disable apparmor > /dev/null 2>&1
  766. fi
  767. fi
  768. #----------------------------------------------------------#
  769. # Install packages #
  770. #----------------------------------------------------------#
  771. # Disabling daemon autostart on apt-get install
  772. echo -e '#!/bin/sh\nexit 101' > /usr/sbin/policy-rc.d
  773. chmod a+x /usr/sbin/policy-rc.d
  774. # Installing apt packages
  775. echo "The installer is now downloading and installing all required packages."
  776. echo -ne "NOTE: This process may take 10 to 15 minutes to complete, please wait... "
  777. echo
  778. apt-get -y install $software > /dev/null 2>&1 &
  779. BACK_PID=$!
  780. # Check if package installation is done, print a spinner
  781. spin_i=1
  782. while kill -0 $BACK_PID > /dev/null 2>&1 ; do
  783. printf "\b${spinner:spin_i++%${#spinner}:1}"
  784. sleep 0.5
  785. done
  786. # Do a blank echo to get the \n back
  787. echo
  788. # Check Installation result
  789. wait $BACK_PID
  790. check_result $? "apt-get install failed"
  791. echo
  792. echo "========================================================================"
  793. echo
  794. # Install Hestia packages from local folder
  795. if [ ! -z "$withdebs" ] && [ -d "$withdebs" ]; then
  796. echo "[ * ] Installing local package files..."
  797. echo " - hestia core package"
  798. dpkg -i $withdebs/hestia_*.deb > /dev/null 2>&1
  799. if [ -z $(ls $withdebs/hestia-php_*.deb 2>/dev/null) ]; then
  800. echo " - hestia-php backend package (from apt)"
  801. apt-get -y install hestia-php > /dev/null 2>&1
  802. else
  803. echo " - hestia-php backend package"
  804. dpkg -i $withdebs/hestia-php_*.deb > /dev/null 2>&1
  805. fi
  806. if [ -z $(ls $withdebs/hestia-nginx_*.deb 2>/dev/null) ]; then
  807. echo " - hestia-nginx backend package (from apt)"
  808. apt-get -y install hestia-nginx > /dev/null 2>&1
  809. else
  810. echo " - hestia-nginx backend package"
  811. dpkg -i $withdebs/hestia-nginx_*.deb > /dev/null 2>&1
  812. fi
  813. fi
  814. # Restoring autostart policy
  815. rm -f /usr/sbin/policy-rc.d
  816. #----------------------------------------------------------#
  817. # Configure system #
  818. #----------------------------------------------------------#
  819. echo "[ * ] Configuring system settings..."
  820. # Enable SFTP subsystem for SSH
  821. sftp_subsys_enabled=$(grep -iE "^#?.*subsystem.+(sftp )?sftp-server" /etc/ssh/sshd_config)
  822. if [ ! -z "$sftp_subsys_enabled" ]; then
  823. sed -i -E "s/^#?.*Subsystem.+(sftp )?sftp-server/Subsystem sftp internal-sftp/g" /etc/ssh/sshd_config
  824. fi
  825. # Reduce SSH login grace time
  826. sed -i "s/[#]LoginGraceTime [[:digit:]]m/LoginGraceTime 1m/g" /etc/ssh/sshd_config
  827. # Disable SSH suffix broadcast
  828. if [ -z "$(grep "^DebianBanner no" /etc/ssh/sshd_config)" ]; then
  829. echo '' >> /etc/ssh/sshd_config
  830. echo 'DebianBanner no' >> /etc/ssh/sshd_config
  831. fi
  832. # Restart SSH daemon
  833. systemctl restart ssh
  834. # Disable AWStats cron
  835. rm -f /etc/cron.d/awstats
  836. # Set directory color
  837. if [ -z "$(grep 'LS_COLORS="$LS_COLORS:di=00;33"' /etc/profile)" ]; then
  838. echo 'LS_COLORS="$LS_COLORS:di=00;33"' >> /etc/profile
  839. fi
  840. # Registering /usr/sbin/nologin
  841. if [ -z "$(grep nologin /etc/shells)" ]; then
  842. echo "/usr/sbin/nologin" >> /etc/shells
  843. fi
  844. # Configuring NTP
  845. sed -i 's/#NTP=/NTP=pool.ntp.org/' /etc/systemd/timesyncd.conf
  846. systemctl enable systemd-timesyncd
  847. systemctl start systemd-timesyncd
  848. # Setup rssh
  849. if [ "$release" != '20.04' ]; then
  850. if [ -z "$(grep /usr/bin/rssh /etc/shells)" ]; then
  851. echo /usr/bin/rssh >> /etc/shells
  852. fi
  853. sed -i 's/#allowscp/allowscp/' /etc/rssh.conf
  854. sed -i 's/#allowsftp/allowsftp/' /etc/rssh.conf
  855. sed -i 's/#allowrsync/allowrsync/' /etc/rssh.conf
  856. chmod 755 /usr/bin/rssh
  857. fi
  858. # Check iptables paths and add symlinks when necessary
  859. if [ ! -e "/sbin/iptables" ]; then
  860. if which iptables; then
  861. ln -s "$(which iptables)" /sbin/iptables
  862. elif [ -e "/usr/sbin/iptables" ]; then
  863. ln -s /usr/sbin/iptables /sbin/iptables
  864. elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables; then
  865. autoiptables=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables | cut -d '' -f 2)
  866. if [ -x "$autoiptables" ]; then
  867. ln -s "$autoiptables" /sbin/iptables
  868. fi
  869. fi
  870. fi
  871. if [ ! -e "/sbin/iptables-save" ]; then
  872. if which iptables-save; then
  873. ln -s "$(which iptables-save)" /sbin/iptables-save
  874. elif [ -e "/usr/sbin/iptables-save" ]; then
  875. ln -s /usr/sbin/iptables-save /sbin/iptables-save
  876. elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save; then
  877. autoiptables_save=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-save | cut -d '' -f 2)
  878. if [ -x "$autoiptables_save" ]; then
  879. ln -s "$autoiptables_save" /sbin/iptables-save
  880. fi
  881. fi
  882. fi
  883. if [ ! -e "/sbin/iptables-restore" ]; then
  884. if which iptables-restore; then
  885. ln -s "$(which iptables-restore)" /sbin/iptables-restore
  886. elif [ -e "/usr/sbin/iptables-restore" ]; then
  887. ln -s /usr/sbin/iptables-restore /sbin/iptables-restore
  888. elif whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore; then
  889. autoiptables_restore=$(whereis -B /bin /sbin /usr/bin /usr/sbin -f -b iptables-restore | cut -d '' -f 2)
  890. if [ -x "$autoiptables_restore" ]; then
  891. ln -s "$autoiptables_restore" /sbin/iptables-restore
  892. fi
  893. fi
  894. fi
  895. # Restrict access to /proc fs
  896. # - Prevent unpriv users from seeing each other running processes
  897. mount -o remount,defaults,hidepid=2 /proc > /dev/null 2>&1
  898. if [ $? -ne 0 ]; then
  899. echo "Info: Cannot remount /proc (LXC containers require additional perm added to host apparmor profile)"
  900. else
  901. echo "@reboot root sleep 5 && mount -o remount,defaults,hidepid=2 /proc" > /etc/cron.d/hestia-proc
  902. fi
  903. #----------------------------------------------------------#
  904. # Configure Hestia #
  905. #----------------------------------------------------------#
  906. echo "[ * ] Configuring Hestia Control Panel..."
  907. # Installing sudo configuration
  908. mkdir -p /etc/sudoers.d
  909. cp -f $HESTIA_INSTALL_DIR/sudo/admin /etc/sudoers.d/
  910. chmod 440 /etc/sudoers.d/admin
  911. # Add Hestia global config
  912. if [[ ! -e /etc/hestiacp/hestia.conf ]]; then
  913. mkdir -p /etc/hestiacp
  914. echo -e "# Do not edit this file, will get overwritten on next upgrade, use /etc/hestiacp/local.conf instead\n\nexport HESTIA='/usr/local/hestia'\n\n[[ -f /etc/hestiacp/local.conf ]] && source /etc/hestiacp/local.conf" > /etc/hestiacp/hestia.conf
  915. fi
  916. # Configuring system env
  917. echo "export HESTIA='$HESTIA'" > /etc/profile.d/hestia.sh
  918. echo 'PATH=$PATH:'$HESTIA'/bin' >> /etc/profile.d/hestia.sh
  919. echo 'export PATH' >> /etc/profile.d/hestia.sh
  920. chmod 755 /etc/profile.d/hestia.sh
  921. source /etc/profile.d/hestia.sh
  922. # Configuring logrotate for Hestia logs
  923. cp -f $HESTIA_INSTALL_DIR/logrotate/hestia /etc/logrotate.d/hestia
  924. # Building directory tree and creating some blank files for Hestia
  925. mkdir -p $HESTIA/conf $HESTIA/log $HESTIA/ssl $HESTIA/data/ips \
  926. $HESTIA/data/queue $HESTIA/data/users $HESTIA/data/firewall \
  927. $HESTIA/data/sessions
  928. touch $HESTIA/data/queue/backup.pipe $HESTIA/data/queue/disk.pipe \
  929. $HESTIA/data/queue/webstats.pipe $HESTIA/data/queue/restart.pipe \
  930. $HESTIA/data/queue/traffic.pipe $HESTIA/data/queue/daily.pipe $HESTIA/log/system.log \
  931. $HESTIA/log/nginx-error.log $HESTIA/log/auth.log
  932. chmod 750 $HESTIA/conf $HESTIA/data/users $HESTIA/data/ips $HESTIA/log
  933. chmod -R 750 $HESTIA/data/queue
  934. chmod 660 $HESTIA/log/*
  935. rm -f /var/log/hestia
  936. ln -s $HESTIA/log /var/log/hestia
  937. chmod 770 $HESTIA/data/sessions
  938. # Generating Hestia configuration
  939. rm -f $HESTIA/conf/hestia.conf > /dev/null 2>&1
  940. touch $HESTIA/conf/hestia.conf
  941. chmod 660 $HESTIA/conf/hestia.conf
  942. # Web stack
  943. if [ "$apache" = 'yes' ]; then
  944. write_config_value "WEB_SYSTEM" "apache2"
  945. write_config_value "WEB_RGROUPS" "www-data"
  946. write_config_value "WEB_PORT" "8080"
  947. write_config_value "WEB_SSL_PORT" "8443"
  948. write_config_value "WEB_SSL" "mod_ssl"
  949. write_config_value "PROXY_SYSTEM" "nginx"
  950. write_config_value "PROXY_PORT" "80"
  951. write_config_value "PROXY_SSL_PORT" "443"
  952. write_config_value "STATS_SYSTEM" "awstats"
  953. fi
  954. if [ "$apache" = 'no' ]; then
  955. write_config_value "WEB_SYSTEM" "nginx"
  956. write_config_value "WEB_PORT" "80"
  957. write_config_value "WEB_SSL_PORT" "443"
  958. write_config_value "WEB_SSL" "openssl"
  959. write_config_value "STATS_SYSTEM" "awstats"
  960. fi
  961. if [ "$phpfpm" = 'yes' ] || [ "$multiphp" = 'yes' ]; then
  962. write_config_value "WEB_BACKEND" "php-fpm"
  963. fi
  964. # Database stack
  965. if [ "$mysql" = 'yes' ]; then
  966. installed_db_types='mysql'
  967. fi
  968. if [ "$postgresql" = 'yes' ]; then
  969. installed_db_types="$installed_db_types,pgsql"
  970. fi
  971. if [ ! -z "$installed_db_types" ]; then
  972. db=$(echo "$installed_db_types" |\
  973. sed "s/,/\n/g"|\
  974. sort -r -u |\
  975. sed "/^$/d"|\
  976. sed ':a;N;$!ba;s/\n/,/g')
  977. write_config_value "DB_SYSTEM" "$db"
  978. fi
  979. # FTP stack
  980. if [ "$vsftpd" = 'yes' ]; then
  981. write_config_value "FTP_SYSTEM" "vsftpd"
  982. fi
  983. if [ "$proftpd" = 'yes' ]; then
  984. write_config_value "FTP_SYSTEM" "proftpd"
  985. fi
  986. # DNS stack
  987. if [ "$named" = 'yes' ]; then
  988. write_config_value "DNS_SYSTEM" "bind9"
  989. fi
  990. # Mail stack
  991. if [ "$exim" = 'yes' ]; then
  992. write_config_value "MAIL_SYSTEM" "exim4"
  993. if [ "$clamd" = 'yes' ]; then
  994. write_config_value "ANTIVIRUS_SYSTEM" "clamav-daemon"
  995. fi
  996. if [ "$spamd" = 'yes' ]; then
  997. write_config_value "ANTISPAM_SYSTEM" "spamassassin"
  998. fi
  999. if [ "$dovecot" = 'yes' ]; then
  1000. write_config_value "IMAP_SYSTEM" "dovecot"
  1001. fi
  1002. fi
  1003. # Cron daemon
  1004. write_config_value "CRON_SYSTEM" "cron"
  1005. # Firewall stack
  1006. if [ "$iptables" = 'yes' ]; then
  1007. write_config_value "FIREWALL_SYSTEM" "iptables"
  1008. fi
  1009. if [ "$iptables" = 'yes' ] && [ "$fail2ban" = 'yes' ]; then
  1010. write_config_value "FIREWALL_EXTENSION" "fail2ban"
  1011. fi
  1012. # Disk quota
  1013. if [ "$quota" = 'yes' ]; then
  1014. write_config_value "DISK_QUOTA" "yes"
  1015. else
  1016. write_config_value "DISK_QUOTA" "no"
  1017. fi
  1018. # Backups
  1019. write_config_value "BACKUP_SYSTEM" "local"
  1020. write_config_value "BACKUP_GZIP" "4"
  1021. write_config_value "BACKUP_MODE" "zstd"
  1022. # Language
  1023. write_config_value "LANGUAGE" "$lang"
  1024. # Login in screen
  1025. write_config_value "LOGIN_STYLE" "default"
  1026. # Theme
  1027. write_config_value "THEME" "dark"
  1028. # Inactive session timeout
  1029. write_config_value "INACTIVE_SESSION_TIMEOUT" "60"
  1030. # Version & Release Branch
  1031. write_config_value "VERSION" "${HESTIA_INSTALL_VER}"
  1032. write_config_value "RELEASE_BRANCH" "release"
  1033. # Email notifications after upgrade
  1034. write_config_value "UPGRADE_SEND_EMAIL" "true"
  1035. write_config_value "UPGRADE_SEND_EMAIL_LOG" "false"
  1036. # Installing hosting packages
  1037. cp -rf $HESTIA_INSTALL_DIR/packages $HESTIA/data/
  1038. # Update nameservers in hosting package
  1039. IFS='.' read -r -a domain_elements <<< "$servername"
  1040. if [ ! -z "${domain_elements[-2]}" ] && [ ! -z "${domain_elements[-1]}" ]; then
  1041. serverdomain="${domain_elements[-2]}.${domain_elements[-1]}"
  1042. sed -i s/"domain.tld"/"$serverdomain"/g $HESTIA/data/packages/*.pkg
  1043. fi
  1044. # Installing templates
  1045. cp -rf $HESTIA_INSTALL_DIR/templates $HESTIA/data/
  1046. mkdir -p /var/www/html
  1047. mkdir -p /var/www/document_errors
  1048. # Install default success page
  1049. cp -rf $HESTIA_INSTALL_DIR/templates/web/unassigned/index.html /var/www/html/
  1050. cp -rf $HESTIA_INSTALL_DIR/templates/web/skel/document_errors/* /var/www/document_errors/
  1051. # Installing firewall rules
  1052. cp -rf $HESTIA_INSTALL_DIR/firewall $HESTIA/data/
  1053. # Configuring server hostname
  1054. $HESTIA/bin/v-change-sys-hostname $servername 'no' > /dev/null 2>&1
  1055. # Generating SSL certificate
  1056. echo "[ * ] Generating default self-signed SSL certificate..."
  1057. if [ "$release" = "18.04" ]; then
  1058. $HESTIA/bin/v-generate-ssl-cert $(hostname) $email 'US' 'California' \
  1059. 'San Francisco' 'Hestia Control Panel' 'IT' > /tmp/hst.pem
  1060. else
  1061. $HESTIA/bin/v-generate-ssl-cert $(hostname) '' 'US' 'California' \
  1062. 'San Francisco' 'Hestia Control Panel' 'IT' > /tmp/hst.pem
  1063. fi
  1064. # Parsing certificate file
  1065. crt_end=$(grep -n "END CERTIFICATE-" /tmp/hst.pem |cut -f 1 -d:)
  1066. key_start=$(grep -n "BEGIN RSA" /tmp/hst.pem |cut -f 1 -d:)
  1067. key_end=$(grep -n "END RSA" /tmp/hst.pem |cut -f 1 -d:)
  1068. # Adding SSL certificate
  1069. echo "[ * ] Adding SSL certificate to Hestia Control Panel..."
  1070. cd $HESTIA/ssl
  1071. sed -n "1,${crt_end}p" /tmp/hst.pem > certificate.crt
  1072. sed -n "$key_start,${key_end}p" /tmp/hst.pem > certificate.key
  1073. chown root:mail $HESTIA/ssl/*
  1074. chmod 660 $HESTIA/ssl/*
  1075. rm /tmp/hst.pem
  1076. # Adding nologin as a valid system shell
  1077. if [ -z "$(grep nologin /etc/shells)" ]; then
  1078. echo "/usr/sbin/nologin" >> /etc/shells
  1079. fi
  1080. # Install dhparam.pem
  1081. cp -f $HESTIA_INSTALL_DIR/ssl/dhparam.pem /etc/ssl
  1082. # Deleting old admin user
  1083. if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" = 'yes' ]; then
  1084. chattr -i /home/admin/conf > /dev/null 2>&1
  1085. userdel -f admin > /dev/null 2>&1
  1086. chattr -i /home/admin/conf > /dev/null 2>&1
  1087. mv -f /home/admin $hst_backups/home/ > /dev/null 2>&1
  1088. rm -f /tmp/sess_* > /dev/null 2>&1
  1089. fi
  1090. if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" = 'yes' ]; then
  1091. groupdel admin > /dev/null 2>&1
  1092. fi
  1093. # Enable sftp jail
  1094. echo "[ * ] Enable SFTP jail..."
  1095. $HESTIA/bin/v-add-sys-sftp-jail > /dev/null 2>&1
  1096. check_result $? "can't enable sftp jail"
  1097. # Adding Hestia admin account
  1098. echo "[ * ] Create admin account..."
  1099. $HESTIA/bin/v-add-user admin $vpass $email default "System Administrator"
  1100. check_result $? "can't create admin user"
  1101. $HESTIA/bin/v-change-user-shell admin nologin
  1102. $HESTIA/bin/v-change-user-role admin admin
  1103. $HESTIA/bin/v-change-user-language admin $lang
  1104. $HESTIA/bin/v-change-sys-config-value 'POLICY_SYSTEM_PROTECTED_ADMIN' 'yes'
  1105. #----------------------------------------------------------#
  1106. # Configure Nginx #
  1107. #----------------------------------------------------------#
  1108. echo "[ * ] Configuring NGINX..."
  1109. rm -f /etc/nginx/conf.d/*.conf
  1110. cp -f $HESTIA_INSTALL_DIR/nginx/nginx.conf /etc/nginx/
  1111. cp -f $HESTIA_INSTALL_DIR/nginx/status.conf /etc/nginx/conf.d/
  1112. cp -f $HESTIA_INSTALL_DIR/nginx/agents.conf /etc/nginx/conf.d/
  1113. cp -f $HESTIA_INSTALL_DIR/nginx/phpmyadmin.inc /etc/nginx/conf.d/
  1114. cp -f $HESTIA_INSTALL_DIR/nginx/phppgadmin.inc /etc/nginx/conf.d/
  1115. cp -f $HESTIA_INSTALL_DIR/logrotate/nginx /etc/logrotate.d/
  1116. mkdir -p /etc/nginx/conf.d/domains
  1117. mkdir -p /etc/nginx/modules-enabled
  1118. mkdir -p /var/log/nginx/domains
  1119. # Update dns servers in nginx.conf
  1120. dns_resolver=$(cat /etc/resolv.conf | grep -i '^nameserver' | cut -d ' ' -f2 | tr '\r\n' ' ' | xargs)
  1121. for ip in $dns_resolver; do
  1122. if [[ $ip =~ ^[0-9]+\.[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
  1123. resolver="$ip $resolver"
  1124. fi
  1125. done
  1126. if [ ! -z "$resolver" ]; then
  1127. sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /etc/nginx/nginx.conf
  1128. sed -i "s/1.0.0.1 1.1.1.1/$resolver/g" /usr/local/hestia/nginx/conf/nginx.conf
  1129. fi
  1130. update-rc.d nginx defaults > /dev/null 2>&1
  1131. systemctl start nginx >> $LOG
  1132. check_result $? "nginx start failed"
  1133. #----------------------------------------------------------#
  1134. # Configure Apache #
  1135. #----------------------------------------------------------#
  1136. if [ "$apache" = 'yes' ]; then
  1137. echo "[ * ] Configuring Apache Web Server..."
  1138. mkdir -p /etc/apache2/conf.d
  1139. mkdir -p /etc/apache2/conf.d/domains
  1140. # Copy configuration files
  1141. cp -f $HESTIA_INSTALL_DIR/apache2/apache2.conf /etc/apache2/
  1142. cp -f $HESTIA_INSTALL_DIR/apache2/status.conf /etc/apache2/mods-available/hestia-status.conf
  1143. cp -f /etc/apache2/mods-available/status.load /etc/apache2/mods-available/hestia-status.load
  1144. cp -f $HESTIA_INSTALL_DIR/logrotate/apache2 /etc/logrotate.d/
  1145. # Enable needed modules
  1146. a2enmod rewrite > /dev/null 2>&1
  1147. a2enmod suexec > /dev/null 2>&1
  1148. a2enmod ssl > /dev/null 2>&1
  1149. a2enmod actions > /dev/null 2>&1
  1150. a2dismod --quiet status > /dev/null 2>&1
  1151. a2enmod --quiet hestia-status > /dev/null 2>&1
  1152. # Enable mod_ruid/mpm_itk or mpm_event
  1153. if [ "$phpfpm" = 'yes' ]; then
  1154. # Disable prefork and php, enable event
  1155. a2dismod php$fpm_v > /dev/null 2>&1
  1156. a2dismod mpm_prefork > /dev/null 2>&1
  1157. a2enmod mpm_event > /dev/null 2>&1
  1158. cp -f $HESTIA_INSTALL_DIR/apache2/hestia-event.conf /etc/apache2/conf.d/
  1159. else
  1160. a2enmod ruid2 > /dev/null 2>&1
  1161. fi
  1162. echo "# Powered by hestia" > /etc/apache2/sites-available/default
  1163. echo "# Powered by hestia" > /etc/apache2/sites-available/default-ssl
  1164. echo "# Powered by hestia" > /etc/apache2/ports.conf
  1165. echo -e "/home\npublic_html/cgi-bin" > /etc/apache2/suexec/www-data
  1166. touch /var/log/apache2/access.log /var/log/apache2/error.log
  1167. mkdir -p /var/log/apache2/domains
  1168. chmod a+x /var/log/apache2
  1169. chmod 640 /var/log/apache2/access.log /var/log/apache2/error.log
  1170. chmod 751 /var/log/apache2/domains
  1171. # Prevent remote access to server-status page
  1172. sed -i '/Allow from all/d' /etc/apache2/mods-available/hestia-status.conf
  1173. update-rc.d apache2 defaults > /dev/null 2>&1
  1174. systemctl start apache2 >> $LOG
  1175. check_result $? "apache2 start failed"
  1176. else
  1177. update-rc.d apache2 disable > /dev/null 2>&1
  1178. systemctl stop apache2 > /dev/null 2>&1
  1179. fi
  1180. #----------------------------------------------------------#
  1181. # Configure PHP-FPM #
  1182. #----------------------------------------------------------#
  1183. if [ "$multiphp" = 'yes' ] ; then
  1184. for v in "${multiphp_v[@]}"; do
  1185. rm -f /etc/php/$v/fpm/pool.d/*
  1186. echo "[ * ] Install PHP version $v..."
  1187. $HESTIA/bin/v-add-web-php "$v" > /dev/null 2>&1
  1188. done
  1189. fi
  1190. if [ "$phpfpm" = 'yes' ]; then
  1191. echo "[ * ] Configuring PHP-FPM..."
  1192. $HESTIA/bin/v-add-web-php "$fpm_v" > /dev/null 2>&1
  1193. cp -f $HESTIA_INSTALL_DIR/php-fpm/www.conf /etc/php/$fpm_v/fpm/pool.d/www.conf
  1194. update-rc.d php$fpm_v-fpm defaults > /dev/null 2>&1
  1195. systemctl start php$fpm_v-fpm >> $LOG
  1196. check_result $? "php-fpm start failed"
  1197. update-alternatives --set php /usr/bin/php$fpm_v > /dev/null 2>&1
  1198. fi
  1199. #----------------------------------------------------------#
  1200. # Configure PHP #
  1201. #----------------------------------------------------------#
  1202. echo "[ * ] Configuring PHP..."
  1203. ZONE=$(timedatectl > /dev/null 2>&1|grep Timezone|awk '{print $2}')
  1204. if [ -z "$ZONE" ]; then
  1205. ZONE='UTC'
  1206. fi
  1207. for pconf in $(find /etc/php* -name php.ini); do
  1208. sed -i "s%;date.timezone =%date.timezone = $ZONE%g" $pconf
  1209. sed -i 's%_open_tag = Off%_open_tag = On%g' $pconf
  1210. done
  1211. # Cleanup php session files not changed in the last 7 days (60*24*7 minutes)
  1212. echo '#!/bin/sh' > /etc/cron.daily/php-session-cleanup
  1213. echo "find -O3 /home/*/tmp/ -ignore_readdir_race -depth -mindepth 1 -name 'sess_*' -type f -cmin '+10080' -delete > /dev/null 2>&1" >> /etc/cron.daily/php-session-cleanup
  1214. echo "find -O3 $HESTIA/data/sessions/ -ignore_readdir_race -depth -mindepth 1 -name 'sess_*' -type f -cmin '+10080' -delete > /dev/null 2>&1" >> /etc/cron.daily/php-session-cleanup
  1215. chmod 755 /etc/cron.daily/php-session-cleanup
  1216. #----------------------------------------------------------#
  1217. # Configure Vsftpd #
  1218. #----------------------------------------------------------#
  1219. if [ "$vsftpd" = 'yes' ]; then
  1220. echo "[ * ] Configuring Vsftpd server..."
  1221. cp -f $HESTIA_INSTALL_DIR/vsftpd/vsftpd.conf /etc/
  1222. touch /var/log/vsftpd.log
  1223. chown root:adm /var/log/vsftpd.log
  1224. chmod 640 /var/log/vsftpd.log
  1225. touch /var/log/xferlog
  1226. chown root:adm /var/log/xferlog
  1227. chmod 640 /var/log/xferlog
  1228. update-rc.d vsftpd defaults
  1229. systemctl start vsftpd >> $LOG
  1230. check_result $? "vsftpd start failed"
  1231. fi
  1232. #----------------------------------------------------------#
  1233. # Configure ProFTPD #
  1234. #----------------------------------------------------------#
  1235. if [ "$proftpd" = 'yes' ]; then
  1236. echo "[ * ] Configuring ProFTPD server..."
  1237. echo "127.0.0.1 $servername" >> /etc/hosts
  1238. cp -f $HESTIA_INSTALL_DIR/proftpd/proftpd.conf /etc/proftpd/
  1239. cp -f $HESTIA_INSTALL_DIR/proftpd/tls.conf /etc/proftpd/
  1240. update-rc.d proftpd defaults > /dev/null 2>&1
  1241. systemctl start proftpd >> $LOG
  1242. check_result $? "proftpd start failed"
  1243. fi
  1244. #----------------------------------------------------------#
  1245. # Configure MariaDB #
  1246. #----------------------------------------------------------#
  1247. if [ "$mysql" = 'yes' ]; then
  1248. echo "[ * ] Configuring MariaDB database server..."
  1249. mycnf="my-small.cnf"
  1250. if [ $memory -gt 1200000 ]; then
  1251. mycnf="my-medium.cnf"
  1252. fi
  1253. if [ $memory -gt 3900000 ]; then
  1254. mycnf="my-large.cnf"
  1255. fi
  1256. # Remove symbolic link
  1257. rm -f /etc/mysql/my.cnf
  1258. # Configuring MariaDB
  1259. cp -f $HESTIA_INSTALL_DIR/mysql/$mycnf /etc/mysql/my.cnf
  1260. mysql_install_db >> $LOG
  1261. update-rc.d mysql defaults > /dev/null 2>&1
  1262. systemctl start mysql >> $LOG
  1263. check_result $? "mariadb start failed"
  1264. # Securing MariaDB installation
  1265. mpass=$(gen_pass)
  1266. mysqladmin -u root password $mpass >> $LOG
  1267. echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
  1268. chmod 600 /root/.my.cnf
  1269. # Clear MariaDB Test Users and Databases
  1270. mysql -e "DELETE FROM mysql.user WHERE User=''"
  1271. mysql -e "DROP DATABASE test" > /dev/null 2>&1
  1272. mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
  1273. mysql -e "DELETE FROM mysql.user WHERE user='';"
  1274. mysql -e "DELETE FROM mysql.user WHERE password='' AND authentication_string='';"
  1275. fi
  1276. #----------------------------------------------------------#
  1277. # Configure phpMyAdmin #
  1278. #----------------------------------------------------------#
  1279. if [ "$mysql" = 'yes' ]; then
  1280. # Display upgrade information
  1281. echo "[ * ] Installing phpMyAdmin version v$pma_v..."
  1282. # Download latest phpmyadmin release
  1283. wget --retry-connrefused --quiet https://files.phpmyadmin.net/phpMyAdmin/$pma_v/phpMyAdmin-$pma_v-all-languages.tar.gz
  1284. # Unpack files
  1285. tar xzf phpMyAdmin-$pma_v-all-languages.tar.gz
  1286. # Create folders
  1287. mkdir -p /usr/share/phpmyadmin
  1288. mkdir -p /etc/phpmyadmin
  1289. mkdir -p /etc/phpmyadmin/conf.d/
  1290. mkdir /usr/share/phpmyadmin/tmp
  1291. # Configuring Apache2 for PHPMYADMIN
  1292. if [ "$apache" = 'yes' ]; then
  1293. cp -f $HESTIA_INSTALL_DIR/pma/apache.conf /etc/phpmyadmin/
  1294. ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
  1295. fi
  1296. # Overwrite old files
  1297. cp -rf phpMyAdmin-$pma_v-all-languages/* /usr/share/phpmyadmin
  1298. # Create copy of config file
  1299. cp -f $HESTIA_INSTALL_DIR/phpmyadmin/config.inc.php /etc/phpmyadmin/
  1300. mkdir -p /var/lib/phpmyadmin/tmp
  1301. chmod 770 /var/lib/phpmyadmin/tmp
  1302. chown root:www-data /usr/share/phpmyadmin/tmp
  1303. # Set config and log directory
  1304. sed -i "s|define('CONFIG_DIR', ROOT_PATH);|define('CONFIG_DIR', '/etc/phpmyadmin/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
  1305. sed -i "s|define('TEMP_DIR', ROOT_PATH . 'tmp/');|define('TEMP_DIR', '/var/lib/phpmyadmin/tmp/');|" /usr/share/phpmyadmin/libraries/vendor_config.php
  1306. # Create temporary folder and change permission
  1307. chmod 770 /usr/share/phpmyadmin/tmp
  1308. chown root:www-data /usr/share/phpmyadmin/tmp
  1309. # Generate blow fish
  1310. blowfish=$(head /dev/urandom | tr -dc A-Za-z0-9 | head -c 32)
  1311. sed -i "s|%blowfish_secret%|$blowfish|" /etc/phpmyadmin/config.inc.php
  1312. # Clean Up
  1313. rm -fr phpMyAdmin-$pma_v-all-languages
  1314. rm -f phpMyAdmin-$pma_v-all-languages.tar.gz
  1315. write_config_value "DB_PMA_ALIAS" "phpmyadmin"
  1316. $HESTIA/bin/v-change-sys-db-alias 'pma' "phpmyadmin"
  1317. # Special thanks to Pavel Galkin (https://skurudo.ru)
  1318. # https://github.com/skurudo/phpmyadmin-fixer
  1319. source $HESTIA_INSTALL_DIR/phpmyadmin/pma.sh > /dev/null 2>&1
  1320. # limit access to /etc/phpmyadmin/
  1321. chown -R root:www-data /etc/phpmyadmin/
  1322. chmod -R 640 /etc/phpmyadmin/*
  1323. chmod 750 /etc/phpmyadmin/conf.d/
  1324. fi
  1325. #----------------------------------------------------------#
  1326. # Configure PostgreSQL #
  1327. #----------------------------------------------------------#
  1328. if [ "$postgresql" = 'yes' ]; then
  1329. echo "[ * ] Configuring PostgreSQL database server..."
  1330. ppass=$(gen_pass)
  1331. cp -f $HESTIA_INSTALL_DIR/postgresql/pg_hba.conf /etc/postgresql/*/main/
  1332. systemctl restart postgresql
  1333. sudo -iu postgres psql -c "ALTER USER postgres WITH PASSWORD '$ppass'" > /dev/null 2>&1
  1334. # Configuring phpPgAdmin
  1335. if [ "$apache" = 'yes' ]; then
  1336. cp -f $HESTIA_INSTALL_DIR/pga/phppgadmin.conf /etc/apache2/conf.d/
  1337. fi
  1338. cp -f $HESTIA_INSTALL_DIR/pga/config.inc.php /etc/phppgadmin/
  1339. write_config_value "DB_PGA_ALIAS" "phppgadmin"
  1340. $HESTIA/bin/v-change-sys-db-alias 'pga' "phppgadmin"
  1341. fi
  1342. #----------------------------------------------------------#
  1343. # Configure Bind #
  1344. #----------------------------------------------------------#
  1345. if [ "$named" = 'yes' ]; then
  1346. echo "[ * ] Configuring Bind DNS server..."
  1347. cp -f $HESTIA_INSTALL_DIR/bind/named.conf /etc/bind/
  1348. cp -f $HESTIA_INSTALL_DIR/bind/named.conf.options /etc/bind/
  1349. chown root:bind /etc/bind/named.conf
  1350. chown root:bind /etc/bind/named.conf.options
  1351. chown bind:bind /var/cache/bind
  1352. chmod 640 /etc/bind/named.conf
  1353. chmod 640 /etc/bind/named.conf.options
  1354. aa-complain /usr/sbin/named > /dev/null 2>&1
  1355. echo "/home/** rwm," >> /etc/apparmor.d/local/usr.sbin.named 2> /dev/null
  1356. if ! grep --quiet lxc /proc/1/environ; then
  1357. systemctl status apparmor > /dev/null 2>&1
  1358. if [ $? -ne 0 ]; then
  1359. systemctl restart apparmor >> $LOG
  1360. fi
  1361. fi
  1362. if [ "$release" = '20.04' ]; then
  1363. update-rc.d named defaults
  1364. systemctl start named
  1365. else
  1366. update-rc.d bind9 defaults
  1367. systemctl start bind9
  1368. fi
  1369. check_result $? "bind9 start failed"
  1370. # Workaround for OpenVZ/Virtuozzo
  1371. if [ -e "/proc/vz/veinfo" ] && [ -e "/etc/rc.local" ]; then
  1372. sed -i "s/^exit 0/service bind9 restart\nexit 0/" /etc/rc.local
  1373. fi
  1374. fi
  1375. #----------------------------------------------------------#
  1376. # Configure Exim #
  1377. #----------------------------------------------------------#
  1378. if [ "$exim" = 'yes' ]; then
  1379. echo "[ * ] Configuring Exim mail server..."
  1380. gpasswd -a Debian-exim mail > /dev/null 2>&1
  1381. cp -f $HESTIA_INSTALL_DIR/exim/exim4.conf.template /etc/exim4/
  1382. cp -f $HESTIA_INSTALL_DIR/exim/dnsbl.conf /etc/exim4/
  1383. cp -f $HESTIA_INSTALL_DIR/exim/spam-blocks.conf /etc/exim4/
  1384. touch /etc/exim4/white-blocks.conf
  1385. if [ "$spamd" = 'yes' ]; then
  1386. sed -i "s/#SPAM/SPAM/g" /etc/exim4/exim4.conf.template
  1387. fi
  1388. if [ "$clamd" = 'yes' ]; then
  1389. sed -i "s/#CLAMD/CLAMD/g" /etc/exim4/exim4.conf.template
  1390. fi
  1391. chmod 640 /etc/exim4/exim4.conf.template
  1392. rm -rf /etc/exim4/domains
  1393. mkdir -p /etc/exim4/domains
  1394. rm -f /etc/alternatives/mta
  1395. ln -s /usr/sbin/exim4 /etc/alternatives/mta
  1396. update-rc.d -f sendmail remove > /dev/null 2>&1
  1397. systemctl stop sendmail > /dev/null 2>&1
  1398. update-rc.d -f postfix remove > /dev/null 2>&1
  1399. systemctl stop postfix > /dev/null 2>&1
  1400. update-rc.d exim4 defaults
  1401. systemctl start exim4 >> $LOG
  1402. check_result $? "exim4 start failed"
  1403. fi
  1404. #----------------------------------------------------------#
  1405. # Configure Dovecot #
  1406. #----------------------------------------------------------#
  1407. if [ "$dovecot" = 'yes' ]; then
  1408. echo "[ * ] Configuring Dovecot POP/IMAP mail server..."
  1409. gpasswd -a dovecot mail > /dev/null 2>&1
  1410. cp -rf $HESTIA_INSTALL_DIR/dovecot /etc/
  1411. cp -f $HESTIA_INSTALL_DIR/logrotate/dovecot /etc/logrotate.d/
  1412. if [ "$release" = '18.04' ] || [ "$release" = '20.04' ]; then
  1413. rm -f /etc/dovecot/conf.d/15-mailboxes.conf
  1414. fi
  1415. chown -R root:root /etc/dovecot*
  1416. #Alter config for 2.2
  1417. version=$(dovecot --version | cut -f -2 -d .);
  1418. if [ "$version" = "2.2" ]; then
  1419. echo "[ * ] Downgrade dovecot config to sync with 2.2 settings"
  1420. sed -i 's|#ssl_dh_parameters_length = 4096|ssl_dh_parameters_length = 4096|g' /etc/dovecot/conf.d/10-ssl.conf
  1421. sed -i 's|ssl_dh = </etc/ssl/dhparam.pem|#ssl_dh = </etc/ssl/dhparam.pem|g' /etc/dovecot/conf.d/10-ssl.conf
  1422. sed -i 's|ssl_min_protocol = TLSv1.1|ssl_protocols = !SSLv3 !TLSv1|g' /etc/dovecot/conf.d/10-ssl.conf
  1423. fi
  1424. update-rc.d dovecot defaults
  1425. systemctl start dovecot >> $LOG
  1426. check_result $? "dovecot start failed"
  1427. fi
  1428. #----------------------------------------------------------#
  1429. # Configure ClamAV #
  1430. #----------------------------------------------------------#
  1431. if [ "$clamd" = 'yes' ]; then
  1432. gpasswd -a clamav mail > /dev/null 2>&1
  1433. gpasswd -a clamav Debian-exim > /dev/null 2>&1
  1434. cp -f $HESTIA_INSTALL_DIR/clamav/clamd.conf /etc/clamav/
  1435. update-rc.d clamav-daemon defaults
  1436. echo -ne "[ * ] Installing ClamAV anti-virus definitions... "
  1437. /usr/bin/freshclam >> $LOG &
  1438. BACK_PID=$!
  1439. spin_i=1
  1440. while kill -0 $BACK_PID > /dev/null 2>&1 ; do
  1441. printf "\b${spinner:spin_i++%${#spinner}:1}"
  1442. sleep 0.5
  1443. done
  1444. echo
  1445. systemctl start clamav-daemon >> $LOG
  1446. check_result $? "clamav-daemon start failed"
  1447. fi
  1448. #----------------------------------------------------------#
  1449. # Configure SpamAssassin #
  1450. #----------------------------------------------------------#
  1451. if [ "$spamd" = 'yes' ]; then
  1452. echo "[ * ] Configuring SpamAssassin..."
  1453. update-rc.d spamassassin defaults > /dev/null 2>&1
  1454. sed -i "s/ENABLED=0/ENABLED=1/" /etc/default/spamassassin
  1455. systemctl start spamassassin >> $LOG
  1456. check_result $? "spamassassin start failed"
  1457. unit_files="$(systemctl list-unit-files |grep spamassassin)"
  1458. if [[ "$unit_files" =~ "disabled" ]]; then
  1459. systemctl enable spamassassin > /dev/null 2>&1
  1460. fi
  1461. fi
  1462. #----------------------------------------------------------#
  1463. # Configure Fail2Ban #
  1464. #----------------------------------------------------------#
  1465. if [ "$fail2ban" = 'yes' ]; then
  1466. echo "[ * ] Configuring fail2ban access monitor..."
  1467. cp -rf $HESTIA_INSTALL_DIR/fail2ban /etc/
  1468. if [ "$dovecot" = 'no' ]; then
  1469. fline=$(cat /etc/fail2ban/jail.local |grep -n dovecot-iptables -A 2)
  1470. fline=$(echo "$fline" |grep enabled |tail -n1 |cut -f 1 -d -)
  1471. sed -i "${fline}s/true/false/" /etc/fail2ban/jail.local
  1472. fi
  1473. if [ "$exim" = 'no' ]; then
  1474. fline=$(cat /etc/fail2ban/jail.local |grep -n exim-iptables -A 2)
  1475. fline=$(echo "$fline" |grep enabled |tail -n1 |cut -f 1 -d -)
  1476. sed -i "${fline}s/true/false/" /etc/fail2ban/jail.local
  1477. fi
  1478. if [ "$vsftpd" = 'yes' ]; then
  1479. #Create vsftpd Log File
  1480. if [ ! -f "/var/log/vsftpd.log" ]; then
  1481. touch /var/log/vsftpd.log
  1482. fi
  1483. fline=$(cat /etc/fail2ban/jail.local |grep -n vsftpd-iptables -A 2)
  1484. fline=$(echo "$fline" |grep enabled |tail -n1 |cut -f 1 -d -)
  1485. sed -i "${fline}s/false/true/" /etc/fail2ban/jail.local
  1486. fi
  1487. if [ -f /etc/fail2ban/jail.d/defaults-debian.conf ]; then
  1488. rm -f /etc/fail2ban/jail.d/defaults-debian.conf
  1489. fi
  1490. update-rc.d fail2ban defaults
  1491. systemctl start fail2ban >> $LOG
  1492. check_result $? "fail2ban start failed"
  1493. fi
  1494. #----------------------------------------------------------#
  1495. # Install Roundcube #
  1496. #----------------------------------------------------------#
  1497. echo "[ * ] Install Roundcube..."
  1498. # Min requirements Dovecote + Exim + Mysql
  1499. if [ "$mysql" == 'yes' ] && [ "$dovecot" == "yes" ]; then
  1500. $HESTIA/bin/v-add-sys-roundcube
  1501. write_config_value "WEBMAIL_ALIAS" "webmail"
  1502. fi
  1503. #----------------------------------------------------------#
  1504. # Configure API #
  1505. #----------------------------------------------------------#
  1506. if [ "$api" = "yes" ]; then
  1507. write_config_value "API" "yes"
  1508. write_config_value "API_ALLOWED_IP" ""
  1509. else
  1510. $HESTIA/bin/v-change-sys-api disable
  1511. fi
  1512. #----------------------------------------------------------#
  1513. # Configure IP #
  1514. #----------------------------------------------------------#
  1515. # Configuring system IPs
  1516. $HESTIA/bin/v-update-sys-ip > /dev/null 2>&1
  1517. # Get main IP
  1518. ip=$(ip addr|grep 'inet '|grep global|head -n1|awk '{print $2}'|cut -f1 -d/)
  1519. local_ip=$ip
  1520. # Configuring firewall
  1521. if [ "$iptables" = 'yes' ]; then
  1522. $HESTIA/bin/v-update-firewall
  1523. fi
  1524. # Get public IP
  1525. echo "[ * ] Configure System IP..."
  1526. pub_ip=$(curl --ipv4 -s https://ip.hestiacp.com/)
  1527. if [ ! -z "$pub_ip" ] && [ "$pub_ip" != "$ip" ]; then
  1528. if [ -e /etc/rc.local ]; then
  1529. sed -i '/exit 0/d' /etc/rc.local
  1530. else
  1531. touch /etc/rc.local
  1532. fi
  1533. check_rclocal=$(cat /etc/rc.local | grep "#!")
  1534. if [ -z "$check_rclocal" ]; then
  1535. echo "#!/bin/sh" >> /etc/rc.local
  1536. fi
  1537. echo "$HESTIA/bin/v-update-sys-ip" >> /etc/rc.local
  1538. echo "exit 0" >> /etc/rc.local
  1539. chmod +x /etc/rc.local
  1540. systemctl enable rc-local > /dev/null 2>&1
  1541. $HESTIA/bin/v-change-sys-ip-nat $ip $pub_ip > /dev/null 2>&1
  1542. ip=$pub_ip
  1543. fi
  1544. if [ "$exim" = 'yes' ]; then
  1545. # Set HELO for IP as it didn't set during v-change-sys-hostname
  1546. $HESTIA/bin/v-change-sys-ip-helo $local_ip $servername
  1547. fi
  1548. # Configuring libapache2-mod-remoteip
  1549. if [ "$apache" = 'yes' ] && [ "$nginx" = 'yes' ] ; then
  1550. cd /etc/apache2/mods-available
  1551. echo "<IfModule mod_remoteip.c>" > remoteip.conf
  1552. echo " RemoteIPHeader X-Real-IP" >> remoteip.conf
  1553. if [ "$local_ip" != "127.0.0.1" ] && [ "$pub_ip" != "127.0.0.1" ]; then
  1554. echo " RemoteIPInternalProxy 127.0.0.1" >> remoteip.conf
  1555. fi
  1556. if [ ! -z "$local_ip" ] && [ "$local_ip" != "$pub_ip" ]; then
  1557. echo " RemoteIPInternalProxy $local_ip" >> remoteip.conf
  1558. fi
  1559. if [ ! -z "$pub_ip" ]; then
  1560. echo " RemoteIPInternalProxy $pub_ip" >> remoteip.conf
  1561. fi
  1562. echo "</IfModule>" >> remoteip.conf
  1563. sed -i "s/LogFormat \"%h/LogFormat \"%a/g" /etc/apache2/apache2.conf
  1564. a2enmod remoteip >> $LOG
  1565. systemctl restart apache2
  1566. fi
  1567. # Configuring MariaDB host
  1568. if [ "$mysql" = 'yes' ]; then
  1569. $HESTIA/bin/v-add-database-host mysql localhost root $mpass
  1570. fi
  1571. # Configuring PostgreSQL host
  1572. if [ "$postgresql" = 'yes' ]; then
  1573. $HESTIA/bin/v-add-database-host pgsql localhost postgres $ppass
  1574. fi
  1575. # Adding default domain
  1576. $HESTIA/bin/v-add-web-domain admin $servername
  1577. check_result $? "can't create $servername domain"
  1578. # Adding cron jobs
  1579. export SCHEDULED_RESTART="yes"
  1580. command="sudo $HESTIA/bin/v-update-sys-queue restart"
  1581. $HESTIA/bin/v-add-cron-job 'admin' '*/2' '*' '*' '*' '*' "$command"
  1582. systemctl restart cron
  1583. command="sudo $HESTIA/bin/v-update-sys-queue daily"
  1584. $HESTIA/bin/v-add-cron-job 'admin' '10' '00' '*' '*' '*' "$command"
  1585. command="sudo $HESTIA/bin/v-update-sys-queue disk"
  1586. $HESTIA/bin/v-add-cron-job 'admin' '15' '02' '*' '*' '*' "$command"
  1587. command="sudo $HESTIA/bin/v-update-sys-queue traffic"
  1588. $HESTIA/bin/v-add-cron-job 'admin' '10' '00' '*' '*' '*' "$command"
  1589. command="sudo $HESTIA/bin/v-update-sys-queue webstats"
  1590. $HESTIA/bin/v-add-cron-job 'admin' '30' '03' '*' '*' '*' "$command"
  1591. command="sudo $HESTIA/bin/v-update-sys-queue backup"
  1592. $HESTIA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
  1593. command="sudo $HESTIA/bin/v-backup-users"
  1594. $HESTIA/bin/v-add-cron-job 'admin' '10' '05' '*' '*' '*' "$command"
  1595. command="sudo $HESTIA/bin/v-update-user-stats"
  1596. $HESTIA/bin/v-add-cron-job 'admin' '20' '00' '*' '*' '*' "$command"
  1597. command="sudo $HESTIA/bin/v-update-sys-rrd"
  1598. $HESTIA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
  1599. # Enable automatic updates
  1600. $HESTIA/bin/v-add-cron-hestia-autoupdate apt
  1601. # Building initital rrd images
  1602. $HESTIA/bin/v-update-sys-rrd
  1603. # Enabling file system quota
  1604. if [ "$quota" = 'yes' ]; then
  1605. $HESTIA/bin/v-add-sys-quota
  1606. fi
  1607. # Set backend port
  1608. $HESTIA/bin/v-change-sys-port $port > /dev/null 2>&1
  1609. # Create default configuration files
  1610. $HESTIA/bin/v-update-sys-defaults
  1611. # Update remaining packages since repositories have changed
  1612. echo -ne "[ * ] Installing remaining software updates..."
  1613. apt-get -qq update
  1614. apt-get -y upgrade >> $LOG &
  1615. BACK_PID=$!
  1616. echo
  1617. # Starting Hestia service
  1618. update-rc.d hestia defaults
  1619. systemctl start hestia
  1620. check_result $? "hestia start failed"
  1621. chown admin:admin $HESTIA/data/sessions
  1622. # Create backup folder and set correct permission
  1623. mkdir -p /backup/
  1624. chmod 755 /backup/
  1625. #----------------------------------------------------------#
  1626. # Configure File Manager #
  1627. #----------------------------------------------------------#
  1628. echo "[ * ] Configuring File Manager..."
  1629. $HESTIA/bin/v-add-sys-filemanager quiet
  1630. # create cronjob to generate ssl
  1631. echo "@reboot root sleep 10 && rm /etc/cron.d/hestia-ssl && /usr/local/hestia/bin/v-add-letsencrypt-host" > /etc/cron.d/hestia-ssl
  1632. echo "[ * ] Finish up install..."
  1633. write_config_value "PHPMYADMIN_KEY" ""
  1634. write_config_value "POLICY_USER_VIEW_SUSPENDED" "no"
  1635. write_config_value "POLICY_USER_VIEW_LOGS" "yes"
  1636. write_config_value "POLICY_USER_EDIT_WEB_TEMPLATES" "true"
  1637. write_config_value "POLICY_USER_EDIT_DNS_TEMPLATES" "yes"
  1638. write_config_value "POLICY_USER_EDIT_DETAILS" "yes"
  1639. write_config_value "POLICY_USER_DELETE_LOGS" "yes"
  1640. write_config_value "POLICY_USER_CHANGE_THEME" "yes"
  1641. write_config_value "POLICY_SYSTEM_PROTECTED_ADMIN" "no"
  1642. write_config_value "POLICY_SYSTEM_PASSWORD_RESET" "yes"
  1643. write_config_value "POLICY_SYSTEM_HIDE_SERVICES" "no"
  1644. write_config_value "POLICY_SYSTEM_ENABLE_BACON" "no"
  1645. write_config_value "PLUGIN_APP_INSTALLER" "true"
  1646. write_config_value "DEBUG_MODE" "no"
  1647. write_config_value "ENFORCE_SUBDOMAIN_OWNERSHIP" "yes"
  1648. write_config_value "USE_SERVER_SMTP" "false"
  1649. write_config_value "SERVER_SMTP_PORT" ""
  1650. write_config_value "SERVER_SMTP_HOST" ""
  1651. write_config_value "SERVER_SMTP_SECURITY" ""
  1652. write_config_value "SERVER_SMTP_USER" ""
  1653. write_config_value "SERVER_SMTP_PASSWD" ""
  1654. write_config_value "SERVER_SMTP_ADDR" ""
  1655. #----------------------------------------------------------#
  1656. # Configure PHPMailer #
  1657. #----------------------------------------------------------#
  1658. echo "[ * ] Configuring PHPMailer..."
  1659. $HESTIA/bin/v-add-sys-phpmailer quiet
  1660. #----------------------------------------------------------#
  1661. # Hestia Access Info #
  1662. #----------------------------------------------------------#
  1663. # Comparing hostname and IP
  1664. host_ip=$(host $servername| head -n 1 |awk '{print $NF}')
  1665. if [ "$host_ip" = "$ip" ]; then
  1666. ip="$servername"
  1667. fi
  1668. echo -e "\n"
  1669. echo "===================================================================="
  1670. echo -e "\n"
  1671. # Sending notification to admin email
  1672. echo -e "Congratulations!
  1673. You have successfully installed Hestia Control Panel on your server.
  1674. Ready to get started? Log in using the following credentials:
  1675. Admin URL: https://$ip:$port
  1676. Username: admin
  1677. Password: $vpass
  1678. Thank you for choosing Hestia Control Panel to power your full stack web server,
  1679. we hope that you enjoy using it as much as we do!
  1680. Please feel free to contact us at any time if you have any questions,
  1681. or if you encounter any bugs or problems:
  1682. Web: https://www.hestiacp.com/
  1683. Forum: https://forum.hestiacp.com/
  1684. Discord: https://discord.gg/nXRUZch
  1685. GitHub: https://www.github.com/hestiacp/hestiacp
  1686. Note: Automatic updates are enabled by default. If you would like to disable them,
  1687. please log in and navigate to Server > Updates to turn them off.
  1688. Help support the Hestia Control Panel project by donating via PayPal:
  1689. https://www.hestiacp.com/donate
  1690. --
  1691. Sincerely yours,
  1692. The Hestia Control Panel development team
  1693. Made with love & pride by the open-source community around the world.
  1694. " > $tmpfile
  1695. send_mail="$HESTIA/web/inc/mail-wrapper.php"
  1696. cat $tmpfile | $send_mail -s "Hestia Control Panel" $email
  1697. # Congrats
  1698. echo
  1699. cat $tmpfile
  1700. rm -f $tmpfile
  1701. # Add welcome message to notification panel
  1702. $HESTIA/bin/v-add-user-notification admin 'Welcome to Hestia Control Panel!' '<br>You are now ready to begin <a href="/add/user/">adding user accounts</a> and <a href="/add/web/">domains</a>. For help and assistance, view the <a href="https://docs.hestiacp.com/" target="_new">documentation</a> or visit our <a href="https://forum.hestiacp.com/" target="_new">user forum</a>.<br><br>Please report any bugs or issues via <a href="https://github.com/hestiacp/hestiacp/issues" target="_new"><i class="fab fa-github"></i> GitHub</a>.<br><br><b>Have a wonderful day!</b><br><br><i class="fas fa-heart status-icon red"></i> The Hestia Control Panel development team'
  1703. # Clean-up
  1704. # Sort final configuration file
  1705. sort_config_file
  1706. if [ "$interactive" = 'yes' ]; then
  1707. echo "[ ! ] IMPORTANT: System will reboot"
  1708. echo ""
  1709. echo -n " Press any key to continue!"
  1710. read reboot
  1711. reboot
  1712. else
  1713. echo "[ ! ] IMPORTANT: You must logout or restart the server before continuing"
  1714. fi
  1715. # EOF