hst-install-debian.sh 71 KB

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