hst-install-debian.sh 71 KB

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