hst-install-ubuntu.sh 70 KB

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