hst-install-debian.sh 70 KB

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