hst-install-debian.sh 69 KB

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