2013-10-14 12:23:41 +03:00
#!/bin/bash
2015-10-21 20:10:00 +03:00
# Vesta Debian installer v.05
2013-10-14 12:23:41 +03:00
#----------------------------------------------------------#
# Variables&Functions #
#----------------------------------------------------------#
export PATH = $PATH :/sbin
export DEBIAN_FRONTEND = noninteractive
RHOST = 'apt.vestacp.com'
CHOST = 'c.vestacp.com'
2015-10-24 15:12:55 +03:00
VERSION = 'debian'
2016-07-31 04:06:38 -04:00
VESTA = '/usr/local/vesta'
2015-10-21 20:10:00 +03:00
memory = $( grep 'MemTotal' /proc/meminfo | tr ' ' '\n' | grep [ 0-9] )
arch = $( uname -i)
os = 'debian'
2016-04-29 04:11:14 +02:00
release = $( cat /etc/debian_version| grep -o [ 0-9] | head -n1)
2015-10-21 20:10:00 +03:00
codename = " $( cat /etc/os-release | grep VERSION = | cut -f 2 -d \( | cut -f 1 -d \) ) "
2018-10-18 17:46:34 +03:00
vestacp = " $VESTA /install/ $VERSION / $release "
2015-10-21 20:10:00 +03:00
2017-12-29 22:02:01 +02:00
if [ " $release " -eq 9 ] ; then
software = " nginx apache2 apache2-utils apache2-suexec-custom
libapache2-mod-ruid2 libapache2-mod-fcgid libapache2-mod-php php
php-common php-cgi php-mysql php-curl php-fpm php-pgsql awstats
webalizer vsftpd proftpd-basic bind9 exim4 exim4-daemon-heavy
clamav-daemon spamassassin dovecot-imapd dovecot-pop3d roundcube-core
roundcube-mysql roundcube-plugins mysql-server mysql-common
mysql-client postgresql postgresql-contrib phppgadmin phpmyadmin mc
flex whois rssh git idn zip sudo bc ftp lsof ntpdate rrdtool quota
e2fslibs bsdutils e2fsprogs curl imagemagick fail2ban dnsutils
bsdmainutils cron vesta vesta-nginx vesta-php expect libmail-dkim-perl
2019-03-02 23:24:02 +01:00
unrar-free vim-common vesta-ioncube vesta-softaculous net-tools unzip"
2017-12-29 22:02:01 +02:00
elif [ " $release " -eq 8 ] ; then
2015-10-21 20:10:00 +03:00
software = " nginx apache2 apache2-utils apache2.2-common
2016-10-19 13:37:52 +00:00
apache2-suexec-custom libapache2-mod-ruid2
2015-10-21 20:10:00 +03:00
libapache2-mod-fcgid libapache2-mod-php5 php5 php5-common php5-cgi
php5-mysql php5-curl php5-fpm php5-pgsql awstats webalizer vsftpd
proftpd-basic bind9 exim4 exim4-daemon-heavy clamav-daemon
spamassassin dovecot-imapd dovecot-pop3d roundcube-core
roundcube-mysql roundcube-plugins mysql-server mysql-common
mysql-client postgresql postgresql-contrib phppgadmin phpMyAdmin mc
flex whois rssh git idn zip sudo bc ftp lsof ntpdate rrdtool quota
e2fslibs bsdutils e2fsprogs curl imagemagick fail2ban dnsutils
2017-12-29 13:15:25 +02:00
bsdmainutils cron vesta vesta-nginx vesta-php expect libmail-dkim-perl
2019-03-02 23:24:02 +01:00
unrar-free vim-common vesta-ioncube vesta-softaculous net-tools unzip"
2015-10-21 20:10:00 +03:00
else
software = " nginx apache2 apache2-utils apache2.2-common
2016-10-19 13:37:52 +00:00
apache2-suexec-custom libapache2-mod-ruid2
2015-10-21 20:10:00 +03:00
libapache2-mod-fcgid libapache2-mod-php5 php5 php5-common php5-cgi
php5-mysql php5-curl php5-fpm php5-pgsql awstats webalizer vsftpd
proftpd-basic proftpd-mod-vroot bind9 exim4 exim4-daemon-heavy
clamav-daemon spamassassin dovecot-imapd dovecot-pop3d roundcube-core
roundcube-mysql roundcube-plugins mysql-server mysql-common
mysql-client postgresql postgresql-contrib phppgadmin phpMyAdmin mc
flex whois rssh git idn zip sudo bc ftp lsof ntpdate rrdtool quota
e2fslibs bsdutils e2fsprogs curl imagemagick fail2ban dnsutils
2017-12-29 13:15:25 +02:00
bsdmainutils cron vesta vesta-nginx vesta-php expect unrar-free
2019-03-02 23:24:02 +01:00
vim-common vesta-ioncube vesta-softaculous net-tools unzip"
2015-10-21 20:10:00 +03:00
fi
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Defining help function
2013-10-14 12:23:41 +03:00
help( ) {
2015-10-21 20:10:00 +03:00
echo " Usage: $0 [OPTIONS]
2018-12-31 19:10:11 -07:00
-a, --apache Install Apache [ yes| no] default: yes
-n, --nginx Install Nginx [ yes| no] default: yes
-w, --phpfpm Install PHP-FPM [ yes| no] default: no
-v, --vsftpd Install Vsftpd [ yes| no] default: yes
-j, --proftpd Install ProFTPD [ yes| no] default: no
-k, --named Install Bind [ yes| no] default: yes
-m, --mysql Install MySQL [ yes| no] default: yes
-g, --postgresql Install PostgreSQL [ yes| no] default: no
-x, --exim Install Exim [ yes| no] default: yes
-z, --dovecot Install Dovecot [ yes| no] default: yes
-c, --clamav Install ClamAV [ yes| no] default: yes
-t, --spamassassin Install SpamAssassin [ yes| no] default: yes
-i, --iptables Install Iptables [ yes| no] default: yes
-b, --fail2ban Install Fail2ban [ yes| no] default: yes
-r, --remi Install Remi repo [ yes| no] default: yes
-o, --softaculous Install Softaculous [ yes| no] default: yes
-q, --quota Filesystem Quota [ yes| no] default: no
2015-10-21 20:10:00 +03:00
-l, --lang Default language default: en
2018-12-31 19:10:11 -07:00
-y, --interactive Interactive install [ yes| no] default: yes
2015-10-21 20:10:00 +03:00
-s, --hostname Set hostname
2018-12-31 15:48:25 -07:00
-u, --ssl Add LE SSL for hostname [ yes| no] default: no
2015-10-21 20:10:00 +03:00
-e, --email Set admin email
2021-08-26 12:53:11 +03:00
-d, --port Set Vesta port
2015-10-21 20:10:00 +03:00
-p, --password Set admin password
-f, --force Force installation
-h, --help Print this help
Example: bash $0 -e demo@vestacp.com -p p4ssw0rd --apache no --phpfpm yes"
2013-10-14 12:23:41 +03:00
exit 1
}
2015-10-21 20:10:00 +03:00
# Defining password-gen function
2013-10-14 12:23:41 +03:00
gen_pass( ) {
MATRIX = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
LENGTH = 10
while [ ${ n : =1 } -le $LENGTH ] ; do
PASS = " $PASS ${ MATRIX : $(( $RANDOM % ${# MATRIX } )) : 1 } "
let n += 1
done
echo " $PASS "
}
2015-10-21 20:10:00 +03:00
# Defning return code check function
check_result( ) {
if [ $1 -ne 0 ] ; then
echo " Error: $2 "
exit $1
fi
}
# Defining function to set default value
set_default_value( ) {
eval variable = \$ $1
if [ -z " $variable " ] ; then
eval $1 = $2
fi
if [ " $variable " != 'yes' ] && [ " $variable " != 'no' ] ; then
eval $1 = $2
fi
}
2013-10-14 12:23:41 +03:00
2017-10-24 16:23:37 +05:00
# Define function to set default language value
set_default_lang( ) {
if [ -z " $lang " ] ; then
eval lang = $1
fi
lang_list = "
ar cz el fa hu ja no pt se ua
bs da en fi id ka pl ro tr vi
cn de es fr it nl pt-BR ru tw
2017-12-29 12:01:16 +02:00
bg ko sr th ur"
if !( echo $lang_list | grep -w $lang 1>& 2>/dev/null) ; then
2017-10-24 16:23:37 +05:00
eval lang = $1
fi
}
2015-10-24 16:48:35 +03:00
2017-12-29 12:01:16 +02:00
2013-10-14 12:23:41 +03:00
#----------------------------------------------------------#
# Verifications #
#----------------------------------------------------------#
2015-10-21 20:10:00 +03:00
# Creating temporary file
tmpfile = $( mktemp -p /tmp)
2013-10-14 12:23:41 +03:00
# Translating argument to --gnu-long-options
for arg; do
delim = ""
case " $arg " in
2015-10-21 20:10:00 +03:00
--apache) args = " ${ args } -a " ; ;
--nginx) args = " ${ args } -n " ; ;
--phpfpm) args = " ${ args } -w " ; ;
--vsftpd) args = " ${ args } -v " ; ;
--proftpd) args = " ${ args } -j " ; ;
--named) args = " ${ args } -k " ; ;
--mysql) args = " ${ args } -m " ; ;
--postgresql) args = " ${ args } -g " ; ;
--exim) args = " ${ args } -x " ; ;
--dovecot) args = " ${ args } -z " ; ;
--clamav) args = " ${ args } -c " ; ;
--spamassassin) args = " ${ args } -t " ; ;
--iptables) args = " ${ args } -i " ; ;
--fail2ban) args = " ${ args } -b " ; ;
2015-10-24 15:06:20 +03:00
--remi) args = " ${ args } -r " ; ;
2017-12-29 13:37:43 +02:00
--softaculous) args = " ${ args } -o " ; ;
2015-10-21 20:10:00 +03:00
--quota) args = " ${ args } -q " ; ;
--lang) args = " ${ args } -l " ; ;
--interactive) args = " ${ args } -y " ; ;
2014-06-09 20:23:09 +03:00
--hostname) args = " ${ args } -s " ; ;
2018-12-31 15:48:25 -07:00
--ssl) args = " ${ args } -u " ; ;
2014-10-22 15:29:42 +03:00
--email) args = " ${ args } -e " ; ;
2021-08-26 12:53:11 +03:00
--port) args = " ${ args } -d " ; ;
2014-10-22 15:29:42 +03:00
--password) args = " ${ args } -p " ; ;
2015-10-21 20:10:00 +03:00
--force) args = " ${ args } -f " ; ;
--help) args = " ${ args } -h " ; ;
*) [ [ " ${ arg : 0 : 1 } " = = "-" ] ] || delim = "\""
args = " ${ args } ${ delim } ${ arg } ${ delim } " ; ;
2013-10-14 12:23:41 +03:00
esac
done
eval set -- " $args "
2015-10-21 20:10:00 +03:00
# Parsing arguments
2021-08-26 12:53:11 +03:00
while getopts "a:n:w:v:j:k:m:g:x:z:c:t:i:b:r:o:q:l:y:s:u:e:d:p:fh" Option; do
2013-10-14 12:23:41 +03:00
case $Option in
2015-10-21 20:10:00 +03:00
a) apache = $OPTARG ; ; # Apache
n) nginx = $OPTARG ; ; # Nginx
w) phpfpm = $OPTARG ; ; # PHP-FPM
v) vsftpd = $OPTARG ; ; # Vsftpd
j) proftpd = $OPTARG ; ; # Proftpd
k) named = $OPTARG ; ; # Named
m) mysql = $OPTARG ; ; # MySQL
g) postgresql = $OPTARG ; ; # PostgreSQL
x) exim = $OPTARG ; ; # Exim
z) dovecot = $OPTARG ; ; # Dovecot
c) clamd = $OPTARG ; ; # ClamAV
t) spamd = $OPTARG ; ; # SpamAssassin
i) iptables = $OPTARG ; ; # Iptables
b) fail2ban = $OPTARG ; ; # Fail2ban
2015-10-24 15:06:20 +03:00
r) remi = $OPTARG ; ; # Remi repo
2017-12-29 13:37:43 +02:00
o) softaculous = $OPTARG ; ; # Softaculous plugin
2015-10-21 20:10:00 +03:00
q) quota = $OPTARG ; ; # FS Quota
l) lang = $OPTARG ; ; # Language
y) interactive = $OPTARG ; ; # Interactive install
s) servername = $OPTARG ; ; # Hostname
2018-12-31 15:48:25 -07:00
u) ssl = $OPTARG ; ; # Add Let's Encrypt SSL for hostname
2015-10-21 20:10:00 +03:00
e) email = $OPTARG ; ; # Admin email
2021-08-26 12:53:11 +03:00
d) port = $OPTARG ; ; # Vesta port
2015-10-21 20:10:00 +03:00
p) vpass = $OPTARG ; ; # Admin password
f) force = 'yes' ; ; # Force install
h) help ; ; # Help
*) help ; ; # Print help (default)
2013-10-14 12:23:41 +03:00
esac
done
2015-10-21 20:10:00 +03:00
# Defining default software stack
set_default_value 'nginx' 'yes'
set_default_value 'apache' 'yes'
set_default_value 'phpfpm' 'no'
set_default_value 'vsftpd' 'yes'
set_default_value 'proftpd' 'no'
set_default_value 'named' 'yes'
set_default_value 'mysql' 'yes'
set_default_value 'postgresql' 'no'
set_default_value 'mongodb' 'no'
set_default_value 'exim' 'yes'
set_default_value 'dovecot' 'yes'
if [ $memory -lt 1500000 ] ; then
set_default_value 'clamd' 'no'
set_default_value 'spamd' 'no'
else
set_default_value 'clamd' 'yes'
set_default_value 'spamd' 'yes'
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
set_default_value 'iptables' 'yes'
set_default_value 'fail2ban' 'yes'
2017-12-29 13:37:43 +02:00
set_default_value 'softaculous' 'yes'
2015-10-21 20:10:00 +03:00
set_default_value 'quota' 'no'
set_default_value 'interactive' 'yes'
2018-12-31 15:48:25 -07:00
set_default_value 'ssl' 'no'
2017-10-24 16:23:37 +05:00
set_default_lang 'en'
2015-10-21 20:10:00 +03:00
# Checking software conflicts
if [ " $phpfpm " = 'yes' ] ; then
apache = 'no'
nginx = 'yes'
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
if [ " $proftpd " = 'yes' ] ; then
vsftpd = 'no'
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
if [ " $exim " = 'no' ] ; then
clamd = 'no'
spamd = 'no'
dovecot = 'no'
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
if [ " $iptables " = 'no' ] ; then
fail2ban = 'no'
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
# Checking root permissions
if [ " x $( id -u) " != 'x0' ] ; then
check_error 1 "Script can be run executed only by root"
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
# Checking admin user account
2019-02-20 17:59:06 +02:00
if [ ! -z " $( grep ^admin: /etc/passwd) " ] && [ -z " $force " ] ; then
2015-10-21 20:10:00 +03:00
echo 'Please remove admin user account before proceeding.'
2013-10-14 12:23:41 +03:00
echo 'If you want to do it automatically run installer with -f option:'
2015-10-21 20:10:00 +03:00
echo -e " Example: bash $0 --force\n "
check_result 1 "User admin exists"
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
# Checking wget
2013-10-14 12:23:41 +03:00
if [ ! -e '/usr/bin/wget' ] ; then
apt-get -y install wget
2015-10-21 20:10:00 +03:00
check_result $? "Can't install wget"
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
# Checking repository availability
2018-10-18 17:46:34 +03:00
wget -q "c.vestacp.com/deb_signing.key" -O /dev/null
2015-10-21 20:10:00 +03:00
check_result $? "No access to Vesta repository"
2013-10-14 12:23:41 +03:00
# Check installed packages
tmpfile = $( mktemp -p /tmp)
dpkg --get-selections > $tmpfile
for pkg in exim4 mysql-server apache2 nginx vesta; do
if [ ! -z " $( grep $pkg $tmpfile ) " ] ; then
conflicts = " $pkg $conflicts "
fi
done
rm -f $tmpfile
if [ ! -z " $conflicts " ] && [ -z " $force " ] ; then
echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
echo
2013-12-05 21:16:30 +02:00
echo 'Following packages are already installed:'
2013-10-14 12:23:41 +03:00
echo " $conflicts "
echo
echo 'It is highly recommended to remove them before proceeding.'
echo 'If you want to force installation run this script with -f option:'
echo " Example: bash $0 --force "
echo
echo '!!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!! !!!'
echo
2015-10-21 20:10:00 +03:00
check_result 1 "Control Panel should be installed on clean server."
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Brief Info #
#----------------------------------------------------------#
# Printing nice ascii aslogo
clear
echo
echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_|'
echo ' _| _| _| _| _| _| _|'
echo ' _| _| _|_|_| _|_| _| _|_|_|_|'
echo ' _| _| _| _| _| _| _|'
echo ' _| _|_|_|_| _|_|_| _| _| _|'
echo
echo ' Vesta Control Panel'
echo -e "\n\n"
echo 'Following software will be installed on your system:'
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Web stack
if [ " $nginx " = 'yes' ] ; then
echo ' - Nginx Web Server'
fi
if [ " $apache " = 'yes' ] && [ " $nginx " = 'no' ] ; then
echo ' - Apache Web Server'
fi
if [ " $apache " = 'yes' ] && [ " $nginx " = 'yes' ] ; then
echo ' - Apache Web Server (as backend)'
fi
if [ " $phpfpm " = 'yes' ] ; then
echo ' - PHP-FPM Application Server'
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
# DNS stack
if [ " $named " = 'yes' ] ; then
echo ' - Bind DNS Server'
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
# Mail Stack
if [ " $exim " = 'yes' ] ; then
echo -n ' - Exim mail server'
if [ " $clamd " = 'yes' ] || [ " $spamd " = 'yes' ] ; then
echo -n ' + '
if [ " $clamd " = 'yes' ] ; then
echo -n 'Antivirus '
fi
if [ " $spamd " = 'yes' ] ; then
echo -n 'Antispam'
fi
fi
2013-10-14 12:23:41 +03:00
echo
2015-10-21 20:10:00 +03:00
if [ " $dovecot " = 'yes' ] ; then
echo ' - Dovecot POP3/IMAP Server'
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
fi
# DB stack
if [ " $mysql " = 'yes' ] ; then
echo ' - MySQL Database Server'
fi
if [ " $postgresql " = 'yes' ] ; then
echo ' - PostgreSQL Database Server'
fi
if [ " $mongodb " = 'yes' ] ; then
echo ' - MongoDB Database Server'
fi
# FTP stack
if [ " $vsftpd " = 'yes' ] ; then
echo ' - Vsftpd FTP Server'
fi
if [ " $proftpd " = 'yes' ] ; then
echo ' - ProFTPD FTP Server'
fi
2013-10-14 12:23:41 +03:00
2021-08-14 20:01:30 +03:00
# LE SSL for hostname
if [ " $ssl " = 'yes' ] ; then
echo ' - LE SSL for hostname'
fi
2017-12-29 13:37:43 +02:00
# Softaculous
if [ " $softaculous " = 'yes' ] ; then
2017-12-29 17:54:27 +02:00
echo ' - Softaculous Plugin'
2017-12-29 13:37:43 +02:00
fi
2015-10-21 20:10:00 +03:00
# Firewall stack
if [ " $iptables " = 'yes' ] ; then
echo -n ' - Iptables Firewall'
fi
if [ " $iptables " = 'yes' ] && [ " $fail2ban " = 'yes' ] ; then
echo -n ' + Fail2Ban'
fi
echo -e "\n\n"
# Asking for confirmation to proceed
if [ " $interactive " = 'yes' ] ; then
read -p 'Would you like to continue [y/n]: ' answer
2013-10-14 12:23:41 +03:00
if [ " $answer " != 'y' ] && [ " $answer " != 'Y' ] ; then
echo 'Goodbye'
exit 1
fi
2015-10-21 20:10:00 +03:00
# Asking for contact email
if [ -z " $email " ] ; then
read -p 'Please enter admin email address: ' email
fi
2014-06-09 20:23:09 +03:00
2021-08-26 12:53:11 +03:00
# Asking for Vesta port
if [ -z " $port " ] ; then
read -p 'Please enter Vesta port number (press enter for 8083): ' port
fi
2015-10-21 20:10:00 +03:00
# Asking to set FQDN hostname
2014-06-09 20:23:09 +03:00
if [ -z " $servername " ] ; then
2015-10-21 20:10:00 +03:00
read -p " Please enter FQDN hostname [ $( hostname) ]: " servername
2014-06-09 20:23:09 +03:00
fi
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
# Generating admin password if it wasn't set
if [ -z " $vpass " ] ; then
vpass = $( gen_pass)
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
# Set hostname if it wasn't set
if [ -z " $servername " ] ; then
servername = $( hostname -f)
2013-10-14 12:23:41 +03:00
fi
2016-06-28 14:55:59 +03:00
# Set FQDN if it wasn't set
2016-06-28 02:46:10 +03:00
mask1 = '(([[:alnum:]](-?[[:alnum:]])*)\.)'
mask2 = '*[[:alnum:]](-?[[:alnum:]])+\.[[:alnum:]]{2,}'
if ! [ [ " $servername " = ~ ^${ mask1 } ${ mask2 } $ ] ] ; then
2016-06-28 14:55:59 +03:00
if [ ! -z " $servername " ] ; then
servername = " $servername .example.com "
else
servername = "example.com"
fi
echo " 127.0.0.1 $servername " >> /etc/hosts
2016-06-28 02:46:10 +03:00
fi
2015-10-21 20:10:00 +03:00
# Set email if it wasn't set
if [ -z " $email " ] ; then
email = " admin@ $servername "
fi
2013-10-14 12:23:41 +03:00
2021-08-26 12:53:11 +03:00
# Set port if it wasn't set
if [ -z " $port " ] ; then
port = "8083"
fi
2015-10-21 20:10:00 +03:00
# Defining backup directory
vst_backups = " /root/vst_install_backups/ $( date +%s) "
echo " Installation backup directory: $vst_backups "
# Printing start message and sleeping for 5 seconds
2013-10-14 12:23:41 +03:00
echo -e "\n\n\n\nInstallation will take about 15 minutes ...\n"
sleep 5
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Checking swap #
#----------------------------------------------------------#
# Checking swap on small instances
if [ -z " $( swapon -s) " ] && [ $memory -lt 1000000 ] ; then
fallocate -l 1G /swapfile
chmod 600 /swapfile
mkswap /swapfile
swapon /swapfile
echo "/swapfile none swap sw 0 0" >> /etc/fstab
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Install repository #
#----------------------------------------------------------#
# Updating system
apt-get -y upgrade
check_result $? 'apt-get upgrade failed'
# Installing nginx repo
2013-10-14 12:23:41 +03:00
apt = /etc/apt/sources.list.d
echo " deb http://nginx.org/packages/debian/ $codename nginx " > $apt /nginx.list
wget http://nginx.org/keys/nginx_signing.key -O /tmp/nginx_signing.key
apt-key add /tmp/nginx_signing.key
2015-10-21 20:10:00 +03:00
# Installing vesta repo
2013-10-14 12:23:41 +03:00
echo " deb http:// $RHOST / $codename / $codename vesta " > $apt /vesta.list
wget $CHOST /deb_signing.key -O deb_signing.key
apt-key add deb_signing.key
2019-04-20 00:08:37 +03:00
# Installing jessie backports
if [ " $release " -eq 8 ] ; then
if [ ! -e /etc/apt/apt.conf ] ; then
echo 'Acquire::Check-Valid-Until "false";' >> /etc/apt/apt.conf
fi
if [ ! -e /etc/apt/sources.list.d/backports.list ] ; then
echo "deb http://archive.debian.org/debian jessie-backports main" >\
2019-04-20 03:06:59 +03:00
/etc/apt/sources.list.d/backports.list
2019-04-20 00:08:37 +03:00
fi
fi
2013-10-14 12:23:41 +03:00
#----------------------------------------------------------#
2015-10-21 20:10:00 +03:00
# Backup #
2013-10-14 12:23:41 +03:00
#----------------------------------------------------------#
2015-10-21 20:10:00 +03:00
# Creating backup directory tree
mkdir -p $vst_backups
cd $vst_backups
2017-12-31 11:45:21 +02:00
mkdir nginx apache2 php php5 php5-fpm vsftpd proftpd bind exim4 dovecot clamd
2015-10-21 20:10:00 +03:00
mkdir spamassassin mysql postgresql mongodb vesta
# Backing up Nginx configuration
2013-10-14 12:23:41 +03:00
service nginx stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
cp -r /etc/nginx/* $vst_backups /nginx >/dev/null 2>& 1
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Backing up Apache configuration
2013-10-14 12:23:41 +03:00
service apache2 stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
cp -r /etc/apache2/* $vst_backups /apache2 > /dev/null 2>& 1
rm -f /etc/apache2/conf.d/* > /dev/null 2>& 1
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Backing up PHP configuration
cp /etc/php.ini $vst_backups /php > /dev/null 2>& 1
cp -r /etc/php.d $vst_backups /php > /dev/null 2>& 1
# Backing up PHP configuration
service php5-fpm stop >/dev/null 2>& 1
cp /etc/php5/* $vst_backups /php5 > /dev/null 2>& 1
rm -f /etc/php5/fpm/pool.d/* >/dev/null 2>& 1
# Backing up Bind configuration
2013-10-14 12:23:41 +03:00
service bind9 stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
cp -r /etc/bind/* $vst_backups /bind > /dev/null 2>& 1
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Backing up Vsftpd configuration
2013-10-14 12:23:41 +03:00
service vsftpd stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
cp /etc/vsftpd.conf $vst_backups /vsftpd > /dev/null 2>& 1
# Backing up ProFTPD configuration
service proftpd stop > /dev/null 2>& 1
cp /etc/proftpd.conf $vst_backups /proftpd >/dev/null 2>& 1
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Backing up Exim configuration
2013-10-14 12:23:41 +03:00
service exim4 stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
cp -r /etc/exim4/* $vst_backups /exim4 > /dev/null 2>& 1
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Backing up ClamAV configuration
2013-10-14 12:23:41 +03:00
service clamav-daemon stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
cp -r /etc/clamav/* $vst_backups /clamav > /dev/null 2>& 1
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Backing up SpamAssassin configuration
2013-10-14 12:23:41 +03:00
service spamassassin stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
cp -r /etc/spamassassin/* $vst_backups /spamassassin > /dev/null 2>& 1
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Backing up Dovecot configuration
2013-10-14 12:23:41 +03:00
service dovecot stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
cp /etc/dovecot.conf $vst_backups /dovecot > /dev/null 2>& 1
cp -r /etc/dovecot/* $vst_backups /dovecot > /dev/null 2>& 1
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Backing up MySQL/MariaDB configuration and data
2013-10-14 12:23:41 +03:00
service mysql stop > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
killall -9 mysqld > /dev/null 2>& 1
mv /var/lib/mysql $vst_backups /mysql/mysql_datadir > /dev/null 2>& 1
cp -r /etc/mysql/* $vst_backups /mysql > /dev/null 2>& 1
mv -f /root/.my.cnf $vst_backups /mysql > /dev/null 2>& 1
2013-10-14 12:23:41 +03:00
# Backup vesta
service vesta stop > /dev/null 2>& 1
2016-07-31 04:06:38 -04:00
cp -r $VESTA /* $vst_backups /vesta > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
apt-get -y remove vesta vesta-nginx vesta-php > /dev/null 2>& 1
apt-get -y purge vesta vesta-nginx vesta-php > /dev/null 2>& 1
2016-07-31 04:06:38 -04:00
rm -rf $VESTA > /dev/null 2>& 1
2013-10-14 12:23:41 +03:00
#----------------------------------------------------------#
2015-11-06 17:38:58 +02:00
# Package Excludes #
2013-10-14 12:23:41 +03:00
#----------------------------------------------------------#
2015-10-21 20:10:00 +03:00
# Excluding packages
if [ " $nginx " = 'no' ] ; then
2021-08-02 16:18:48 +03:00
software = $( echo " $software " | sed -e "s/ nginx/ /" )
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
if [ " $apache " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/apache2 //" )
software = $( echo " $software " | sed -e "s/apache2-utils//" )
software = $( echo " $software " | sed -e "s/apache2-suexec-custom//" )
software = $( echo " $software " | sed -e "s/apache2.2-common//" )
software = $( echo " $software " | sed -e "s/libapache2-mod-ruid2//" )
software = $( echo " $software " | sed -e "s/libapache2-mod-fcgid//" )
software = $( echo " $software " | sed -e "s/libapache2-mod-php5//" )
2017-12-31 11:45:21 +02:00
software = $( echo " $software " | sed -e "s/libapache2-mod-php//" )
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
if [ " $phpfpm " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/php5-fpm//" )
2017-12-31 11:45:21 +02:00
software = $( echo " $software " | sed -e "s/php-fpm//" )
2015-10-21 20:10:00 +03:00
fi
if [ " $vsftpd " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/vsftpd//" )
fi
if [ " $proftpd " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/proftpd-basic//" )
software = $( echo " $software " | sed -e "s/proftpd-mod-vroot//" )
fi
if [ " $named " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/bind9//" )
fi
if [ " $exim " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/exim4 //" )
software = $( echo " $software " | sed -e "s/exim4-daemon-heavy//" )
software = $( echo " $software " | sed -e "s/dovecot-imapd//" )
software = $( echo " $software " | sed -e "s/dovecot-pop3d//" )
software = $( echo " $software " | sed -e "s/clamav-daemon//" )
software = $( echo " $software " | sed -e "s/spamassassin//" )
fi
if [ " $clamd " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/clamav-daemon//" )
fi
if [ " $spamd " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/spamassassin//" )
2016-10-31 14:08:39 +01:00
software = $( echo " $software " | sed -e "s/libmail-dkim-perl//" )
2015-10-21 20:10:00 +03:00
fi
if [ " $dovecot " = 'no' ] ; then
software = $( echo " $software " | sed -e "s/dovecot-imapd//" )
software = $( echo " $software " | sed -e "s/dovecot-pop3d//" )
fi
if [ " $mysql " = 'no' ] ; then
software = $( echo " $software " | sed -e 's/mysql-server//' )
software = $( echo " $software " | sed -e 's/mysql-client//' )
software = $( echo " $software " | sed -e 's/mysql-common//' )
software = $( echo " $software " | sed -e 's/php5-mysql//' )
2017-12-31 11:45:21 +02:00
software = $( echo " $software " | sed -e 's/php-mysql//' )
2015-10-21 20:10:00 +03:00
software = $( echo " $software " | sed -e 's/phpMyAdmin//' )
fi
if [ " $postgresql " = 'no' ] ; then
software = $( echo " $software " | sed -e 's/postgresql-contrib//' )
software = $( echo " $software " | sed -e 's/postgresql//' )
software = $( echo " $software " | sed -e 's/php5-pgsql//' )
2017-12-31 11:45:21 +02:00
software = $( echo " $software " | sed -e 's/php-pgsql//' )
2015-10-21 20:10:00 +03:00
software = $( echo " $software " | sed -e 's/phppgadmin//' )
fi
2017-12-29 13:37:43 +02:00
if [ " $softaculous " = 'no' ] ; then
software = $( echo " $software " | sed -e 's/vesta-softaculous//' )
fi
2015-10-21 20:10:00 +03:00
if [ " $iptables " = 'no' ] || [ " $fail2ban " = 'no' ] ; then
2014-10-22 15:29:42 +03:00
software = $( echo " $software " | sed -e 's/fail2ban//' )
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Install packages #
#----------------------------------------------------------#
2013-10-14 22:34:36 +03:00
# Update system packages
2013-10-14 12:23:41 +03:00
apt-get update
2013-10-14 22:34:36 +03:00
2015-10-21 20:10:00 +03:00
# Disable daemon autostart /usr/share/doc/sysv-rc/README.policy-rc.d.gz
2013-10-14 22:34:36 +03:00
echo -e '#!/bin/sh \nexit 101' > /usr/sbin/policy-rc.d
chmod a+x /usr/sbin/policy-rc.d
2015-10-21 20:10:00 +03:00
# Install apt packages
2013-10-14 12:23:41 +03:00
apt-get -y install $software
2015-10-21 20:10:00 +03:00
check_result $? "apt-get install failed"
2013-10-14 12:23:41 +03:00
2013-10-14 22:34:36 +03:00
# Restore policy
rm -f /usr/sbin/policy-rc.d
2013-10-14 12:23:41 +03:00
#----------------------------------------------------------#
# Configure system #
#----------------------------------------------------------#
2015-10-21 20:10:00 +03:00
# Enable SSH password auth
sed -i "s/rdAuthentication no/rdAuthentication yes/g" /etc/ssh/sshd_config
service ssh restart
# Disable awstats cron
rm -f /etc/cron.d/awstats
# Set directory color
echo 'LS_COLORS="$LS_COLORS:di=00;33"' >> /etc/profile
2017-02-08 14:39:53 +01:00
# Register /sbin/nologin and /usr/sbin/nologin
2015-10-21 20:10:00 +03:00
echo "/sbin/nologin" >> /etc/shells
2017-02-08 14:39:53 +01:00
echo "/usr/sbin/nologin" >> /etc/shells
2015-10-21 20:10:00 +03:00
# NTP Synchronization
echo '#!/bin/sh' > /etc/cron.daily/ntpdate
echo " $( which ntpdate) -s pool.ntp.org " >> /etc/cron.daily/ntpdate
chmod 775 /etc/cron.daily/ntpdate
ntpdate -s pool.ntp.org
# Setup rssh
if [ -z " $( grep /usr/bin/rssh /etc/shells) " ] ; then
echo /usr/bin/rssh >> /etc/shells
fi
sed -i 's/#allowscp/allowscp/' /etc/rssh.conf
sed -i 's/#allowsftp/allowsftp/' /etc/rssh.conf
sed -i 's/#allowrsync/allowrsync/' /etc/rssh.conf
chmod 755 /usr/bin/rssh
#----------------------------------------------------------#
# Configure VESTA #
#----------------------------------------------------------#
2018-10-18 17:46:34 +03:00
# Installing sudo configuration
2015-10-21 20:10:00 +03:00
mkdir -p /etc/sudoers.d
2018-10-18 17:46:34 +03:00
cp -f $vestacp /sudo/admin /etc/sudoers.d/
2015-10-21 20:10:00 +03:00
chmod 440 /etc/sudoers.d/admin
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Configuring system env
2016-07-31 04:06:38 -04:00
echo " export VESTA=' $VESTA ' " > /etc/profile.d/vesta.sh
2014-06-09 20:23:09 +03:00
chmod 755 /etc/profile.d/vesta.sh
source /etc/profile.d/vesta.sh
2016-07-31 04:06:38 -04:00
echo 'PATH=$PATH:' $VESTA '/bin' >> /root/.bash_profile
2014-06-09 20:23:09 +03:00
echo 'export PATH' >> /root/.bash_profile
source /root/.bash_profile
2015-10-21 20:10:00 +03:00
2018-10-18 17:46:34 +03:00
# Configuring logrotate for Vesta logs
cp -f $vestacp /logrotate/vesta /etc/logrotate.d/
2015-10-21 20:10:00 +03:00
2015-11-06 17:38:58 +02:00
# Building directory tree and creating some blank files for vesta
2015-10-21 20:10:00 +03:00
mkdir -p $VESTA /conf $VESTA /log $VESTA /ssl $VESTA /data/ips \
2016-06-27 14:30:39 +03:00
$VESTA /data/queue $VESTA /data/users $VESTA /data/firewall \
$VESTA /data/sessions
2015-10-21 20:10:00 +03:00
touch $VESTA /data/queue/backup.pipe $VESTA /data/queue/disk.pipe \
$VESTA /data/queue/webstats.pipe $VESTA /data/queue/restart.pipe \
$VESTA /data/queue/traffic.pipe $VESTA /log/system.log \
$VESTA /log/nginx-error.log $VESTA /log/auth.log
chmod 750 $VESTA /conf $VESTA /data/users $VESTA /data/ips $VESTA /log
2014-06-09 20:23:09 +03:00
chmod -R 750 $VESTA /data/queue
2015-10-24 15:18:30 +03:00
chmod 660 $VESTA /log/*
2015-10-21 20:10:00 +03:00
rm -f /var/log/vesta
2016-07-31 04:06:38 -04:00
ln -s $VESTA /log /var/log/vesta
2016-06-27 14:30:39 +03:00
chmod 770 $VESTA /data/sessions
2014-06-09 20:23:09 +03:00
2015-10-21 20:10:00 +03:00
# Generating vesta configuration
rm -f $VESTA /conf/vesta.conf 2>/dev/null
touch $VESTA /conf/vesta.conf
chmod 660 $VESTA /conf/vesta.conf
# WEB stack
if [ " $apache " = 'yes' ] && [ " $nginx " = 'no' ] ; then
echo "WEB_SYSTEM='apache2'" >> $VESTA /conf/vesta.conf
echo "WEB_RGROUPS='www-data'" >> $VESTA /conf/vesta.conf
echo "WEB_PORT='80'" >> $VESTA /conf/vesta.conf
echo "WEB_SSL_PORT='443'" >> $VESTA /conf/vesta.conf
echo "WEB_SSL='mod_ssl'" >> $VESTA /conf/vesta.conf
echo "STATS_SYSTEM='webalizer,awstats'" >> $VESTA /conf/vesta.conf
fi
if [ " $apache " = 'yes' ] && [ " $nginx " = 'yes' ] ; then
echo "WEB_SYSTEM='apache2'" >> $VESTA /conf/vesta.conf
echo "WEB_RGROUPS='www-data'" >> $VESTA /conf/vesta.conf
echo "WEB_PORT='8080'" >> $VESTA /conf/vesta.conf
echo "WEB_SSL_PORT='8443'" >> $VESTA /conf/vesta.conf
echo "WEB_SSL='mod_ssl'" >> $VESTA /conf/vesta.conf
echo "PROXY_SYSTEM='nginx'" >> $VESTA /conf/vesta.conf
echo "PROXY_PORT='80'" >> $VESTA /conf/vesta.conf
echo "PROXY_SSL_PORT='443'" >> $VESTA /conf/vesta.conf
echo "STATS_SYSTEM='webalizer,awstats'" >> $VESTA /conf/vesta.conf
fi
if [ " $apache " = 'no' ] && [ " $nginx " = 'yes' ] ; then
echo "WEB_SYSTEM='nginx'" >> $VESTA /conf/vesta.conf
echo "WEB_PORT='80'" >> $VESTA /conf/vesta.conf
echo "WEB_SSL_PORT='443'" >> $VESTA /conf/vesta.conf
echo "WEB_SSL='openssl'" >> $VESTA /conf/vesta.conf
2017-12-31 11:45:21 +02:00
if [ " $release " -eq 9 ] ; then
if [ " $phpfpm " = 'yes' ] ; then
echo "WEB_BACKEND='php-fpm'" >> $VESTA /conf/vesta.conf
fi
else
if [ " $phpfpm " = 'yes' ] ; then
echo "WEB_BACKEND='php5-fpm'" >> $VESTA /conf/vesta.conf
fi
2015-10-21 20:10:00 +03:00
fi
echo "STATS_SYSTEM='webalizer,awstats'" >> $VESTA /conf/vesta.conf
2014-06-09 20:23:09 +03:00
fi
2015-10-21 20:10:00 +03:00
# FTP stack
if [ " $vsftpd " = 'yes' ] ; then
echo "FTP_SYSTEM='vsftpd'" >> $VESTA /conf/vesta.conf
fi
if [ " $proftpd " = 'yes' ] ; then
echo "FTP_SYSTEM='proftpd'" >> $VESTA /conf/vesta.conf
fi
# DNS stack
if [ " $named " = 'yes' ] ; then
echo "DNS_SYSTEM='bind9'" >> $VESTA /conf/vesta.conf
fi
# Mail stack
if [ " $exim " = 'yes' ] ; then
echo "MAIL_SYSTEM='exim4'" >> $VESTA /conf/vesta.conf
if [ " $clamd " = 'yes' ] ; then
echo "ANTIVIRUS_SYSTEM='clamav-daemon'" >> $VESTA /conf/vesta.conf
fi
if [ " $spamd " = 'yes' ] ; then
echo "ANTISPAM_SYSTEM='spamassassin'" >> $VESTA /conf/vesta.conf
fi
if [ " $dovecot " = 'yes' ] ; then
echo "IMAP_SYSTEM='dovecot'" >> $VESTA /conf/vesta.conf
fi
fi
# CRON daemon
echo "CRON_SYSTEM='cron'" >> $VESTA /conf/vesta.conf
# Firewall stack
if [ " $iptables " = 'yes' ] ; then
echo "FIREWALL_SYSTEM='iptables'" >> $VESTA /conf/vesta.conf
fi
if [ " $iptables " = 'yes' ] && [ " $fail2ban " = 'yes' ] ; then
echo "FIREWALL_EXTENSION='fail2ban'" >> $VESTA /conf/vesta.conf
fi
# Disk quota
if [ " $quota " = 'yes' ] ; then
echo "DISK_QUOTA='yes'" >> $VESTA /conf/vesta.conf
2014-07-29 20:46:00 +03:00
fi
2014-06-09 20:23:09 +03:00
2015-10-21 20:10:00 +03:00
# Backups
echo "BACKUP_SYSTEM='local'" >> $VESTA /conf/vesta.conf
# Language
echo " LANGUAGE=' $lang ' " >> $VESTA /conf/vesta.conf
# Version
echo "VERSION='0.9.8'" >> $VESTA /conf/vesta.conf
2018-10-18 17:46:34 +03:00
# Installing hosting packages
cp -rf $vestacp /packages $VESTA /data/
2015-10-21 20:10:00 +03:00
2018-10-18 17:46:34 +03:00
# Installing templates
cp -rf $vestacp /templates $VESTA /data/
2015-10-21 20:10:00 +03:00
# Copying index.html to default documentroot
2018-10-18 17:46:34 +03:00
cp $VESTA /data/templates/web/skel/public_html/index.html /var/www/
2014-06-09 20:23:09 +03:00
sed -i 's/%domain%/It worked!/g' /var/www/index.html
2015-10-21 20:10:00 +03:00
2018-10-18 17:46:34 +03:00
# Installing firewall rules
cp -rf $vestacp /firewall $VESTA /data/
2015-10-21 20:10:00 +03:00
# Configuring server hostname
$VESTA /bin/v-change-sys-hostname $servername 2>/dev/null
2014-06-09 20:23:09 +03:00
# Generating SSL certificate
$VESTA /bin/v-generate-ssl-cert $( hostname) $email 'US' 'California' \
'San Francisco' 'Vesta Control Panel' 'IT' > /tmp/vst.pem
2015-10-21 20:10:00 +03:00
# Parsing certificate file
2014-06-09 20:23:09 +03:00
crt_end = $( grep -n "END CERTIFICATE-" /tmp/vst.pem | cut -f 1 -d:)
key_start = $( grep -n "BEGIN RSA" /tmp/vst.pem | cut -f 1 -d:)
key_end = $( grep -n "END RSA" /tmp/vst.pem | cut -f 1 -d:)
# Adding SSL certificate
2015-10-21 20:10:00 +03:00
cd $VESTA /ssl
2014-06-09 20:23:09 +03:00
sed -n " 1, ${ crt_end } p " /tmp/vst.pem > certificate.crt
sed -n " $key_start , ${ key_end } p " /tmp/vst.pem > certificate.key
2015-10-21 20:10:00 +03:00
chown root:mail $VESTA /ssl/*
chmod 660 $VESTA /ssl/*
2014-06-09 20:23:09 +03:00
rm /tmp/vst.pem
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure Nginx #
#----------------------------------------------------------#
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
if [ " $nginx " = 'yes' ] ; then
rm -f /etc/nginx/conf.d/*.conf
2018-10-18 17:46:34 +03:00
cp -f $vestacp /nginx/nginx.conf /etc/nginx/
cp -f $vestacp /nginx/status.conf /etc/nginx/conf.d/
cp -f $vestacp /nginx/phpmyadmin.inc /etc/nginx/conf.d/
cp -f $vestacp /nginx/phppgadmin.inc /etc/nginx/conf.d/
cp -f $vestacp /nginx/webmail.inc /etc/nginx/conf.d/
cp -f $vestacp /logrotate/nginx /etc/logrotate.d/
2015-10-21 20:10:00 +03:00
echo > /etc/nginx/conf.d/vesta.conf
mkdir -p /var/log/nginx/domains
update-rc.d nginx defaults
service nginx start
check_result $? "nginx start failed"
fi
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure Apache #
#----------------------------------------------------------#
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
if [ " $apache " = 'yes' ] ; then
2018-10-18 17:46:34 +03:00
cp -f $vestacp /apache2/apache2.conf /etc/apache2/
cp -f $vestacp /apache2/status.conf /etc/apache2/mods-enabled/
cp -f $vestacp /logrotate/apache2 /etc/logrotate.d/
2015-10-21 20:10:00 +03:00
a2enmod rewrite
a2enmod suexec
a2enmod ssl
a2enmod actions
a2enmod ruid2
2016-10-19 13:37:52 +00:00
a2enmod headers
2015-10-21 20:10:00 +03:00
mkdir -p /etc/apache2/conf.d
echo > /etc/apache2/conf.d/vesta.conf
2021-09-23 17:56:05 +03:00
echo "# Server control panel by VESTA" > /etc/apache2/sites-available/default
echo "# Server control panel by VESTA" > /etc/apache2/sites-available/default-ssl
echo "# Server control panel by VESTA" > /etc/apache2/ports.conf
2015-10-21 20:10:00 +03:00
echo -e "/home\npublic_html/cgi-bin" > /etc/apache2/suexec/www-data
touch /var/log/apache2/access.log /var/log/apache2/error.log
mkdir -p /var/log/apache2/domains
chmod a+x /var/log/apache2
chmod 640 /var/log/apache2/access.log /var/log/apache2/error.log
chmod 751 /var/log/apache2/domains
update-rc.d apache2 defaults
service apache2 start
check_result $? "apache2 start failed"
2016-09-30 12:40:17 +03:00
else
update-rc.d apache2 disable >/dev/null 2>& 1
service apache2 stop >/dev/null 2>& 1
2015-10-21 20:10:00 +03:00
fi
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure PHP-FPM #
#----------------------------------------------------------#
if [ " $phpfpm " = 'yes' ] ; then
2017-12-31 11:45:21 +02:00
if [ " $release " -eq 9 ] ; then
2018-10-18 17:46:34 +03:00
cp -f $vestacp /php-fpm/www.conf /etc/php/7.0/fpm/pool.d/www.conf
2017-12-31 11:45:21 +02:00
update-rc.d php7.0-fpm defaults
service php7.0-fpm start
check_result $? "php-fpm start failed"
else
2018-10-18 17:46:34 +03:00
cp -f $vestacp /php5-fpm/www.conf /etc/php5/fpm/pool.d/www.conf
2017-12-31 11:45:21 +02:00
update-rc.d php5-fpm defaults
service php5-fpm start
check_result $? "php-fpm start failed"
fi
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure PHP #
#----------------------------------------------------------#
ZONE = $( timedatectl 2>/dev/null| grep Timezone| awk '{print $2}' )
if [ -z " $ZONE " ] ; then
ZONE = 'UTC'
2013-10-14 12:23:41 +03:00
fi
2015-10-24 16:48:35 +03:00
for pconf in $( find /etc/php* -name php.ini) ; do
sed -i " s/;date.timezone =/date.timezone = $ZONE /g " $pconf
sed -i 's%_open_tag = Off%_open_tag = On%g' $pconf
2015-10-30 00:01:51 +03:00
done
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure VSFTPD #
#----------------------------------------------------------#
if [ " $vsftpd " = 'yes' ] ; then
2018-10-18 17:46:34 +03:00
cp -f $vestacp /vsftpd/vsftpd.conf /etc/
2015-10-21 20:10:00 +03:00
update-rc.d vsftpd defaults
service vsftpd start
check_result $? "vsftpd start failed"
2016-12-08 16:20:48 +02:00
# To be deleted after release 0.9.8-18
echo "/sbin/nologin" >> /etc/shells
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure ProFTPD #
#----------------------------------------------------------#
if [ " $proftpd " = 'yes' ] ; then
echo " 127.0.0.1 $servername " >> /etc/hosts
2018-10-18 17:46:34 +03:00
cp -f $vestacp /proftpd/proftpd.conf /etc/proftpd/
2015-10-21 20:10:00 +03:00
update-rc.d proftpd defaults
service proftpd start
check_result $? "proftpd start failed"
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure MySQL/MariaDB #
#----------------------------------------------------------#
if [ " $mysql " = 'yes' ] ; then
mycnf = "my-small.cnf"
if [ $memory -gt 1200000 ] ; then
mycnf = "my-medium.cnf"
fi
if [ $memory -gt 3900000 ] ; then
mycnf = "my-large.cnf"
fi
# MySQL configuration
2018-10-18 17:46:34 +03:00
cp -f $vestacp /mysql/$mycnf /etc/mysql/my.cnf
2015-10-21 20:10:00 +03:00
mysql_install_db
update-rc.d mysql defaults
service mysql start
check_result $? "mysql start failed"
# Securing MySQL installation
2018-10-17 17:27:03 +03:00
mpass = $( gen_pass)
mysqladmin -u root password $mpass
echo -e " [client]\npassword=' $mpass '\n " > /root/.my.cnf
2015-10-21 20:10:00 +03:00
chmod 600 /root/.my.cnf
mysql -e "DELETE FROM mysql.user WHERE User=''"
mysql -e "DROP DATABASE test" >/dev/null 2>& 1
mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
mysql -e "DELETE FROM mysql.user WHERE user='' or password='';"
mysql -e "FLUSH PRIVILEGES"
# Configuring phpMyAdmin
if [ " $apache " = 'yes' ] ; then
2018-10-18 17:46:34 +03:00
cp -f $vestacp /pma/apache.conf /etc/phpmyadmin/
2015-10-21 20:10:00 +03:00
ln -s /etc/phpmyadmin/apache.conf /etc/apache2/conf.d/phpmyadmin.conf
fi
2018-10-18 17:46:34 +03:00
cp -f $vestacp /pma/config.inc.php /etc/phpmyadmin/
2015-10-21 20:10:00 +03:00
chmod 777 /var/lib/phpmyadmin/tmp
2014-06-09 20:23:09 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure PostgreSQL #
#----------------------------------------------------------#
if [ " $postgresql " = 'yes' ] ; then
2018-10-17 17:27:03 +03:00
ppass = $( gen_pass)
2018-10-18 17:46:34 +03:00
cp -f $vestacp /postgresql/pg_hba.conf /etc/postgresql/*/main/
2015-10-21 20:10:00 +03:00
service postgresql restart
2018-10-17 17:27:03 +03:00
sudo -u postgres psql -c " ALTER USER postgres WITH PASSWORD ' $ppass ' "
2015-10-21 20:10:00 +03:00
# Configuring phpPgAdmin
if [ " $apache " = 'yes' ] ; then
2018-10-18 17:46:34 +03:00
cp -f $vestacp /pga/phppgadmin.conf /etc/apache2/conf.d/
2015-10-21 20:10:00 +03:00
fi
2018-10-18 17:46:34 +03:00
cp -f $vestacp /pga/config.inc.php /etc/phppgadmin/
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure Bind #
#----------------------------------------------------------#
if [ " $named " = 'yes' ] ; then
2018-10-18 17:46:34 +03:00
cp -f $vestacp /bind/named.conf /etc/bind/
2015-10-21 20:10:00 +03:00
sed -i "s%listen-on%//listen%" /etc/bind/named.conf.options
chown root:bind /etc/bind/named.conf
chmod 640 /etc/bind/named.conf
2016-08-26 17:27:02 +03:00
aa-complain /usr/sbin/named 2>/dev/null
echo "/home/** rwm," >> /etc/apparmor.d/local/usr.sbin.named 2>/dev/null
service apparmor status >/dev/null 2>& 1
if [ $? -ne 0 ] ; then
service apparmor restart
fi
2015-10-21 20:10:00 +03:00
update-rc.d bind9 defaults
service bind9 start
check_result $? "bind9 start failed"
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure Exim #
#----------------------------------------------------------#
if [ " $exim " = 'yes' ] ; then
gpasswd -a Debian-exim mail
2018-10-18 17:46:34 +03:00
cp -f $vestacp /exim/exim4.conf.template /etc/exim4/
cp -f $vestacp /exim/dnsbl.conf /etc/exim4/
cp -f $vestacp /exim/spam-blocks.conf /etc/exim4/
2015-10-21 20:10:00 +03:00
touch /etc/exim4/white-blocks.conf
if [ " $spamd " = 'yes' ] ; then
sed -i "s/#SPAM/SPAM/g" /etc/exim4/exim4.conf.template
fi
if [ " $clamd " = 'yes' ] ; then
sed -i "s/#CLAMD/CLAMD/g" /etc/exim4/exim4.conf.template
fi
chmod 640 /etc/exim4/exim4.conf.template
rm -rf /etc/exim4/domains
mkdir -p /etc/exim4/domains
rm -f /etc/alternatives/mta
ln -s /usr/sbin/exim4 /etc/alternatives/mta
update-rc.d -f sendmail remove > /dev/null 2>& 1
service sendmail stop > /dev/null 2>& 1
update-rc.d -f postfix remove > /dev/null 2>& 1
service postfix stop > /dev/null 2>& 1
update-rc.d exim4 defaults
service exim4 start
check_result $? "exim4 start failed"
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure Dovecot #
#----------------------------------------------------------#
if [ " $dovecot " = 'yes' ] ; then
gpasswd -a dovecot mail
2018-10-18 17:46:34 +03:00
cp -rf $vestacp /dovecot /etc/
cp -f $vestacp /logrotate/dovecot /etc/logrotate.d/
2015-10-21 20:10:00 +03:00
chown -R root:root /etc/dovecot*
2018-11-04 03:35:17 +01:00
if [ " $release " -eq 9 ] ; then
sed -i "s#namespace inbox {#namespace inbox {\n inbox = yes#" /etc/dovecot/conf.d/15-mailboxes.conf
fi
2015-10-21 20:10:00 +03:00
update-rc.d dovecot defaults
service dovecot start
check_result $? "dovecot start failed"
fi
#----------------------------------------------------------#
# Configure ClamAV #
#----------------------------------------------------------#
if [ " $clamd " = 'yes' ] ; then
2013-10-14 12:23:41 +03:00
gpasswd -a clamav mail
gpasswd -a clamav Debian-exim
2018-10-18 17:46:34 +03:00
cp -f $vestacp /clamav/clamd.conf /etc/clamav/
2013-10-14 12:23:41 +03:00
/usr/bin/freshclam
update-rc.d clamav-daemon defaults
2016-09-07 02:49:17 +02:00
if [ ! -d "/var/run/clamav" ] ; then
mkdir /var/run/clamav
fi
chown -R clamav:clamav /var/run/clamav
2017-12-29 13:15:25 +02:00
if [ -e "/lib/systemd/system/clamav-daemon.service" ] ; then
2018-02-07 21:02:53 +01:00
exec_pre1 = 'ExecStartPre=-/bin/mkdir -p /var/run/clamav'
exec_pre2 = 'ExecStartPre=-/bin/chown -R clamav:clamav /var/run/clamav'
2017-12-29 13:15:25 +02:00
sed -i " s|\[Service\]/|[Service]\n $exec_pre1 \n $exec_pre2 |g " \
/lib/systemd/system/clamav-daemon.service
systemctl daemon-reload
2016-11-17 14:43:17 +01:00
fi
2013-10-14 12:23:41 +03:00
service clamav-daemon start
2015-10-21 20:10:00 +03:00
check_result $? "clamav-daeom start failed"
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure SpamAssassin #
#----------------------------------------------------------#
if [ " $spamd " = 'yes' ] ; then
2013-10-14 12:23:41 +03:00
update-rc.d spamassassin defaults
sed -i "s/ENABLED=0/ENABLED=1/" /etc/default/spamassassin
service spamassassin start
2015-10-21 20:10:00 +03:00
check_result $? "spamassassin start failed"
2017-12-29 13:15:25 +02:00
unit_files = " $( systemctl list-unit-files | grep spamassassin) "
if [ [ " $unit_files " = ~ "disabled" ] ] ; then
2016-09-08 03:49:20 +02:00
systemctl enable spamassassin
fi
2015-10-21 20:10:00 +03:00
fi
#----------------------------------------------------------#
# Configure RoundCube #
#----------------------------------------------------------#
if [ " $exim " = 'yes' ] && [ " $mysql " = 'yes' ] ; then
if [ " $apache " = 'yes' ] ; then
2018-10-18 17:46:34 +03:00
cp -f $vestacp /roundcube/apache.conf /etc/roundcube/
2015-10-21 20:10:00 +03:00
ln -s /etc/roundcube/apache.conf /etc/apache2/conf.d/roundcube.conf
fi
2018-10-18 17:46:34 +03:00
cp -f $vestacp /roundcube/main.inc.php /etc/roundcube/
cp -f $vestacp /roundcube/db.inc.php /etc/roundcube/
2017-02-16 22:13:48 +01:00
chmod 640 /etc/roundcube/debian-db-roundcube.php
chmod 640 /etc/roundcube/config.inc.php
chown root:www-data /etc/roundcube/debian-db-roundcube.php
2017-03-08 16:01:11 +01:00
chown root:www-data /etc/roundcube/config.inc.php
2018-10-18 17:46:34 +03:00
cp -f $vestacp /roundcube/vesta.php \
/usr/share/roundcube/plugins/password/drivers/
cp -f $vestacp /roundcube/config.inc.php /etc/roundcube/plugins/password/
2015-10-21 20:10:00 +03:00
r = " $( gen_pass) "
mysql -e "CREATE DATABASE roundcube"
2017-12-29 13:15:25 +02:00
mysql -e " GRANT ALL ON roundcube.*
TO roundcube@localhost IDENTIFIED BY '$r' "
2015-10-21 20:10:00 +03:00
sed -i " s/%password%/ $r /g " /etc/roundcube/db.inc.php
2017-12-29 13:15:25 +02:00
sed -i " s/localhost/ $servername /g " \
/etc/roundcube/plugins/password/config.inc.php
2015-10-21 20:10:00 +03:00
mysql roundcube < /usr/share/dbconfig-common/data/roundcube/install/mysql
chmod a+r /etc/roundcube/main.inc.php
2018-01-07 19:08:51 +01:00
if [ " $release " -eq 8 ] || [ " $release " -eq 9 ] ; then
2015-10-21 20:10:00 +03:00
mv -f /etc/roundcube/main.inc.php /etc/roundcube/config.inc.php
mv -f /etc/roundcube/db.inc.php /etc/roundcube/debian-db-roundcube.php
2017-02-16 22:13:48 +01:00
chmod 640 /etc/roundcube/debian-db-roundcube.php
chmod 640 /etc/roundcube/config.inc.php
chown root:www-data /etc/roundcube/debian-db-roundcube.php
2017-03-08 16:01:11 +01:00
chown root:www-data /etc/roundcube/config.inc.php
2018-01-07 19:08:51 +01:00
fi
if [ " $release " -eq 8 ] ; then
2016-10-12 20:02:18 +00:00
# RoundCube tinyMCE fix
tinymceFixArchiveURL = $vestacp /roundcube/roundcube-tinymce.tar.gz
tinymceParentFolder = /usr/share/roundcube/program/js
tinymceFolder = $tinymceParentFolder /tinymce
tinymceBadJS = $tinymceFolder /tiny_mce.js
tinymceFixArchive = $tinymceParentFolder /roundcube-tinymce.tar.gz
if [ [ -L " $tinymceFolder " && -d " $tinymceFolder " ] ] ; then
if [ -f " $tinymceBadJS " ] ; then
wget $tinymceFixArchiveURL -O $tinymceFixArchive
2017-12-29 13:15:25 +02:00
if [ [ -f " $tinymceFixArchive " && -s " $tinymceFixArchive " ] ]
then
2016-10-12 20:02:18 +00:00
rm $tinymceFolder
tar -xzf $tinymceFixArchive -C $tinymceParentFolder
rm $tinymceFixArchive
chown -R root:root $tinymceFolder
else
2017-12-29 13:15:25 +02:00
echo -n "File roundcube-tinymce.tar.gz is not downloaded,"
echo "RoundCube tinyMCE fix is not applied"
2016-10-12 20:02:18 +00:00
rm $tinymceFixArchive
fi
fi
fi
2013-10-14 12:23:41 +03:00
fi
fi
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Configure Fail2Ban #
#----------------------------------------------------------#
if [ " $fail2ban " = 'yes' ] ; then
2018-10-18 17:46:34 +03:00
cp -rf $vestacp /fail2ban /etc/
2015-10-21 20:10:00 +03:00
if [ " $dovecot " = 'no' ] ; then
fline = $( cat /etc/fail2ban/jail.local | grep -n dovecot-iptables -A 2)
2015-11-08 21:27:49 +02:00
fline = $( echo " $fline " | grep enabled | tail -n1 | cut -f 1 -d -)
2015-10-21 20:10:00 +03:00
sed -i " ${ fline } s/true/false/ " /etc/fail2ban/jail.local
fi
if [ " $exim " = 'no' ] ; then
fline = $( cat /etc/fail2ban/jail.local | grep -n exim-iptables -A 2)
2015-11-08 21:27:49 +02:00
fline = $( echo " $fline " | grep enabled | tail -n1 | cut -f 1 -d -)
2015-10-21 20:10:00 +03:00
sed -i " ${ fline } s/true/false/ " /etc/fail2ban/jail.local
fi
2018-10-18 17:46:34 +03:00
if [ " $vsftpd " = 'yes' ] ; then
#Create vsftpd Log File
if [ ! -f "/var/log/vsftpd.log" ] ; then
touch /var/log/vsftpd.log
fi
fline = $( cat /etc/fail2ban/jail.local | grep -n vsftpd-iptables -A 2)
fline = $( echo " $fline " | grep enabled | tail -n1 | cut -f 1 -d -)
sed -i " ${ fline } s/false/true/ " /etc/fail2ban/jail.local
fi
2015-10-21 20:10:00 +03:00
update-rc.d fail2ban defaults
2014-10-22 15:29:42 +03:00
service fail2ban start
2015-10-21 20:10:00 +03:00
check_result $? "fail2ban start failed"
fi
#----------------------------------------------------------#
# Configure Admin User #
#----------------------------------------------------------#
# Deleting old admin user
2013-10-14 12:23:41 +03:00
if [ ! -z " $( grep ^admin: /etc/passwd) " ] && [ " $force " = 'yes' ] ; then
chattr -i /home/admin/conf > /dev/null 2>& 1
2015-10-21 20:10:00 +03:00
userdel -f admin >/dev/null 2>& 1
chattr -i /home/admin/conf >/dev/null 2>& 1
mv -f /home/admin $vst_backups /home/ >/dev/null 2>& 1
rm -f /tmp/sess_* >/dev/null 2>& 1
2013-10-14 12:23:41 +03:00
fi
2019-02-20 17:59:06 +02:00
if [ ! -z " $( grep ^admin: /etc/group) " ] ; then
2013-10-14 12:23:41 +03:00
groupdel admin > /dev/null 2>& 1
fi
2014-06-09 20:23:09 +03:00
2015-10-21 20:10:00 +03:00
# Adding vesta account
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-add-user admin $vpass $email default System Administrator
2015-10-21 20:10:00 +03:00
check_result $? "can't create admin user"
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-change-user-shell admin bash
2015-10-21 20:10:00 +03:00
$VESTA /bin/v-change-user-language admin $lang
2013-10-14 12:23:41 +03:00
2016-07-21 01:00:03 +02:00
# RoundCube permissions fix
if [ " $exim " = 'yes' ] && [ " $mysql " = 'yes' ] ; then
2016-10-19 13:37:52 +00:00
if [ ! -d "/var/log/roundcube" ] ; then
mkdir /var/log/roundcube
fi
2016-07-21 01:00:03 +02:00
chown admin:admin /var/log/roundcube
fi
2013-10-14 12:23:41 +03:00
# Configuring system ips
$VESTA /bin/v-update-sys-ip
# Get main ip
2015-10-21 20:10:00 +03:00
ip = $( ip addr| grep 'inet ' | grep global| head -n1| awk '{print $2}' | cut -f1 -d/)
2017-12-29 13:15:25 +02:00
local_ip = $ip
2013-10-14 12:23:41 +03:00
2016-10-20 00:57:12 +02:00
# Firewall configuration
if [ " $iptables " = 'yes' ] ; then
$VESTA /bin/v-update-firewall
fi
2015-10-21 20:10:00 +03:00
# Get public ip
2016-06-30 23:10:03 +03:00
pub_ip = $( curl -s vestacp.com/what-is-my-ip/)
2016-10-19 13:37:52 +00:00
2015-10-21 20:10:00 +03:00
if [ ! -z " $pub_ip " ] && [ " $pub_ip " != " $ip " ] ; then
$VESTA /bin/v-change-sys-ip-nat $ip $pub_ip
2016-06-30 23:10:03 +03:00
ip = $pub_ip
2013-10-14 12:23:41 +03:00
fi
2015-10-21 20:10:00 +03:00
2016-10-19 13:37:52 +00:00
# Configuring libapache2-mod-remoteip
if [ " $apache " = 'yes' ] && [ " $nginx " = 'yes' ] ; then
2017-12-29 13:15:25 +02:00
cd /etc/apache2/mods-available
echo "<IfModule mod_remoteip.c>" > remoteip.conf
echo " RemoteIPHeader X-Real-IP" >> remoteip.conf
if [ " $local_ip " != "127.0.0.1" ] && [ " $pub_ip " != "127.0.0.1" ] ; then
echo " RemoteIPInternalProxy 127.0.0.1" >> remoteip.conf
2016-10-19 13:37:52 +00:00
fi
2017-12-29 13:15:25 +02:00
if [ ! -z " $local_ip " ] && [ " $local_ip " != " $pub_ip " ] ; then
echo " RemoteIPInternalProxy $local_ip " >> remoteip.conf
2016-10-19 13:37:52 +00:00
fi
2017-12-29 13:15:25 +02:00
if [ ! -z " $pub_ip " ] ; then
echo " RemoteIPInternalProxy $pub_ip " >> remoteip.conf
2016-10-19 13:37:52 +00:00
fi
2017-12-29 13:15:25 +02:00
echo "</IfModule>" >> remoteip.conf
2016-10-19 14:06:44 +00:00
sed -i "s/LogFormat \"%h/LogFormat \"%a/g" /etc/apache2/apache2.conf
2016-10-19 13:37:52 +00:00
a2enmod remoteip
service apache2 restart
fi
2015-10-21 20:10:00 +03:00
# Configuring mysql host
if [ " $mysql " = 'yes' ] ; then
2018-10-17 17:27:03 +03:00
$VESTA /bin/v-add-database-host mysql localhost root $mpass
2015-10-21 20:10:00 +03:00
$VESTA /bin/v-add-database admin default default $( gen_pass) mysql
fi
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Configuring pgsql host
if [ " $postgresql " = 'yes' ] ; then
2018-10-17 17:27:03 +03:00
$VESTA /bin/v-add-database-host pgsql localhost postgres $ppass
2015-10-21 20:10:00 +03:00
$VESTA /bin/v-add-database admin db db $( gen_pass) pgsql
fi
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Adding default domain
$VESTA /bin/v-add-domain admin $servername
check_result $? " can't create $servername domain "
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Adding cron jobs
2016-07-31 04:06:38 -04:00
command = " sudo $VESTA /bin/v-update-sys-queue disk "
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-add-cron-job 'admin' '15' '02' '*' '*' '*' " $command "
2016-07-31 04:06:38 -04:00
command = " sudo $VESTA /bin/v-update-sys-queue traffic "
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-add-cron-job 'admin' '10' '00' '*' '*' '*' " $command "
2016-07-31 04:06:38 -04:00
command = " sudo $VESTA /bin/v-update-sys-queue webstats "
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-add-cron-job 'admin' '30' '03' '*' '*' '*' " $command "
2016-07-31 04:06:38 -04:00
command = " sudo $VESTA /bin/v-update-sys-queue backup "
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' " $command "
2016-07-31 04:06:38 -04:00
command = " sudo $VESTA /bin/v-backup-users "
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-add-cron-job 'admin' '10' '05' '*' '*' '*' " $command "
2016-07-31 04:06:38 -04:00
command = " sudo $VESTA /bin/v-update-user-stats "
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-add-cron-job 'admin' '20' '00' '*' '*' '*' " $command "
2016-07-31 04:06:38 -04:00
command = " sudo $VESTA /bin/v-update-sys-rrd "
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' " $command "
2015-10-21 20:10:00 +03:00
service cron restart
2013-10-14 12:23:41 +03:00
2014-06-14 11:50:57 +03:00
# Building inititall rrd images
2013-10-14 12:23:41 +03:00
$VESTA /bin/v-update-sys-rrd
2015-10-21 20:10:00 +03:00
# Enabling file system quota
2014-06-09 20:23:09 +03:00
if [ " $quota " = 'yes' ] ; then
$VESTA /bin/v-add-sys-quota
fi
2017-12-29 13:37:43 +02:00
# Enabling softaculous plugin
if [ " $softaculous " = 'yes' ] ; then
$VESTA /bin/v-add-vesta-softaculous
fi
2015-10-21 20:10:00 +03:00
# Starting vesta service
2013-10-14 12:23:41 +03:00
update-rc.d vesta defaults
service vesta start
2015-10-21 20:10:00 +03:00
check_result $? "vesta start failed"
2016-06-28 13:49:17 +03:00
chown admin:admin $VESTA /data/sessions
2015-10-21 20:10:00 +03:00
2015-11-07 14:58:27 +02:00
# Adding notifications
$VESTA /upd/add_notifications.sh
2016-06-28 02:46:10 +03:00
# Adding cronjob for autoupdates
$VESTA /bin/v-add-cron-vesta-autoupdate
2021-08-26 12:53:11 +03:00
if [ " $port " != "8083" ] ; then
echo " === Set Vesta port: $port "
$VESTA /bin/v-change-vesta-port $port
2018-12-31 15:48:25 -07:00
fi
2021-08-26 18:45:15 +03:00
echo " NOTIFY_ADMIN_FULL_BACKUP=' $email ' " >> $VESTA /conf/vesta.conf
2015-10-21 20:10:00 +03:00
#----------------------------------------------------------#
# Vesta Access Info #
#----------------------------------------------------------#
# Comparing hostname and ip
2021-08-26 21:36:15 +03:00
if [ " $ssl " = 'no' ] ; then
host_ip = $( host $servername | head -n 1 | awk '{print $NF}' )
if [ " $host_ip " = " $ip " ] ; then
ip = " $servername "
fi
fi
if [ " $ssl " = 'yes' ] ; then
make_ssl = 0
host_ip = $( host $servername | head -n 1 | awk '{print $NF}' )
if [ " $host_ip " != " $pub_ip " ] ; then
echo " ***** PROBLEM: Hostname $servername is not pointing to your server (IP address $ip ) "
echo "Without pointing your hostname to your IP, LetsEncrypt SSL will not be generated for your server hostname."
echo " Try to setup an A record in your DNS, pointing your hostname $servername to IP address $ip and then press ENTER. "
echo " (or register ns1. $servername and ns2. $servername as DNS Nameservers and put those Nameservers on $servername domain) "
echo "If we detect that hostname is still not pointing to your IP, installer will not add LetsEncrypt SSL certificate to your hosting panel (unsigned SSL will be used instead)."
read -p "To force to try anyway to add LetsEncrypt, press f and then ENTER." answer
host_ip = $( host $servername | head -n 1 | awk '{print $NF}' )
fi
if [ " $answer " = "f" ] ; then
make_ssl = 1
fi
2015-10-21 20:10:00 +03:00
if [ " $host_ip " = " $ip " ] ; then
ip = " $servername "
2021-08-26 21:36:15 +03:00
make_ssl = 1
fi
if [ $make_ssl -eq 1 ] ; then
# Check if www is also pointing to our IP
www_host = " www. $servername "
www_host_ip = $( host $www_host | head -n 1 | awk '{print $NF}' )
if [ " $www_host_ip " != " $pub_ip " ] ; then
if [ " $named " = 'yes' ] ; then
echo "=== Deleting www to server hostname"
$VESTA /bin/v-delete-web-domain-alias 'admin' " $servername " " $www_host " 'no'
$VESTA /bin/v-delete-dns-on-web-alias 'admin' " $servername " " $www_host " 'no'
fi
www_host = ""
fi
fi
echo "==="
echo " Hostname $servername is pointing to $host_ip "
if [ $make_ssl -eq 1 ] ; then
echo "=== Generating HOSTNAME SSL"
$VESTA /bin/v-add-letsencrypt-domain 'admin' " $servername " " $www_host " 'yes'
$VESTA /bin/v-update-host-certificate 'admin' " $servername "
else
echo "We will not generate SSL because of this"
fi
echo "==="
echo "UPDATE_HOSTNAME_SSL='yes'" >> $VESTA /conf/vesta.conf
2015-10-21 20:10:00 +03:00
fi
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# Sending notification to admin email
2013-10-14 12:23:41 +03:00
echo -e " Congratulations, you have just successfully installed \
2015-10-21 20:10:00 +03:00
Vesta Control Panel
2013-10-14 12:23:41 +03:00
2021-08-26 12:53:11 +03:00
https://$ip :$port
2013-10-14 12:23:41 +03:00
username: admin
password: $vpass
We hope that you enjoy your installation of Vesta. Please \
feel free to contact us anytime if you have any questions.
Thank you.
--
Sincerely yours
vestacp.com team
" > $tmpfile
send_mail = " $VESTA /web/inc/mail-wrapper.php "
cat $tmpfile | $send_mail -s "Vesta Control Panel" $email
# Congrats
echo '======================================================='
echo
echo ' _| _| _|_|_|_| _|_|_| _|_|_|_|_| _|_| '
echo ' _| _| _| _| _| _| _| '
echo ' _| _| _|_|_| _|_| _| _|_|_|_| '
echo ' _| _| _| _| _| _| _| '
echo ' _| _|_|_|_| _|_|_| _| _| _| '
echo
echo
2015-10-21 20:10:00 +03:00
cat $tmpfile
rm -f $tmpfile
2013-10-14 12:23:41 +03:00
2015-10-21 20:10:00 +03:00
# EOF