vst-install.sh 18 KB

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