hst-install-ubuntu.sh 71 KB

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