mirror of
https://github.com/serghey-rodin/vesta.git
synced 2025-08-20 21:34:11 -07:00
New installer for Debian
This commit is contained in:
parent
64a85a82db
commit
cba75321f0
1 changed files with 131 additions and 80 deletions
|
@ -1,6 +1,6 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
# Vesta Debian installer v.01
|
# Vesta Debian installer v.04
|
||||||
|
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# Variables&Functions #
|
# Variables&Functions #
|
||||||
|
@ -16,15 +16,19 @@ software="nginx apache2 apache2-utils apache2.2-common apache2-suexec-custom
|
||||||
php5-curl libapache2-mod-php5 vsftpd mc exim4 exim4-daemon-heavy
|
php5-curl libapache2-mod-php5 vsftpd mc exim4 exim4-daemon-heavy
|
||||||
clamav-daemon flex dovecot-imapd dovecot-pop3d phpMyAdmin awstats
|
clamav-daemon flex dovecot-imapd dovecot-pop3d phpMyAdmin awstats
|
||||||
webalizer jwhois rssh git spamassassin roundcube roundcube-mysql
|
webalizer jwhois rssh git spamassassin roundcube roundcube-mysql
|
||||||
roundcube-plugins sudo bc ftp lsof ntpdate rrdtool
|
roundcube-plugins sudo bc ftp lsof ntpdate rrdtool quota e2fslibs
|
||||||
dnsutils vesta vesta-nginx vesta-php"
|
dnsutils vesta vesta-nginx vesta-php"
|
||||||
|
|
||||||
help() {
|
help() {
|
||||||
echo "usage: $0 [OPTIONS]
|
echo "usage: $0 [OPTIONS]
|
||||||
-e, --email Define email address
|
-e, --email Set email address
|
||||||
-h, --help Print this help and exit
|
|
||||||
-f, --force Force installation
|
-f, --force Force installation
|
||||||
-n, --noupdate Do not run apt-get upgrade command"
|
-h, --help Print this help and exit
|
||||||
|
-n, --noupdate Do not run yum update command
|
||||||
|
-m, --mysql-password Set MySQL password instead of generating it
|
||||||
|
-p, --password Set admin password instead of generating it
|
||||||
|
-s, --hostname Set server hostname
|
||||||
|
-q, --quota Enable File System Quota"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,10 +52,14 @@ gen_pass() {
|
||||||
for arg; do
|
for arg; do
|
||||||
delim=""
|
delim=""
|
||||||
case "$arg" in
|
case "$arg" in
|
||||||
--help) args="${args}-h " ;;
|
--email) args="${args}-e " ;;
|
||||||
--force) args="${args}-f " ;;
|
--force) args="${args}-f " ;;
|
||||||
--email) args="${args}-e " ;;
|
--help) args="${args}-h " ;;
|
||||||
--noupdate) args="${args}-n " ;;
|
--noupdate) args="${args}-n " ;;
|
||||||
|
--mysql-password) args="${args}-m " ;;
|
||||||
|
--password) args="${args}-p " ;;
|
||||||
|
--hostname) args="${args}-s " ;;
|
||||||
|
--quota) args="${args}-q " ;;
|
||||||
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
|
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
|
||||||
args="${args}${delim}${arg}${delim} ";;
|
args="${args}${delim}${arg}${delim} ";;
|
||||||
esac
|
esac
|
||||||
|
@ -59,12 +67,16 @@ done
|
||||||
eval set -- "$args"
|
eval set -- "$args"
|
||||||
|
|
||||||
# Getopt
|
# Getopt
|
||||||
while getopts "dhfne:" Option; do
|
while getopts "dhfnqe:m:p:s:" Option; do
|
||||||
case $Option in
|
case $Option in
|
||||||
h) help ;; # Help
|
h) help ;; # Help
|
||||||
e) email=$OPTARG ;; # Set email
|
e) email=$OPTARG ;; # Set email
|
||||||
f) force='yes' ;; # Force apt-get install
|
f) force='yes' ;; # Force install
|
||||||
n) noupdate='yes' ;; # Disable apt-get upgrade
|
n) noupdate='yes' ;; # Disable yum update
|
||||||
|
m) mpass=$OPTARG ;; # MySQL pasword
|
||||||
|
p) vpass=$OPTARG ;; # Admin password
|
||||||
|
s) servername=$OPTARG ;; # Server hostname
|
||||||
|
q) quota='yes' ;; # Enable quota
|
||||||
*) help ;; # Default
|
*) help ;; # Default
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
@ -216,6 +228,14 @@ if [ -z $email ]; then
|
||||||
|
|
||||||
# Check email
|
# Check email
|
||||||
read -p 'Please enter valid email address: ' email
|
read -p 'Please enter valid email address: ' email
|
||||||
|
|
||||||
|
# Define server hostname
|
||||||
|
if [ -z "$servername" ]; then
|
||||||
|
read -p "Please enter hostname [$(hostname)]: " servername
|
||||||
|
fi
|
||||||
|
if [ -z "$servername" ]; then
|
||||||
|
servername=$(hostname)
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Validate email
|
# Validate email
|
||||||
|
@ -399,6 +419,86 @@ rm -f /usr/sbin/policy-rc.d
|
||||||
# Set writable permission on tmp directory
|
# Set writable permission on tmp directory
|
||||||
chmod 777 /tmp
|
chmod 777 /tmp
|
||||||
|
|
||||||
|
# Vesta configuration
|
||||||
|
echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
|
||||||
|
chmod 755 /etc/profile.d/vesta.sh
|
||||||
|
source /etc/profile.d/vesta.sh
|
||||||
|
echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
|
||||||
|
echo 'export PATH' >> /root/.bash_profile
|
||||||
|
source /root/.bash_profile
|
||||||
|
wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
|
||||||
|
|
||||||
|
# Directory tree
|
||||||
|
mkdir -p $VESTA/conf
|
||||||
|
mkdir -p $VESTA/log
|
||||||
|
mkdir -p $VESTA/ssl
|
||||||
|
mkdir -p $VESTA/data
|
||||||
|
mkdir -p $VESTA/data/ips
|
||||||
|
mkdir -p $VESTA/data/queue
|
||||||
|
mkdir -p $VESTA/data/users
|
||||||
|
touch $VESTA/data/queue/backup.pipe
|
||||||
|
touch $VESTA/data/queue/disk.pipe
|
||||||
|
touch $VESTA/data/queue/webstats.pipe
|
||||||
|
touch $VESTA/data/queue/restart.pipe
|
||||||
|
touch $VESTA/data/queue/traffic.pipe
|
||||||
|
chmod 750 $VESTA/conf
|
||||||
|
chmod 750 $VESTA/data/users
|
||||||
|
chmod 750 $VESTA/data/ips
|
||||||
|
chmod -R 750 $VESTA/data/queue
|
||||||
|
ln -s /usr/local/vesta/log /var/log/vesta
|
||||||
|
touch /var/log/vesta/system.log
|
||||||
|
touch /var/log/vesta/nginx-error.log
|
||||||
|
touch /var/log/vesta/auth.log
|
||||||
|
chmod 660 /var/log/vesta/*
|
||||||
|
adduser backup > /dev/null 2>&1
|
||||||
|
mkdir -p /home/backup
|
||||||
|
chown backup:backup /home/backup
|
||||||
|
ln -s /home/backup /backup
|
||||||
|
chmod a+x /backup
|
||||||
|
|
||||||
|
# vesta.conf
|
||||||
|
wget $CHOST/$VERSION/vesta.conf -O $VESTA/conf/vesta.conf
|
||||||
|
if [ "$srv_type" = 'micro' ] || [ "$srv_type" = 'small' ]; then
|
||||||
|
sed -i "s/clamav-daemon//g" $VESTA/conf/vesta.conf
|
||||||
|
sed -i "s/spamassassin//g" $VESTA/conf/vesta.conf
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Set server hostname
|
||||||
|
/usr/local/vesta/bin/v-change-sys-hostname $servername 2>/dev/null
|
||||||
|
|
||||||
|
# Templates
|
||||||
|
cd /usr/local/vesta/data
|
||||||
|
wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
|
||||||
|
tar -xzf packages.tar.gz
|
||||||
|
rm -f packages.tar.gz
|
||||||
|
cd /usr/local/vesta/data
|
||||||
|
wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
|
||||||
|
tar -xzf templates.tar.gz
|
||||||
|
rm -f templates.tar.gz
|
||||||
|
chmod -R 755 /usr/local/vesta/data/templates
|
||||||
|
cp templates/web/skel/public_html/index.html /var/www/
|
||||||
|
sed -i 's/%domain%/It worked!/g' /var/www/index.html
|
||||||
|
if [ "$srv_type" = 'micro' ]; then
|
||||||
|
rm -f /usr/local/vesta/data/templates/web/apache2/phpfcgid.*
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Generating SSL certificate
|
||||||
|
$VESTA/bin/v-generate-ssl-cert $(hostname) $email 'US' 'California' \
|
||||||
|
'San Francisco' 'Vesta Control Panel' 'IT' > /tmp/vst.pem
|
||||||
|
|
||||||
|
# Parsing merged certificate file
|
||||||
|
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
|
||||||
|
cd /usr/local/vesta/ssl
|
||||||
|
sed -n "1,${crt_end}p" /tmp/vst.pem > certificate.crt
|
||||||
|
sed -n "$key_start,${key_end}p" /tmp/vst.pem > certificate.key
|
||||||
|
chown root:mail /usr/local/vesta/ssl/*
|
||||||
|
chmod 660 /usr/local/vesta/ssl/*
|
||||||
|
rm /tmp/vst.pem
|
||||||
|
|
||||||
# Enable password auth
|
# Enable password auth
|
||||||
sed -i "s/rdAuthentication no/rdAuthentication yes/g" /etc/ssh/sshd_config
|
sed -i "s/rdAuthentication no/rdAuthentication yes/g" /etc/ssh/sshd_config
|
||||||
service ssh restart
|
service ssh restart
|
||||||
|
@ -488,8 +588,12 @@ if [ "$?" -ne 0 ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# Generating MySQL password if it wasn't set
|
||||||
|
if [ -z "$mpass" ]; then
|
||||||
|
mpass=$(gen_pass)
|
||||||
|
fi
|
||||||
|
|
||||||
# MySQL configuration
|
# MySQL configuration
|
||||||
mpass=$(gen_pass)
|
|
||||||
wget $CHOST/$VERSION/my.cnf -O /etc/mysql/my.cnf
|
wget $CHOST/$VERSION/my.cnf -O /etc/mysql/my.cnf
|
||||||
mysql_install_db
|
mysql_install_db
|
||||||
update-rc.d mysql defaults
|
update-rc.d mysql defaults
|
||||||
|
@ -503,7 +607,7 @@ mysqladmin -u root password $mpass
|
||||||
echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
|
echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
|
||||||
chmod 600 /root/.my.cnf
|
chmod 600 /root/.my.cnf
|
||||||
mysql -e "DELETE FROM mysql.user WHERE User=''"
|
mysql -e "DELETE FROM mysql.user WHERE User=''"
|
||||||
mysql -e "DROP DATABASE test"
|
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.db WHERE Db='test' OR Db='test\\_%'"
|
||||||
mysql -e "DELETE FROM mysql.user WHERE user='' or password='';"
|
mysql -e "DELETE FROM mysql.user WHERE user='' or password='';"
|
||||||
mysql -e "FLUSH PRIVILEGES"
|
mysql -e "FLUSH PRIVILEGES"
|
||||||
|
@ -621,6 +725,7 @@ wget $CHOST/$VERSION/roundcube-driver.php -O \
|
||||||
wget $CHOST/$VERSION/roundcube-pw.conf -O \
|
wget $CHOST/$VERSION/roundcube-pw.conf -O \
|
||||||
/etc/roundcube/plugins/password/config.inc.php
|
/etc/roundcube/plugins/password/config.inc.php
|
||||||
r="$(gen_pass)"
|
r="$(gen_pass)"
|
||||||
|
mysql -e "DROP DATABASE roundcube" > /dev/null 2>&1
|
||||||
mysql -e "CREATE DATABASE roundcube"
|
mysql -e "CREATE DATABASE roundcube"
|
||||||
mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'"
|
mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'"
|
||||||
sed -i "s/%password%/$r/g" /etc/roundcube/db.inc.php
|
sed -i "s/%password%/$r/g" /etc/roundcube/db.inc.php
|
||||||
|
@ -628,71 +733,6 @@ mysql roundcube < /usr/share/dbconfig-common/data/roundcube/install/mysql
|
||||||
mkdir -p /var/log/roundcube/error
|
mkdir -p /var/log/roundcube/error
|
||||||
chmod -R 777 /var/log/roundcube
|
chmod -R 777 /var/log/roundcube
|
||||||
|
|
||||||
# Vesta configuration
|
|
||||||
echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
|
|
||||||
chmod 755 /etc/profile.d/vesta.sh
|
|
||||||
source /etc/profile.d/vesta.sh
|
|
||||||
echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
|
|
||||||
echo 'export PATH' >> /root/.bash_profile
|
|
||||||
source /root/.bash_profile
|
|
||||||
wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
|
|
||||||
|
|
||||||
# Directory tree
|
|
||||||
mkdir -p $VESTA/conf
|
|
||||||
mkdir -p $VESTA/log
|
|
||||||
mkdir -p $VESTA/ssl
|
|
||||||
mkdir -p $VESTA/data
|
|
||||||
mkdir -p $VESTA/data/ips
|
|
||||||
mkdir -p $VESTA/data/queue
|
|
||||||
mkdir -p $VESTA/data/users
|
|
||||||
touch $VESTA/data/queue/backup.pipe
|
|
||||||
touch $VESTA/data/queue/disk.pipe
|
|
||||||
touch $VESTA/data/queue/webstats.pipe
|
|
||||||
touch $VESTA/data/queue/restart.pipe
|
|
||||||
touch $VESTA/data/queue/traffic.pipe
|
|
||||||
chmod 750 $VESTA/conf
|
|
||||||
chmod 750 $VESTA/data/users
|
|
||||||
chmod 750 $VESTA/data/ips
|
|
||||||
chmod -R 750 $VESTA/data/queue
|
|
||||||
ln -s /usr/local/vesta/log /var/log/vesta
|
|
||||||
touch /var/log/vesta/system.log
|
|
||||||
touch /var/log/vesta/nginx-error.log
|
|
||||||
touch /var/log/vesta/auth.log
|
|
||||||
chmod 660 /var/log/vesta/*
|
|
||||||
adduser backup > /dev/null 2>&1
|
|
||||||
mkdir -p /home/backup
|
|
||||||
chown backup:backup /home/backup
|
|
||||||
ln -s /home/backup /backup
|
|
||||||
chmod a+x /backup
|
|
||||||
|
|
||||||
# vesta.conf
|
|
||||||
wget $CHOST/$VERSION/vesta.conf -O $VESTA/conf/vesta.conf
|
|
||||||
if [ "$srv_type" = 'micro' ] || [ "$srv_type" = 'small' ]; then
|
|
||||||
sed -i "s/clamav-daemon//g" $VESTA/conf/vesta.conf
|
|
||||||
sed -i "s/spamassassin//g" $VESTA/conf/vesta.conf
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Templates
|
|
||||||
cd /usr/local/vesta/data
|
|
||||||
wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
|
|
||||||
tar -xzf packages.tar.gz
|
|
||||||
rm -f packages.tar.gz
|
|
||||||
cd /usr/local/vesta/data
|
|
||||||
wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
|
|
||||||
tar -xzf templates.tar.gz
|
|
||||||
rm -f templates.tar.gz
|
|
||||||
chmod -R 755 /usr/local/vesta/data/templates
|
|
||||||
cp templates/web/skel/public_html/index.html /var/www/
|
|
||||||
sed -i 's/%domain%/It worked!/g' /var/www/index.html
|
|
||||||
if [ "$srv_type" = 'micro' ]; then
|
|
||||||
rm -f /usr/local/vesta/data/templates/web/apache2/phpfcgid.*
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Default SSL keys
|
|
||||||
cd /usr/local/vesta/ssl
|
|
||||||
wget $CHOST/$VERSION/certificate.crt -O certificate.crt
|
|
||||||
wget $CHOST/$VERSION/certificate.key -O certificate.key
|
|
||||||
|
|
||||||
# Adding admin user
|
# Adding admin user
|
||||||
if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" = 'yes' ]; then
|
if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" = 'yes' ]; then
|
||||||
chattr -i /home/admin/conf > /dev/null 2>&1
|
chattr -i /home/admin/conf > /dev/null 2>&1
|
||||||
|
@ -704,7 +744,13 @@ fi
|
||||||
if [ ! -z "$(grep ^admin: /etc/group)" ]; then
|
if [ ! -z "$(grep ^admin: /etc/group)" ]; then
|
||||||
groupdel admin > /dev/null 2>&1
|
groupdel admin > /dev/null 2>&1
|
||||||
fi
|
fi
|
||||||
vpass=$(gen_pass)
|
|
||||||
|
# Generating admin password if it wasn't set
|
||||||
|
if [ -z "$vpass" ]; then
|
||||||
|
vpass=$(gen_pass)
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Adding vesta account
|
||||||
$VESTA/bin/v-add-user admin $vpass $email default System Administrator
|
$VESTA/bin/v-add-user admin $vpass $email default System Administrator
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Error: can't create admin user"
|
echo "Error: can't create admin user"
|
||||||
|
@ -762,6 +808,11 @@ $VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
|
||||||
# Build inititall rrd images
|
# Build inititall rrd images
|
||||||
$VESTA/bin/v-update-sys-rrd
|
$VESTA/bin/v-update-sys-rrd
|
||||||
|
|
||||||
|
# Enable file system quota
|
||||||
|
if [ "$quota" = 'yes' ]; then
|
||||||
|
$VESTA/bin/v-add-sys-quota
|
||||||
|
fi
|
||||||
|
|
||||||
# Start system service
|
# Start system service
|
||||||
update-rc.d vesta defaults
|
update-rc.d vesta defaults
|
||||||
service vesta stop > /dev/null 2>&1
|
service vesta stop > /dev/null 2>&1
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue