hst-install-ubuntu.sh 70 KB

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