Skip to content

Commit cba7532

Browse files
committed
New installer for Debian
1 parent 64a85a8 commit cba7532

File tree

1 file changed

+131
-80
lines changed

1 file changed

+131
-80
lines changed

install/vst-install-debian.sh

Lines changed: 131 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
#!/bin/bash
22

3-
# Vesta Debian installer v.01
3+
# Vesta Debian installer v.04
44

55
#----------------------------------------------------------#
66
# Variables&Functions #
@@ -16,15 +16,19 @@ software="nginx apache2 apache2-utils apache2.2-common apache2-suexec-custom
1616
php5-curl libapache2-mod-php5 vsftpd mc exim4 exim4-daemon-heavy
1717
clamav-daemon flex dovecot-imapd dovecot-pop3d phpMyAdmin awstats
1818
webalizer jwhois rssh git spamassassin roundcube roundcube-mysql
19-
roundcube-plugins sudo bc ftp lsof ntpdate rrdtool
19+
roundcube-plugins sudo bc ftp lsof ntpdate rrdtool quota e2fslibs
2020
dnsutils vesta vesta-nginx vesta-php"
2121

2222
help() {
2323
echo "usage: $0 [OPTIONS]
24-
-e, --email Define email address
25-
-h, --help Print this help and exit
24+
-e, --email Set email address
2625
-f, --force Force installation
27-
-n, --noupdate Do not run apt-get upgrade command"
26+
-h, --help Print this help and exit
27+
-n, --noupdate Do not run yum update command
28+
-m, --mysql-password Set MySQL password instead of generating it
29+
-p, --password Set admin password instead of generating it
30+
-s, --hostname Set server hostname
31+
-q, --quota Enable File System Quota"
2832
exit 1
2933
}
3034

@@ -48,23 +52,31 @@ gen_pass() {
4852
for arg; do
4953
delim=""
5054
case "$arg" in
51-
--help) args="${args}-h " ;;
52-
--force) args="${args}-f " ;;
53-
--email) args="${args}-e " ;;
54-
--noupdate) args="${args}-n " ;;
55+
--email) args="${args}-e " ;;
56+
--force) args="${args}-f " ;;
57+
--help) args="${args}-h " ;;
58+
--noupdate) args="${args}-n " ;;
59+
--mysql-password) args="${args}-m " ;;
60+
--password) args="${args}-p " ;;
61+
--hostname) args="${args}-s " ;;
62+
--quota) args="${args}-q " ;;
5563
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
5664
args="${args}${delim}${arg}${delim} ";;
5765
esac
5866
done
5967
eval set -- "$args"
6068

6169
# Getopt
62-
while getopts "dhfne:" Option; do
70+
while getopts "dhfnqe:m:p:s:" Option; do
6371
case $Option in
6472
h) help ;; # Help
6573
e) email=$OPTARG ;; # Set email
66-
f) force='yes' ;; # Force apt-get install
67-
n) noupdate='yes' ;; # Disable apt-get upgrade
74+
f) force='yes' ;; # Force install
75+
n) noupdate='yes' ;; # Disable yum update
76+
m) mpass=$OPTARG ;; # MySQL pasword
77+
p) vpass=$OPTARG ;; # Admin password
78+
s) servername=$OPTARG ;; # Server hostname
79+
q) quota='yes' ;; # Enable quota
6880
*) help ;; # Default
6981
esac
7082
done
@@ -216,6 +228,14 @@ if [ -z $email ]; then
216228

217229
# Check email
218230
read -p 'Please enter valid email address: ' email
231+
232+
# Define server hostname
233+
if [ -z "$servername" ]; then
234+
read -p "Please enter hostname [$(hostname)]: " servername
235+
fi
236+
if [ -z "$servername" ]; then
237+
servername=$(hostname)
238+
fi
219239
fi
220240

221241
# Validate email
@@ -399,6 +419,86 @@ rm -f /usr/sbin/policy-rc.d
399419
# Set writable permission on tmp directory
400420
chmod 777 /tmp
401421

