new installer

This commit is contained in:
Serghey Rodin 2014-10-22 15:29:42 +03:00
commit 569bd23fe5
3 changed files with 149 additions and 53 deletions

View file

@ -17,17 +17,19 @@ software="nginx apache2 apache2-utils apache2-suexec-custom bsdutils e2fsprogs
clamav-daemon flex dovecot-imapd dovecot-pop3d phpMyAdmin awstats e2fslibs
webalizer jwhois rssh git spamassassin roundcube roundcube-mysql quota
roundcube-plugins apparmor-utils sudo bc ftp lsof ntpdate rrdtool
dnsutils vesta vesta-nginx vesta-php"
fail2ban dnsutils vesta vesta-nginx vesta-php"
help() {
echo "usage: $0 [OPTIONS]
-e, --email Set email address
-f, --force Force installation
-h, --help Print this help and exit
-n, --noupdate Do not run apt-get upgrade command
-m, --mysql-password Set MySQL password instead of generating it
-p, --password Set admin password instead of generating it
-f, --force Force installation
-i, --disable-iptables Disable iptables support
-b, --disable-fail2ban Disable fail2ban protection
-n, --noupdate Do not run yum update command
-s, --hostname Set server hostname
-e, --email Set email address
-p, --password Set admin password instead of generating it
-m, --mysql-password Set MySQL password instead of generating it
-q, --quota Enable File System Quota"
exit 1
}
@ -52,13 +54,15 @@ gen_pass() {
for arg; do
delim=""
case "$arg" in
--email) args="${args}-e " ;;
--force) args="${args}-f " ;;
--help) args="${args}-h " ;;
--force) args="${args}-f " ;;
--disable-fail2ban) args="${args}-b " ;;
--disable-iptables) args="${args}-i " ;;
--noupdate) args="${args}-n " ;;
--mysql-password) args="${args}-m " ;;
--password) args="${args}-p " ;;
--hostname) args="${args}-s " ;;
--email) args="${args}-e " ;;
--password) args="${args}-p " ;;
--mysql-password) args="${args}-m " ;;
--quota) args="${args}-q " ;;
*) [[ "${arg:0:1}" == "-" ]] || delim="\""
args="${args}${delim}${arg}${delim} ";;
@ -67,15 +71,17 @@ done
eval set -- "$args"
# Getopt
while getopts "dhfnqe:m:p:s:" Option; do
while getopts "hfibdnqe:m:p:s:" Option; do
case $Option in
h) help ;; # Help
e) email=$OPTARG ;; # Set email
f) force='yes' ;; # Force install
n) noupdate='yes' ;; # Disable apt-get upgrade
m) mpass=$OPTARG ;; # MySQL pasword
p) vpass=$OPTARG ;; # Admin password
i) disable_iptables='yes' ;; # Disable iptables
b) disable_fail2ban='yes' ;; # Disable fail2ban
n) noupdate='yes' ;; # Disable yum update
s) servername=$OPTARG ;; # Server hostname
e) email=$OPTARG ;; # Set email
p) vpass=$OPTARG ;; # Admin password
m) mpass=$OPTARG ;; # MySQL pasword
q) quota='yes' ;; # Enable quota
*) help ;; # Default
esac
@ -388,6 +394,11 @@ if [ "$srv_type" = 'small' ]; then
software=$(echo "$software" | sed -e 's/spamassassin//')
fi
# Exclude fail2ban
if [ "$disable_fail2ban" = 'yes' ]; then
software=$(echo "$software" | sed -e 's/fail2ban//')
fi
# Update system packages
apt-get update
@ -431,6 +442,7 @@ mkdir -p $VESTA/data
mkdir -p $VESTA/data/ips
mkdir -p $VESTA/data/queue
mkdir -p $VESTA/data/users
mkdir -p $VESTA/data/firewall
touch $VESTA/data/queue/backup.pipe
touch $VESTA/data/queue/disk.pipe
touch $VESTA/data/queue/webstats.pipe
@ -464,7 +476,7 @@ if [ -z "$servername" ]; then
fi
/usr/local/vesta/bin/v-change-sys-hostname $servername 2>/dev/null
# Templates
# Templates, packages
cd /usr/local/vesta/data
wget $CHOST/$VERSION/packages.tar.gz -O packages.tar.gz
tar -xzf packages.tar.gz
@ -489,6 +501,15 @@ if [ "$codename" = 'trusty' ]; then
rm -f /usr/local/vesta/data/templates/web/apache2/phpcgi.*
fi
# Firewall configuartion
wget $CHOST/$VERSION/firewall.tar.gz -O firewall.tar.gz
tar -xzf firewall.tar.gz
if [ "$disable_iptables" = 'yes' ]; then
sed -i "s/iptables//" $VESTA/conf/vesta.conf
else
$BIN/v-update-firewall
fi
# Generating SSL certificate
$VESTA/bin/v-generate-ssl-cert $(hostname) $email 'US' 'California' \
'San Francisco' 'Vesta Control Panel' 'IT' > /tmp/vst.pem
@ -713,6 +734,18 @@ if [ "$srv_type" = 'medium' ] || [ "$srv_type" = 'large' ]; then
fi
fi
# Fail2ban configuration
if [ -z "$disable_fail2ban" ]; then
cd /etc
wget $CHOST/$VERSION/fail2ban.tar.gz -O fail2ban.tar.gz
tar -xzf fail2ban.tar.gz
rm -f fail2ban.tar.gz
chkconfig fail2ban on
service fail2ban start
else
sed -i "s/fail2ban//" $VESTA/conf/vestac.conf
fi
# php configuration
sed -i "s/;date.timezone =/date.timezone = UTC/g" /etc/php5/apache2/php.ini
sed -i "s/;date.timezone =/date.timezone = UTC/g" /etc/php5/cli/php.ini