vst-install.sh 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633
  1. #!/bin/bash
  2. # Vesta installer
  3. # Define Variables
  4. RHOST='r.vestacp.com'
  5. CHOST='c.vestacp.com'
  6. REPO='cmmnt'
  7. VERSION='0.9.7'
  8. YUM_REPO='/etc/yum.repos.d/vesta.repo'
  9. arch=$(uname -i)
  10. tools="screen mc libpng libjpeg curl curl libmcrypt libmcrypt mhash mhash
  11. freetype openssl flex libxml2 ImageMagick sqlite sqlite pcre pcre sudo bc
  12. mailx lsof ntp tar whois telnet rsync"
  13. rpms="nginx httpd httpd-devel.$arch mod_ssl mod_ruid2 mod_extract_forwarded
  14. webalizer awstats mysql mysql-server php php-bcmath php-cli php-common
  15. php-gd php-imap php-mbstring php-mcrypt php-mysql php-pdo php-soap php-tidy
  16. php-xml php-xmlrpc phpMyAdmin exim dovecot clamd spamassassin roundcubemail
  17. bind bind-utils bind-libs vsftpd rrdtool GeoIP vesta vesta-nginx vesta-php"
  18. # Am I root?
  19. if [ "x$(id -u)" != 'x0' ]; then
  20. echo 'Error: this script can only be executed by root'
  21. exit 1
  22. fi
  23. # Check supported version
  24. if [ ! -e '/etc/redhat-release' ]; then
  25. echo 'Error: sorry, we currently support RHEL and CentOS only'
  26. exit 1
  27. fi
  28. os=$(cut -f 1 -d ' ' /etc/redhat-release)
  29. if [ $os != 'CentOS' ] && [ $os != 'Red' ]; then
  30. echo 'Error: sorry, we currently support RHEL and CentOS only'
  31. fi
  32. release=$(grep -o "[0-9]" /etc/redhat-release |head -n1)
  33. help() {
  34. echo "usage: $0 [OPTIONS]
  35. -e, --email Define email address
  36. -h, --help Print this help and exit
  37. -f, --force Force installation"
  38. exit 1
  39. }
  40. # Translating argument to --gnu-long-options
  41. for arg; do
  42. delim=""
  43. case "$arg" in
  44. --help) args="${args}-h " ;;
  45. --force) args="${args}-f " ;;
  46. --email) args="${args}-e " ;;
  47. *) [[ "${arg:0:1}" == "-" ]] || delim="\""
  48. args="${args}${delim}${arg}${delim} ";;
  49. esac
  50. done
  51. eval set -- "$args"
  52. # Getopt
  53. while getopts "hfe:" Option; do
  54. case $Option in
  55. h) help ;; # Help
  56. e) email=$OPTARG ;; # Contact email
  57. f) force=yes ;; # Force install
  58. *) help ;; # Default
  59. esac
  60. done
  61. # Are you sure ?
  62. if [ -z $email ]; then
  63. echo
  64. echo
  65. echo
  66. echo
  67. echo
  68. echo ' ***********************************************************'
  69. echo
  70. echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| '
  71. echo ' _| _| _| _| _| _| _| '
  72. echo ' _| _| _|_|_| _|_| _| _|_|_|_| '
  73. echo ' _| _| _| _| _| _| _| '
  74. echo ' _| _|_|_|_| _|_|_| _| _| _| '
  75. echo
  76. echo
  77. echo
  78. echo
  79. echo
  80. echo
  81. echo
  82. echo
  83. echo ' ***********************************************************'
  84. echo
  85. echo
  86. read -n 1 -p 'Do you want to install Vesta Control Panel? [y/n]): ' answer
  87. if [ "$answer" != 'y' ] && [ "$answer" != 'Y' ]; then
  88. echo 'Goodbye'
  89. exit 1
  90. fi
  91. echo
  92. # Check email
  93. read -p 'Please enter valid email address: ' email
  94. fi
  95. # Validate email
  96. local_part=$(echo $email | cut -s -f1 -d\@)
  97. remote_host=$(echo $email | cut -s -f2 -d\@)
  98. mx_failed=1
  99. if [ ! -z "$remote_host" ] && [ ! -z "$local_part" ]; then
  100. /usr/bin/host -t mx "$remote_host" &> /dev/null
  101. mx_failed="$?"
  102. fi
  103. if [ "$mx_failed" -eq 1 ]; then
  104. echo "Error: email $email is not valid"
  105. exit 1
  106. fi
  107. echo
  108. echo
  109. echo
  110. echo
  111. echo 'Installation will take about 15 minutes ...'
  112. echo
  113. sleep 2
  114. # Check wget
  115. if [ ! -e '/usr/bin/wget' ]; then
  116. yum -y install wget
  117. if [ $? -ne 0 ]; then
  118. echo "Error: can't install wget"
  119. exit 1
  120. fi
  121. fi
  122. # Check repo availability
  123. wget "$RHOST/$REPO/vesta.conf" -O /dev/null
  124. if [ $? -ne 0 ]; then
  125. echo "Error: no access to $REPO repository"
  126. exit 1
  127. fi
  128. # Check installed packages
  129. tmpfile=$(mktemp -p /tmp)
  130. rpm -qa > $tmpfile
  131. for rpm in $rpms; do
  132. if [ ! -z "$(grep ^$rpm. $tmpfile)" ]; then
  133. conflicts="$rpm $conflicts"
  134. fi
  135. done
  136. rm -f $tmpfile
  137. if [ ! -z "$conflicts" ] && [ -z "$force" ]; then
  138. echo
  139. echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
  140. echo
  141. echo 'Following rpm packages aleady installed:'
  142. echo "$conflicts"
  143. echo
  144. echo 'It is highly recommended to remove them before proceeding.'
  145. echo
  146. echo 'If you want to force installation run this script with -f option:'
  147. echo "Example: bash $0 --force"
  148. echo
  149. echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
  150. echo
  151. exit 1
  152. fi
  153. # Password generator
  154. gen_pass() {
  155. MATRIX='0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
  156. LENGTH=10
  157. while [ ${n:=1} -le $LENGTH ]; do
  158. PASS="$PASS${MATRIX:$(($RANDOM%${#MATRIX})):1}"
  159. let n+=1
  160. done
  161. echo "$PASS"
  162. }
  163. # Update system
  164. yum -y update
  165. if [ $? -ne 0 ]; then
  166. echo 'Error: yum update failed'
  167. exit 1
  168. fi
  169. # Install additional packages
  170. yum -y install $tools
  171. if [ $? -ne 0 ]; then
  172. echo 'Error: yum install failed'
  173. exit 1
  174. fi
  175. # Install EPEL repo
  176. if [ ! -e '/etc/yum.repos.d/epel.repo' ]; then
  177. if [ "$release" -eq '5' ]; then
  178. epel="5/i386/epel-release-5-4.noarch.rpm"
  179. fi
  180. if [ "$release" -eq '6' ]; then
  181. epel="6/i386/epel-release-6-7.noarch.rpm"
  182. fi
  183. rpm -ivh http://dl.fedoraproject.org/pub/epel/$epel
  184. if [ $? -ne 0 ]; then
  185. echo "Error: can't install EPEL repository"
  186. exit 1
  187. fi
  188. fi
  189. # Install remi repo
  190. if [ ! -e '/etc/yum.repos.d/remi.repo' ]; then
  191. if [ "$release" -eq '5' ]; then
  192. remi="remi-release-5.rpm"
  193. fi
  194. if [ "$release" -eq '6' ]; then
  195. remi="remi-release-6.rpm"
  196. fi
  197. rpm -ivh http://rpms.famillecollet.com/enterprise/$remi
  198. if [ $? -ne 0 ]; then
  199. echo "Error: can't install remi repository"
  200. exit 1
  201. fi
  202. fi
  203. # Install vesta repo
  204. echo "[vesta]
  205. name=Vesta - $REPO
  206. baseurl=http://$RHOST/$REPO/$release/\$basearch/
  207. enabled=1
  208. gpgcheck=1
  209. gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA" > $YUM_REPO
  210. wget $CHOST/GPG.txt -O /etc/pki/rpm-gpg/RPM-GPG-KEY-VESTA
  211. # Checking if old MySQL stuff exists
  212. if [ -e '/var/lib/mysql' ]; then
  213. mv -f /var/lib/mysql /var/lib/mysql_old
  214. fi
  215. if [ -e '/etc/my.cnf' ]; then
  216. mv -f /etc/my.cnf /etc/my.cnf_old
  217. fi
  218. if [ -e '/root/.my.cnf' ]; then
  219. mv -f /root/.my.cnf
  220. fi
  221. # Vesta packages
  222. yum -y --enablerepo=remi install $rpms
  223. if [ $? -ne 0 ]; then
  224. echo 'Error: yum install failed'
  225. exit 1
  226. fi
  227. # Configuring run levels
  228. chkconfig iptables off
  229. if [ -e /etc/init.d/sendmail ]; then
  230. chkconfig sendmail off
  231. fi
  232. if [ -e /etc/init.d/postfix ]; then
  233. chkconfig postfix off
  234. fi
  235. chkconfig vesta on
  236. chkconfig httpd on
  237. chkconfig nginx on
  238. chkconfig mysqld on
  239. chkconfig vsftpd on
  240. chkconfig named on
  241. chkconfig exim on
  242. chkconfig clamd on
  243. chkconfig spamassassin on
  244. chkconfig dovecot on
  245. # Make dirs more visible
  246. echo 'LS_COLORS="$LS_COLORS:di=00;33"' >> /etc/profile
  247. # Vesta does not support SELINUX for now
  248. if [ -e '/etc/sysconfig/selinux' ]; then
  249. sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/sysconfig/selinux
  250. setenforce 0
  251. fi
  252. if [ -e '/etc/selinux/config' ]; then
  253. sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config
  254. setenforce 0
  255. fi
  256. # Vesta use own webalizer routine
  257. rm -f /etc/cron.daily/00webalizer
  258. # NTP Synchronization
  259. echo '#!/bin/sh' > /etc/cron.daily/ntpdate
  260. echo '/sbin/ntpdate -s pool.ntp.org' >> /etc/cron.daily/ntpdate
  261. chmod 775 /etc/cron.daily/ntpdate
  262. /sbin/ntpdate -s pool.ntp.org
  263. # Vesta Environment
  264. echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
  265. chmod 755 /etc/profile.d/vesta.sh
  266. source /etc/profile.d/vesta.sh
  267. echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
  268. echo 'export PATH' >> /root/.bash_profile
  269. source /root/.bash_profile
  270. mkdir -p $VESTA/conf
  271. mkdir -p $VESTA/log
  272. mkdir -p $VESTA/data
  273. mkdir -p $VESTA/ssl
  274. chmod 770 $VESTA/conf
  275. # Make backup directory
  276. vst_backups="/root/vst_install_backups/$(date +%s)"
  277. mkdir -p $vst_backups
  278. mkdir -p $vst_backups/nginx
  279. mkdir -p $vst_backups/httpd
  280. mkdir -p $vst_backups/mysql
  281. mkdir -p $vst_backups/exim
  282. mkdir -p $vst_backups/dovecot
  283. mkdir -p $vst_backups/clamd
  284. mkdir -p $vst_backups/vsftpd
  285. mkdir -p $vst_backups/named
  286. wget $RHOST/$REPO/vesta.conf -O $VESTA/conf/vesta.conf
  287. if [ -e '/etc/sudoers' ]; then
  288. mv /etc/sudoers $vst_backups/
  289. fi
  290. wget $CHOST/$VERSION/sudoers.conf -O /etc/sudoers
  291. chmod 0440 /etc/sudoers
  292. wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
  293. sed -i "s/umask 022/umask 002/g" /etc/profile
  294. # Create backup directory
  295. adduser backup
  296. ln -s /home/backup /backup
  297. chmod a+x /backup
  298. # Configuring data templates
  299. cd /usr/local/vesta/data
  300. mkdir ips
  301. mkdir queue
  302. mkdir users
  303. touch queue/backup.pipe
  304. touch queue/disk.pipe
  305. touch queue/webstats.pipe
  306. touch queue/restart.pipe
  307. touch queue/traffic.pipe
  308. chmod 750 users
  309. chmod 750 ips
  310. chmod -R 750 queue
  311. wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
  312. tar -xzf packages.tar.gz
  313. rm -f packages.tar.gz
  314. cd /usr/local/vesta/data
  315. wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
  316. tar -xzf templates.tar.gz
  317. rm -f templates.tar.gz
  318. chmod -R 755 /usr/local/vesta/data/templates
  319. cp templates/web/skel/public_html/index.html /var/www/html/
  320. sed -i 's/%domain%/It worked!/g' /var/www/html/index.html
  321. # Configuring ssl keys
  322. cd /usr/local/vesta/ssl
  323. wget $CHOST/$VERSION/certificate.crt -O certificate.crt
  324. wget $CHOST/$VERSION/certificate.key -O certificate.key
  325. # Adding admin user
  326. vpass=$(gen_pass)
  327. $VESTA/bin/v-add-user admin $vpass $email default System Administrator
  328. if [ $? -ne 0 ]; then
  329. echo "Error: can't create admin user"
  330. exit 1
  331. fi
  332. # Set shell
  333. $VESTA/bin/v-change-user-shell admin bash
  334. # Apache
  335. if [ -e '/etc/httpd/conf/httpd.conf' ]; then
  336. mv /etc/httpd/conf/httpd.conf $vst_backups/httpd/
  337. fi
  338. if [ -e '/etc/httpd/conf.d/ssl.conf' ]; then
  339. mv /etc/httpd/conf.d/ssl.conf $vst_backups/httpd/
  340. fi
  341. if [ -e '/etc/httpd/conf.d/proxy_ajp.conf' ]; then
  342. mv /etc/httpd/conf.d/proxy_ajp.conf $vst_backups/httpd/
  343. fi
  344. wget $CHOST/$VERSION/httpd.conf -O /etc/httpd/conf/httpd.conf
  345. wget $CHOST/$VERSION/httpd-status.conf -O /etc/httpd/conf.d/status.conf
  346. wget $CHOST/$VERSION/httpd-ssl.conf -O /etc/httpd/conf.d/ssl.conf
  347. wget $CHOST/$VERSION/httpd.log -O /etc/logrotate.d/httpd
  348. echo "MEFaccept 127.0.0.1" >> /etc/httpd/conf.d/mod_extract_forwarded.conf
  349. echo > /etc/httpd/conf.d/proxy_ajp.conf
  350. echo > /etc/httpd/conf.d/vesta.conf
  351. touch /var/log/httpd/access_log
  352. touch /var/log/httpd/error_log
  353. touch /var/log/httpd/suexec.log
  354. mkdir -p /var/log/httpd/domains
  355. chmod a+x /var/log/httpd
  356. chmod 640 /var/log/httpd/access_log
  357. chmod 640 /var/log/httpd/error_log
  358. chmod 640 /var/log/httpd/suexec.log
  359. chmod 751 /var/log/httpd/domains
  360. # Nginx
  361. if [ -e '/etc/nginx/nginx.conf' ]; then
  362. mv /etc/nginx/nginx.conf $vst_backups/nginx/
  363. fi
  364. if [ -f '/etc/nginx/conf.d/default.conf' ]; then
  365. mv /etc/nginx/conf.d/default.conf $vst_backups/nginx/
  366. fi
  367. if [ -e '/etc/nginx/conf.d/example_ssl.conf' ]; then
  368. mv /etc/nginx/conf.d/example_ssl.conf $vst_backups/nginx/
  369. fi
  370. wget $CHOST/$VERSION/nginx.conf -O /etc/nginx/nginx.conf
  371. wget $CHOST/$VERSION/nginx-status.conf -O /etc/nginx/conf.d/status.conf
  372. touch /etc/nginx/conf.d/vesta_ip.conf
  373. touch /etc/nginx/conf.d/vesta_users.conf
  374. # VsFTP
  375. if [ -e '/etc/vsftpd/vsftpd.conf' ]; then
  376. mv /etc/vsftpd/vsftpd.conf $vst_backups/vsftpd/
  377. fi
  378. wget $CHOST/$VERSION/vsftpd.conf -O /etc/vsftpd/vsftpd.conf
  379. # MySQL
  380. if [ -e '/etc/my.cnf' ]; then
  381. mv /etc/my.cnf $vst_backups/mysql/
  382. fi
  383. if [ -e '/root/.my.cnf' ]; then
  384. mv /root/.my.cnf $vst_backups/mysql/
  385. fi
  386. mpass=$(gen_pass)
  387. server_memory="$(grep 'MemTotal' /proc/meminfo |tr ' ' '\n' |grep [0-9])"
  388. if [ "$server_memory" -gt '1000000' ]; then
  389. wget $CHOST/$VERSION/mysql.cnf -O /etc/my.cnf
  390. else
  391. wget $CHOST/$VERSION/mysql-512.cnf -O /etc/my.cnf
  392. fi
  393. service mysqld start
  394. mysqladmin -u root password $mpass
  395. echo -e "[client]\npassword='$mpass'\n" >/root/.my.cnf
  396. $VESTA/bin/v-add-database-server mysql localhost 3306 root $mpass
  397. $VESTA/bin/v-add-database admin default default $(gen_pass) mysql
  398. # Bind
  399. if [ -e '/etc/named.conf' ]; then
  400. mv /etc/named.conf $vst_backups/named/
  401. fi
  402. wget $CHOST/$VERSION/named.conf -O /etc/named.conf
  403. chown root:named /etc/named.conf
  404. chmod 640 /etc/named.conf
  405. # Exim
  406. if [ -e '/etc/exim/exim.conf' ]; then
  407. mv /etc/exim/exim.conf $vst_backups/exim/
  408. fi
  409. if [ -e '/etc/clamd.conf' ]; then
  410. mv /etc/clamd.conf $vst_backups/clamd/
  411. fi
  412. wget $CHOST/$VERSION/exim.conf -O /etc/exim/exim.conf
  413. wget $CHOST/$VERSION/dnsbl.conf -O /etc/exim/dnsbl.conf
  414. wget $CHOST/$VERSION/spam-blocks.conf -O /etc/exim/spam-blocks.conf
  415. wget $CHOST/$VERSION/clamd.conf -O /etc/clamd.conf
  416. mkdir /etc/exim/domains
  417. chmod 640 /etc/exim/exim.conf
  418. gpasswd -a clam exim
  419. gpasswd -a exim mail
  420. gpasswd -a clam mail
  421. gpasswd -a dovecot mail
  422. /usr/bin/freshclam
  423. # Dovecot config
  424. if [ "$release" -eq '5' ]; then
  425. if -e [ '/etc/dovecot.conf' ]; then
  426. mv /etc/dovecot.conf $vst_backups/dovecot/
  427. fi
  428. wget $CHOST/$VERSION/dovecot.conf -O /etc/dovecot.conf
  429. else
  430. if [ -e '/etc/dovecot' ]; then
  431. mv /etc/dovecot/* $vst_backups/dovecot/
  432. fi
  433. wget $CHOST/$VERSION/dovecot.tar.gz -O /etc/dovecot.tar.gz
  434. cd /etc/
  435. tar -xzf dovecot.tar.gz
  436. rm -f dovecot.tar.gz
  437. fi
  438. # PMA
  439. wget $CHOST/$VERSION/httpd-pma.conf -O /etc/httpd/conf.d/phpMyAdmin.conf
  440. wget $CHOST/$VERSION/pma.conf -O /etc/phpMyAdmin/config.inc.php
  441. sed -i "s/%blowfish_secret%/$(gen_pass)/g" /etc/phpMyAdmin/config.inc.php
  442. # Roundcube setup
  443. wget $CHOST/$VERSION/httpd-webmail.conf -O /etc/httpd/conf.d/roundcubemail.conf
  444. wget $CHOST/$VERSION/roundcube-main.conf -O /etc/roundcubemail/main.inc.php
  445. wget $CHOST/$VERSION/roundcube-db.conf -O /etc/roundcubemail/db.inc.php
  446. r="$(gen_pass)"
  447. mysql -e "CREATE DATABASE roundcube"
  448. mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'"
  449. sed -i "s/%password%/$r/g" /etc/roundcubemail/db.inc.php
  450. mysql roundcube < /usr/share/doc/roundcubemail-*/SQL/mysql.initial.sql
  451. # Configuring ip
  452. $VESTA/bin/v-update-sys-ip
  453. # Get main ip
  454. main_ip=$(ifconfig |grep 'inet addr:' |grep -v 127.0.0.1 |head -n1 |\
  455. cut -f2 -d: | cut -f1 -d ' ')
  456. # Add default web domain on main ip
  457. $VESTA/bin/v-add-web-domain admin default.domain $main_ip
  458. # Add default dns domain on main ip
  459. $VESTA/bin/v-add-dns-domain admin default.domain $main_ip
  460. # Add default mail domain
  461. $VESTA/bin/v-add-mail-domain admin default.domain
  462. # Configuring crond
  463. command='sudo /usr/local/vesta/bin/v-update-sys-queue disk'
  464. $VESTA/bin/v-add-cron-job 'admin' '15' '02' '*' '*' '*' "$command"
  465. command='sudo /usr/local/vesta/bin/v-update-sys-queue traffic'
  466. $VESTA/bin/v-add-cron-job 'admin' '10' '00' '*' '*' '*' "$command"
  467. command='sudo /usr/local/vesta/bin/v-update-sys-queue webstats'
  468. $VESTA/bin/v-add-cron-job 'admin' '30' '03' '*' '*' '*' "$command"
  469. command='sudo /usr/local/vesta/bin/v-update-sys-queue backup'
  470. $VESTA/bin/v-add-cron-job 'admin' '*/30' '*' '*' '*' '*' "$command"
  471. command='sudo /usr/local/vesta/bin/v-backup-users'
  472. $VESTA/bin/v-add-cron-job 'admin' '10' '05' '*' '*' '*' "$command"
  473. command='sudo /usr/local/vesta/bin/v-update-user-stats'
  474. $VESTA/bin/v-add-cron-job 'admin' '20' '00' '01' '*' '*' "$command"
  475. command='sudo /usr/local/vesta/bin/v-update-sys-rrd'
  476. $VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
  477. # Creating symlink
  478. ln -s /usr/local/vesta/log /var/log/vesta
  479. # Stop unused services
  480. services='iptables sendmail postfix'
  481. for srv in $services; do
  482. service $srv status > /dev/null
  483. if [ $? -eq 0 ]; then
  484. service $srv stop
  485. fi
  486. done
  487. # Start system service
  488. services='vesta httpd nginx vsftpd exim dovecot clamd spamassassin named crond'
  489. for srv in $services; do
  490. service $srv status > /dev/null
  491. if [ $? -gt 0 ]; then
  492. service $srv start
  493. else
  494. service $srv restart
  495. fi
  496. done
  497. # Change sendmail client
  498. rm -f /etc/alternatives/mta
  499. ln -s /usr/sbin/sendmail.exim /etc/alternatives/mta
  500. # Build inititall rrd images
  501. $VESTA/bin/v-update-sys-rrd
  502. # Send notification to vestacp.com
  503. wget vestacp.com/notify/?$REPO -O /dev/null
  504. # Get server ip
  505. vst_ip=$(wget vestacp.com/what-is-my-ip/ -O - 2>/dev/null)
  506. if [ -z "$vst_ip" ]; then
  507. vst_ip=$main_ip
  508. fi
  509. # Send email
  510. echo -e "Congratulations, you have just successfully installed \
  511. the Vesta Control Panel
  512. You can login in Vesta with following credentials:
  513. username: admin
  514. password: $vpass
  515. https://$vst_ip:8083
  516. We hope that you enjoy your installation of Vesta. Please \
  517. feel free to contact us anytime if you have any questions.
  518. Thank you.
  519. --
  520. Sincerely yours
  521. vestacp.com team
  522. " > $tmpfile
  523. cat $tmpfile | mail -s "Vesta Control Panel" $email
  524. rm -f $tmpfile
  525. # Congrats
  526. echo
  527. echo
  528. echo ' ***********************************************************'
  529. echo
  530. echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| '
  531. echo ' _| _| _| _| _| _| _| '
  532. echo ' _| _| _|_|_| _|_| _| _|_|_|_| '
  533. echo ' _| _| _| _| _| _| _| '
  534. echo ' _| _|_|_|_| _|_|_| _| _| _| '
  535. echo
  536. echo ' Congratulations, you have just successfully installed'
  537. echo ' the Vesta Control Panel!'
  538. echo
  539. echo ' Now you can login in Vesta with following credentials:'
  540. echo ' username: admin'
  541. echo " password: $vpass"
  542. echo " https://$vst_ip:8083/"
  543. echo
  544. echo
  545. echo ' Thank you for using our product.'
  546. echo
  547. echo ' ***********************************************************'
  548. echo
  549. echo
  550. # Tricky way to get new PATH variable
  551. cd
  552. bash
  553. # EOF