Skip to content

Commit 451de9d

Browse files
committed
New installer
1 parent 4836872 commit 451de9d

File tree

1 file changed

+131
-81
lines changed

1 file changed

+131
-81
lines changed

install/vst-install-rhel.sh

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

3-
# Vesta RHEL/CentOS installer v.03
3+
# Vesta RHEL/CentOS installer v.04
44

55
#----------------------------------------------------------#
66
# Variables&Functions #
@@ -13,20 +13,26 @@ VERSION='0.9.8/rhel'
1313
YUM_REPO='/etc/yum.repos.d/vesta.repo'
1414
software="nginx httpd mod_ssl mod_ruid2 mod_extract_forwarded mod_fcgid
1515
php php-bcmath php-cli php-common php-gd php-imap php-mbstring php-mcrypt
16-
php-mysql php-pdo php-soap php-tidy php-xml php-xmlrpc
16+
php-mysql php-pdo php-soap php-tidy php-xml php-xmlrpc quota e2fsprogs
1717
phpMyAdmin awstats webalizer vsftpd mysql mysql-server exim dovecot clamd
1818
spamassassin curl roundcubemail bind bind-utils bind-libs mc screen ftp
1919
libpng libjpeg libmcrypt mhash zip unzip openssl flex rssh libxml2
2020
ImageMagick sqlite pcre sudo bc jwhois mailx lsof tar telnet rsync
2121
rrdtool GeoIP freetype ntp openssh-clients vesta vesta-nginx vesta-php"
2222

23+
# Help
2324
help() {
2425
echo "usage: $0 [OPTIONS]
25-
-d, --disable-remi Disable remi
26-
-e, --email Define email address
27-
-h, --help Print this help and exit
26+
-d, --disable-remi Disable remi repository
27+
-e, --email Set email address
2828
-f, --force Force installation
29-
-n, --noupdate Do not run yum update command"
29+
-h, --help Print this help and exit
30+
-n, --noupdate Do not run yum update command
31+
-m, --mysql-password Set MySQL password instead of generating it
32+
-p, --password Set admin password instead of generating it
33+
-s, --hostname Set server hostname
34+
-q, --quota Enable File System Quota"
35+
3036
exit 1
3137
}
3238

@@ -50,25 +56,33 @@ gen_pass() {
5056
for arg; do
5157
delim=""
5258
case "$arg" in
53-
--help) args="${args}-h " ;;
54-
--disable-remi) args="${args}-d " ;;
55-
--force) args="${args}-f " ;;
56-
--email) args="${args}-e " ;;
57-
--noupdate) args="${args}-n " ;;
59+
--disable-remi) args="${args}-d " ;;
60+
--email) args="${args}-e " ;;
61+
--force) args="${args}-f " ;;
62+
--help) args="${args}-h " ;;
63+
--noupdate) args="${args}-n " ;;
64+
--mysql-password) args="${args}-m " ;;
65+
--password) args="${args}-p " ;;
66+
--hostname) args="${args}-s " ;;
67+
--quota) args="${args}-q " ;;
5868
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
5969
args="${args}${delim}${arg}${delim} ";;
6070
esac
6171
done
6272
eval set -- "$args"
6373

6474
# Getopt
65-
while getopts "dhfne:" Option; do
75+
while getopts "dhfnqe:m:p:s:" Option; do
6676
case $Option in
6777
d) disable_remi='yes' ;; # Disable remi repo
6878
h) help ;; # Help
6979
e) email=$OPTARG ;; # Set email
7080
f) force='yes' ;; # Force install
7181
n) noupdate='yes' ;; # Disable yum update
82+
m) mpass=$OPTARG ;; # MySQL pasword
83+
p) vpass=$OPTARG ;; # Admin password
84+
s) servername=$OPTARG ;; # Server hostname
85+
q) quota='yes' ;; # Enable quota
7286
*) help ;; # Default
7387
esac
7488
done
@@ -212,8 +226,16 @@ if [ -z $email ]; then
212226
exit 1
213227
fi
214228

215-
# Check email
229+
# Define email
216230
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
217239
fi
218240

219241
# Validate email
@@ -459,6 +481,84 @@ if [ -e '/etc/selinux/config' ]; then
459481
setenforce 0
460482
fi
461483