422+
# Vesta configuration
423+
echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
424+
chmod 755 /etc/profile.d/vesta.sh
425+
source /etc/profile.d/vesta.sh
426+
echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
427+
echo 'export PATH' >> /root/.bash_profile
428+
source /root/.bash_profile
429+
wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
430+
431+
# Directory tree
432+
mkdir -p $VESTA/conf
433+
mkdir -p $VESTA/log
434+
mkdir -p $VESTA/ssl
435+
mkdir -p $VESTA/data
436+
mkdir -p $VESTA/data/ips
437+
mkdir -p $VESTA/data/queue
438+
mkdir -p $VESTA/data/users
439+
touch $VESTA/data/queue/backup.pipe
440+
touch $VESTA/data/queue/disk.pipe
441+
touch $VESTA/data/queue/webstats.pipe
442+
touch $VESTA/data/queue/restart.pipe
443+
touch $VESTA/data/queue/traffic.pipe
444+
chmod 750 $VESTA/conf
445+
chmod 750 $VESTA/data/users
446+
chmod 750 $VESTA/data/ips
447+
chmod -R 750 $VESTA/data/queue
448+
ln -s /usr/local/vesta/log /var/log/vesta
449+
touch /var/log/vesta/system.log
450+
touch /var/log/vesta/nginx-error.log
451+
touch /var/log/vesta/auth.log
452+
chmod 660 /var/log/vesta/*
453+
adduser backup > /dev/null 2>&1
454+
mkdir -p /home/backup
455+
chown backup:backup /home/backup
456+
ln -s /home/backup /backup
457+
chmod a+x /backup
458+
459+
# vesta.conf
460+
wget $CHOST/$VERSION/vesta.conf -O $VESTA/conf/vesta.conf
461+
if [ "$srv_type" = 'micro' ] || [ "$srv_type" = 'small' ]; then
462+
sed -i "s/clamav-daemon//g" $VESTA/conf/vesta.conf
463+
sed -i "s/spamassassin//g" $VESTA/conf/vesta.conf
464+
fi
465+
466+
# Set server hostname
467+
/usr/local/vesta/bin/v-change-sys-hostname $servername 2>/dev/null
468+
469+
# Templates
470+
cd /usr/local/vesta/data
471+
wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
472+
tar -xzf packages.tar.gz
473+
rm -f packages.tar.gz
474+
cd /usr/local/vesta/data
475+
wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
476+
tar -xzf templates.tar.gz
477+
rm -f templates.tar.gz
478+
chmod -R 755 /usr/local/vesta/data/templates
479+
cp templates/web/skel/public_html/index.html /var/www/
480+
sed -i 's/%domain%/It worked!/g' /var/www/index.html
481+
if [ "$srv_type" = 'micro' ]; then
482+
rm -f /usr/local/vesta/data/templates/web/apache2/phpfcgid.*
483+
fi
484+
485+
# Generating SSL certificate
486+
$VESTA/bin/v-generate-ssl-cert $(hostname) $email 'US' 'California' \
487+
'San Francisco' 'Vesta Control Panel' 'IT' > /tmp/vst.pem
488+
489+
# Parsing merged certificate file
490+
crt_end=$(grep -n "END CERTIFICATE-" /tmp/vst.pem |cut -f 1 -d:)
491+
key_start=$(grep -n "BEGIN RSA" /tmp/vst.pem |cut -f 1 -d:)
492+
key_end=$(grep -n "END RSA" /tmp/vst.pem |cut -f 1 -d:)
493+
494+
# Adding SSL certificate
495+
cd /usr/local/vesta/ssl
496+
sed -n "1,${crt_end}p" /tmp/vst.pem > certificate.crt
497+
sed -n "$key_start,${key_end}p" /tmp/vst.pem > certificate.key
498+
chown root:mail /usr/local/vesta/ssl/*
499+
chmod 660 /usr/local/vesta/ssl/*
500+
rm /tmp/vst.pem
501+
402502
# Enable password auth
403503
sed -i "s/rdAuthentication no/rdAuthentication yes/g" /etc/ssh/sshd_config
404504
service ssh restart
@@ -488,8 +588,12 @@ if [ "$?" -ne 0 ]; then
488588
exit 1
489589
fi
490590

591+
# Generating MySQL password if it wasn't set
592+
if [ -z "$mpass" ]; then
593+
mpass=$(gen_pass)
594+
fi
595+
491596
# MySQL configuration
492-
mpass=$(gen_pass)
493597
wget $CHOST/$VERSION/my.cnf -O /etc/mysql/my.cnf
494598
mysql_install_db
495599
update-rc.d mysql defaults
@@ -503,7 +607,7 @@ mysqladmin -u root password $mpass
503607
echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
504608
chmod 600 /root/.my.cnf
505609
mysql -e "DELETE FROM mysql.user WHERE User=''"
506-
mysql -e "DROP DATABASE test"
610+
mysql -e "DROP DATABASE test" > /dev/null 2>&1
507611
mysql -e "DELETE FROM mysql.db WHERE Db='test' OR Db='test\\_%'"
508612
mysql -e "DELETE FROM mysql.user WHERE user='' or password='';"
509613
mysql -e "FLUSH PRIVILEGES"
@@ -621,78 +725,14 @@ wget $CHOST/$VERSION/roundcube-driver.php -O \
621725
wget $CHOST/$VERSION/roundcube-pw.conf -O \
622726
/etc/roundcube/plugins/password/config.inc.php
623727
r="$(gen_pass)"
728+
mysql -e "DROP DATABASE roundcube" > /dev/null 2>&1
624729
mysql -e "CREATE DATABASE roundcube"
625730
mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'"
626731
sed -i "s/%password%/$r/g" /etc/roundcube/db.inc.php
627732
mysql roundcube < /usr/share/dbconfig-common/data/roundcube/install/mysql
628733
mkdir -p /var/log/roundcube/error
629734
chmod -R 777 /var/log/roundcube
630735

631-
# Vesta configuration
632-
echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
633-
chmod 755 /etc/profile.d/vesta.sh
634-
source /etc/profile.d/vesta.sh
635-
echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
636-
echo 'export PATH' >> /root/.bash_profile
637-
source /root/.bash_profile
638-
wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
639-
640-
# Directory tree
641-
mkdir -p $VESTA/conf
642-
mkdir -p $VESTA/log
643-
mkdir -p $VESTA/ssl
644-
mkdir -p $VESTA/data
645-
mkdir -p $VESTA/data/ips
646-
mkdir -p $VESTA/data/queue
647-
mkdir -p $VESTA/data/users
648-
touch $VESTA/data/queue/backup.pipe
649-
touch $VESTA/data/queue/disk.pipe
650-
touch $VESTA/data/queue/webstats.pipe
651-
touch $VESTA/data/queue/restart.pipe
652-
touch $VESTA/data/queue/traffic.pipe
653-
chmod 750 $VESTA/conf
654-
chmod 750 $VESTA/data/users
655-
chmod 750 $VESTA/data/ips
656-
chmod -R 750 $VESTA/data/queue
657-
ln -s /usr/local/vesta/log /var/log/vesta
658-
touch /var/log/vesta/system.log
659-
touch /var/log/vesta/nginx-error.log
660-
touch /var/log/vesta/auth.log
661-
chmod 660 /var/log/vesta/*
662-
adduser backup > /dev/null 2>&1
663-
mkdir -p /home/backup
664-
chown backup:backup /home/backup
665-
ln -s /home/backup /backup
666-
chmod a+x /backup
667-
668-
# vesta.conf
669-
wget $CHOST/$VERSION/vesta.conf -O $VESTA/conf/vesta.conf
670-
if [ "$srv_type" = 'micro' ] || [ "$srv_type" = 'small' ]; then
671-
sed -i "s/clamav-daemon//g" $VESTA/conf/vesta.conf
672-
sed -i "s/spamassassin//g" $VESTA/conf/vesta.conf
673-
fi
674-
675-
# Templates
676-
cd /usr/local/vesta/data
677-
wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
678-
tar -xzf packages.tar.gz
679-
rm -f packages.tar.gz
680-
cd /usr/local/vesta/data
681-
wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
682-
tar -xzf templates.tar.gz
683-
rm -f templates.tar.gz
684-
chmod -R 755 /usr/local/vesta/data/templates
685-
cp templates/web/skel/public_html/index.html /var/www/
686-
sed -i 's/%domain%/It worked!/g' /var/www/index.html
687-
if [ "$srv_type" = 'micro' ]; then
688-
rm -f /usr/local/vesta/data/templates/web/apache2/phpfcgid.*
689-
fi
690-
691-
# Default SSL keys
692-
cd /usr/local/vesta/ssl
693-
wget $CHOST/$VERSION/certificate.crt -O certificate.crt
694-
wget $CHOST/$VERSION/certificate.key -O certificate.key
695-
696736
# Adding admin user
697737
if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" = 'yes' ]; then
698738
chattr -i /home/admin/conf > /dev/null 2>&1
@@ -704,7 +744,13 @@ fi
704744
if [ ! -z "$(grep ^admin: /etc/group)" ]; then
705745
groupdel admin > /dev/null 2>&1
706746
fi
707-
vpass=$(gen_pass)
747+
748+
# Generating admin password if it wasn't set
749+
if [ -z "$vpass" ]; then
750+
vpass=$(gen_pass)
751+
fi
752+
753+
# Adding vesta account
708754
$VESTA/bin/v-add-user admin $vpass $email default System Administrator
709755
if [ $? -ne 0 ]; then
710756
echo "Error: can't create admin user"
@@ -762,6 +808,11 @@ $VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
762808
# Build inititall rrd images
763809
$VESTA/bin/v-update-sys-rrd
764810

811+
# Enable file system quota
812+
if [ "$quota" = 'yes' ]; then
813+
$VESTA/bin/v-add-sys-quota
814+
fi
815+
765816
# Start system service
766817
update-rc.d vesta defaults
767818
service vesta stop > /dev/null 2>&1

0 commit comments

Comments
 (0)