hst-install-debian.sh 82 KB

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