484+
# Vesta configuration
485+
echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
486+
chmod 755 /etc/profile.d/vesta.sh
487+
source /etc/profile.d/vesta.sh
488+
echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
489+
echo 'export PATH' >> /root/.bash_profile
490+
source /root/.bash_profile
491+
wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
492+
493+
# Directory tree
494+
mkdir -p $VESTA/conf
495+
mkdir -p $VESTA/log
496+
mkdir -p $VESTA/ssl
497+
mkdir -p $VESTA/data
498+
mkdir -p $VESTA/data/ips
499+
mkdir -p $VESTA/data/queue
500+
mkdir -p $VESTA/data/users
501+
touch $VESTA/data/queue/backup.pipe
502+
touch $VESTA/data/queue/disk.pipe
503+
touch $VESTA/data/queue/webstats.pipe
504+
touch $VESTA/data/queue/restart.pipe
505+
touch $VESTA/data/queue/traffic.pipe
506+
chmod 750 $VESTA/conf
507+
chmod 750 $VESTA/data/users
508+
chmod 750 $VESTA/data/ips
509+
chmod -R 750 $VESTA/data/queue
510+
ln -s /usr/local/vesta/log /var/log/vesta
511+
touch /var/log/vesta/system.log
512+
touch /var/log/vesta/nginx-error.log
513+
touch /var/log/vesta/auth.log
514+
chmod 660 /var/log/vesta/*
515+
adduser backup
516+
ln -s /home/backup /backup
517+
chmod a+x /backup
518+
519+
# vesta.conf
520+
wget $CHOST/$VERSION/vesta.conf -O $VESTA/conf/vesta.conf
521+
if [ "$srv_type" = 'micro' ] || [ "$srv_type" = 'small' ]; then
522+
sed -i "s/clamav//g" $VESTA/conf/vesta.conf
523+
sed -i "s/spamassassin//g" $VESTA/conf/vesta.conf
524+
fi
525+
526+
# Set server hostname
527+
/usr/local/vesta/bin/v-change-sys-hostname $servername 2>/dev/null
528+
529+
# Templates
530+
cd /usr/local/vesta/data
531+
wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
532+
tar -xzf packages.tar.gz
533+
rm -f packages.tar.gz
534+
cd /usr/local/vesta/data
535+
wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
536+
tar -xzf templates.tar.gz
537+
rm -f templates.tar.gz
538+
chmod -R 755 /usr/local/vesta/data/templates
539+
cp templates/web/skel/public_html/index.html /var/www/html/
540+
sed -i 's/%domain%/It worked!/g' /var/www/html/index.html
541+
if [ "$srv_type" = 'micro' ]; then
542+
rm -f /usr/local/vesta/data/templates/web/httpd/phpfcgid.*
543+
fi
544+
545+
# Generating SSL certificate
546+
$VESTA/bin/v-generate-ssl-cert $(hostname) $email 'US' 'California' \
547+
'San Francisco' 'Vesta Control Panel' 'IT' > /tmp/vst.pem
548+
549+
# Parsing merged certificate file
550+
crt_end=$(grep -n "END CERTIFICATE-" /tmp/vst.pem |cut -f 1 -d:)
551+
key_start=$(grep -n "BEGIN RSA" /tmp/vst.pem |cut -f 1 -d:)
552+
key_end=$(grep -n "END RSA" /tmp/vst.pem |cut -f 1 -d:)
553+
554+
# Adding SSL certificate
555+
cd /usr/local/vesta/ssl
556+
sed -n "1,${crt_end}p" /tmp/vst.pem > certificate.crt
557+
sed -n "$key_start,${key_end}p" /tmp/vst.pem > certificate.key
558+
chown root:mail /usr/local/vesta/ssl/*
559+
chmod 660 /usr/local/vesta/ssl/*
560+
rm /tmp/vst.pem
561+
462562
# Disabling iptables
463563
chkconfig iptables off
464564
service iptables stop
@@ -536,17 +636,14 @@ if [ "$?" -ne 0 ]; then
536636
fi
537637

538638
# MySQL configuration
539-
mpass=$(gen_pass)
540639
if [ "$srv_type" = 'micro' ]; then
541640
wget $CHOST/$VERSION/mysql-512.cnf -O /etc/my.cnf
542641
else
543642
wget $CHOST/$VERSION/mysql.cnf -O /etc/my.cnf
544643
fi
545-
546644
chkconfig mysqld on
547645
service mysqld start
548646
if [ "$?" -ne 0 ]; then
549-
550647
# Fix for aio on OpenVZ
551648
if [ -e "/proc/user_beancounters" ]; then
552649
sed -i "s/#innodb_use_native_aio/innodb_use_native_aio/g" /etc/my.cnf
@@ -559,6 +656,11 @@ if [ "$?" -ne 0 ]; then
559656
fi
560657
fi
561658

659+
# Generating MySQL password if it wasn't set
660+
if [ -z "$mpass" ]; then
661+
mpass=$(gen_pass)
662+
fi
663+
562664
mysqladmin -u root password $mpass
563665
echo -e "[client]\npassword='$mpass'\n" > /root/.my.cnf
564666
chmod 600 /root/.my.cnf
@@ -676,69 +778,6 @@ mysql -e "GRANT ALL ON roundcube.* TO roundcube@localhost IDENTIFIED BY '$r'"
676778
sed -i "s/%password%/$r/g" /etc/roundcubemail/db.inc.php
677779
mysql roundcube < /usr/share/doc/roundcubemail-*/SQL/mysql.initial.sql
678780

