hst-install-ubuntu.sh 70 KB

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