679-
# Vesta configuration
680-
echo "export VESTA='/usr/local/vesta'" > /etc/profile.d/vesta.sh
681-
chmod 755 /etc/profile.d/vesta.sh
682-
source /etc/profile.d/vesta.sh
683-
echo 'PATH=$PATH:/usr/local/vesta/bin' >> /root/.bash_profile
684-
echo 'export PATH' >> /root/.bash_profile
685-
source /root/.bash_profile
686-
wget $CHOST/$VERSION/vesta.log -O /etc/logrotate.d/vesta
687-
688-
# Directory tree
689-
mkdir -p $VESTA/conf
690-
mkdir -p $VESTA/log
691-
mkdir -p $VESTA/ssl
692-
mkdir -p $VESTA/data
693-
mkdir -p $VESTA/data/ips
694-
mkdir -p $VESTA/data/queue
695-
mkdir -p $VESTA/data/users
696-
touch $VESTA/data/queue/backup.pipe
697-
touch $VESTA/data/queue/disk.pipe
698-
touch $VESTA/data/queue/webstats.pipe
699-
touch $VESTA/data/queue/restart.pipe
700-
touch $VESTA/data/queue/traffic.pipe
701-
chmod 750 $VESTA/conf
702-
chmod 750 $VESTA/data/users
703-
chmod 750 $VESTA/data/ips
704-
chmod -R 750 $VESTA/data/queue
705-
ln -s /usr/local/vesta/log /var/log/vesta
706-
touch /var/log/vesta/system.log
707-
touch /var/log/vesta/nginx-error.log
708-
touch /var/log/vesta/auth.log
709-
chmod 660 /var/log/vesta/*
710-
adduser backup
711-
ln -s /home/backup /backup
712-
chmod a+x /backup
713-
714-
# vesta.conf
715-
wget $CHOST/$VERSION/vesta.conf -O $VESTA/conf/vesta.conf
716-
if [ "$srv_type" = 'micro' ] || [ "$srv_type" = 'small' ]; then
717-
sed -i "s/clamav//g" $VESTA/conf/vesta.conf
718-
sed -i "s/spamassassin//g" $VESTA/conf/vesta.conf
719-
fi
720-
721-
# Templates
722-
cd /usr/local/vesta/data
723-
wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
724-
tar -xzf packages.tar.gz
725-
rm -f packages.tar.gz
726-
cd /usr/local/vesta/data
727-
wget $CHOST/$VERSION/templates.tar.gz -O templates.tar.gz
728-
tar -xzf templates.tar.gz
729-
rm -f templates.tar.gz
730-
chmod -R 755 /usr/local/vesta/data/templates
731-
cp templates/web/skel/public_html/index.html /var/www/html/
732-
sed -i 's/%domain%/It worked!/g' /var/www/html/index.html
733-
if [ "$srv_type" = 'micro' ]; then
734-
rm -f /usr/local/vesta/data/templates/web/httpd/phpfcgid.*
735-
fi
736-
737-
# Default SSL keys
738-
cd /usr/local/vesta/ssl
739-
wget $CHOST/$VERSION/certificate.crt -O certificate.crt
740-
wget $CHOST/$VERSION/certificate.key -O certificate.key
741-
742781
# Adding admin user
743782
if [ ! -z "$(grep ^admin: /etc/passwd)" ] && [ "$force" = 'yes' ]; then
744783
chattr -i /home/admin/conf > /dev/null 2>&1
@@ -750,7 +789,13 @@ fi
750789
if [ ! -z "$(grep ^admin: /etc/group)" ] && [ "$force" = 'yes' ]; then
751790
groupdel admin > /dev/null 2>&1
752791
fi
753-
vpass=$(gen_pass)
792+
793+
# Generating admin password if it wasn't set
794+
if [ -z "$vpass" ]; then
795+
vpass=$(gen_pass)
796+
fi
797+
798+
# Adding vesta account
754799
$VESTA/bin/v-add-user admin $vpass $email default System Administrator
755800
if [ $? -ne 0 ]; then
756801
echo "Error: can't create admin user"
@@ -759,7 +804,7 @@ fi
759804
$VESTA/bin/v-change-user-shell admin bash
760805
$VESTA/bin/v-change-user-language admin en
761806

762-
# Configure mysql host
807+
# Configuring mysql host
763808
$VESTA/bin/v-add-database-host mysql localhost root $mpass
764809
$VESTA/bin/v-add-database admin default default $(gen_pass) mysql
765810

@@ -808,6 +853,11 @@ $VESTA/bin/v-add-cron-job 'admin' '*/5' '*' '*' '*' '*' "$command"
808853
# Build inititall rrd images
809854
$VESTA/bin/v-update-sys-rrd
810855

856+
# Enable file system quota
857+
if [ "$quota" = 'yes' ]; then
858+
$VESTA/bin/v-add-sys-quota
859+
fi
860+
811861
# Start system service
812862
chkconfig vesta on
813863
service vesta start

0 commit comments

Comments
 (0)