Răsfoiți Sursa

Merge branch 'master' into feature/800

Conflicts:
	bin/v-add-letsencrypt-user
Derrick Hammer 9 ani în urmă
părinte
comite
4daa17f54f
100 a modificat fișierele cu 1385 adăugiri și 193 ștergeri
  1. 23 0
      ISSUE_TEMPLATE.md
  2. 8 3
      README.md
  3. 6 0
      bin/v-add-dns-record
  4. 40 20
      bin/v-add-fs-archive
  5. 1 1
      bin/v-add-letsencrypt-user
  6. 2 2
      bin/v-add-mail-domain-dkim
  7. 2 6
      bin/v-add-remote-dns-domain
  8. 1 6
      bin/v-add-remote-dns-record
  9. 3 2
      bin/v-add-user
  10. 15 6
      bin/v-add-web-domain
  11. 2 2
      bin/v-add-web-domain-proxy
  12. 7 6
      bin/v-backup-user
  13. 1 6
      bin/v-change-remote-dns-domain-exp
  14. 1 6
      bin/v-change-remote-dns-domain-soa
  15. 1 6
      bin/v-change-remote-dns-domain-ttl
  16. 2 0
      bin/v-change-sys-config-value
  17. 119 0
      bin/v-change-sys-service-config
  18. 3 3
      bin/v-change-web-domain-backend-tpl
  19. 97 0
      bin/v-change-web-domain-name
  20. 2 2
      bin/v-change-web-domain-tpl
  21. 1 6
      bin/v-delete-remote-dns-domain
  22. 1 6
      bin/v-delete-remote-dns-domains
  23. 1 6
      bin/v-delete-remote-dns-record
  24. 1 1
      bin/v-generate-ssl-cert
  25. 1 1
      bin/v-list-cron-job
  26. 73 0
      bin/v-list-sys-clamd-config
  27. 103 0
      bin/v-list-sys-dovecot-config
  28. 82 0
      bin/v-list-sys-mysql-config
  29. 88 0
      bin/v-list-sys-nginx-config
  30. 70 0
      bin/v-list-sys-pgsql-config
  31. 94 0
      bin/v-list-sys-php-config
  32. 64 0
      bin/v-list-sys-proftpd-config
  33. 64 0
      bin/v-list-sys-spamd-config
  34. 1 1
      bin/v-list-sys-vesta-updates
  35. 64 0
      bin/v-list-sys-vsftpd-config
  36. 2 1
      bin/v-list-user-backup-exclusions
  37. 1 1
      bin/v-list-user-log
  38. 47 0
      bin/v-open-fs-config
  39. 5 0
      bin/v-open-fs-file
  40. 1 0
      bin/v-restart-cron
  41. 1 0
      bin/v-restart-dns
  42. 1 0
      bin/v-restart-ftp
  43. 1 0
      bin/v-restart-mail
  44. 1 0
      bin/v-restart-proxy
  45. 1 0
      bin/v-restart-service
  46. 1 0
      bin/v-restart-web
  47. 1 0
      bin/v-restart-web-backend
  48. 1 1
      bin/v-restore-user
  49. 1 6
      bin/v-sync-dns-cluster
  50. 3 3
      bin/v-update-sys-rrd-mem
  51. 1 3
      bin/v-update-sys-rrd-mysql
  52. 1 3
      bin/v-update-sys-rrd-pgsql
  53. 91 0
      bin/v-update-web-domain-ssl
  54. 1 1
      func/db.sh
  55. 17 30
      func/domain.sh
  56. 2 2
      func/ip.sh
  57. 12 11
      func/main.sh
  58. 10 0
      func/remote.sh
  59. 3 0
      install/debian/7/nginx/phpmyadmin.inc
  60. 10 0
      install/debian/7/php5-fpm/www.conf
  61. 2 2
      install/debian/7/templates/web/php5-fpm/socket.tpl
  62. 1 1
      install/debian/8/clamav/clamd.conf
  63. 3 0
      install/debian/8/exim/exim4.conf.template
  64. 3 0
      install/debian/8/nginx/phpmyadmin.inc
  65. 2 2
      install/debian/8/templates/web/php5-fpm/socket.tpl
  66. 0 0
      install/rhel/5/fail2ban/action.d/vesta.conf
  67. 1 1
      install/rhel/5/fail2ban/filter.d/vesta.conf
  68. 0 0
      install/rhel/5/fail2ban/jail.local
  69. 4 0
      install/rhel/5/nginx/phpmyadmin.inc
  70. 2 2
      install/rhel/5/templates/web/php-fpm/socket.tpl
  71. 0 0
      install/rhel/6/fail2ban/action.d/vesta.conf
  72. 1 1
      install/rhel/6/fail2ban/filter.d/vesta.conf
  73. 0 0
      install/rhel/6/fail2ban/jail.local
  74. 3 0
      install/rhel/6/nginx/phpmyadmin.inc
  75. 2 2
      install/rhel/6/templates/web/php-fpm/socket.tpl
  76. 1 1
      install/rhel/7/clamav/clamd.conf
  77. 1 1
      install/rhel/7/clamav/clamd.service
  78. 1 1
      install/rhel/7/exim/exim.conf
  79. 0 0
      install/rhel/7/fail2ban/action.d/vesta.conf
  80. 1 1
      install/rhel/7/fail2ban/filter.d/vesta.conf
  81. 0 0
      install/rhel/7/fail2ban/jail.local
  82. 3 0
      install/rhel/7/nginx/phpmyadmin.inc
  83. 2 2
      install/rhel/7/templates/web/php-fpm/socket.tpl
  84. 3 0
      install/ubuntu/12.04/nginx/phpmyadmin.inc
  85. 2 2
      install/ubuntu/12.04/templates/web/php5-fpm/socket.tpl
  86. 3 0
      install/ubuntu/12.10/nginx/phpmyadmin.inc
  87. 2 2
      install/ubuntu/12.10/templates/web/php5-fpm/socket.tpl
  88. 3 0
      install/ubuntu/13.04/nginx/phpmyadmin.inc
  89. 2 2
      install/ubuntu/13.04/templates/web/php5-fpm/socket.tpl
  90. 3 0
      install/ubuntu/13.10/nginx/phpmyadmin.inc
  91. 2 2
      install/ubuntu/13.10/templates/web/php5-fpm/socket.tpl
  92. 3 0
      install/ubuntu/14.04/nginx/phpmyadmin.inc
  93. 52 0
      install/ubuntu/14.04/templates/web/nginx/php5-fpm/opencart.tpl
  94. 2 2
      install/ubuntu/14.04/templates/web/php5-fpm/socket.tpl
  95. 3 0
      install/ubuntu/14.10/nginx/phpmyadmin.inc
  96. 2 2
      install/ubuntu/14.10/templates/web/php5-fpm/socket.tpl
  97. 3 0
      install/ubuntu/15.04/nginx/phpmyadmin.inc
  98. 2 2
      install/ubuntu/15.04/templates/web/php5-fpm/socket.tpl
  99. 3 0
      install/ubuntu/15.10/nginx/phpmyadmin.inc
  100. 2 2
      install/ubuntu/15.10/templates/web/php5-fpm/socket.tpl

+ 23 - 0
ISSUE_TEMPLATE.md

@@ -0,0 +1,23 @@
+### Operating System (OS/VERSION):
+
+Type here, e.g. CentOS 6
+
+### VestaCP Version:
+
+Type here, e.g. 3.14159
+
+### Installed Software (what you got with the installer):
+
+Type here, e.g. php-fpm, apache, nginx, mysql
+
+### Steps to Reproduce:
+
+Type here, e.g. install vesta and type rm -rf / --no-preserve-root
+
+### Related Issues/Forum Threads:
+
+Found anything that might be related to this? It might help us find the cause.
+
+### Other Notes:
+
+Anything else?

+ 8 - 3
README.md

@@ -5,8 +5,7 @@
 * Vesta has a clean and focused interface without the clutter.
 * Vesta has the latest of very innovative technologies.
 
-
-How to install
+How to install (2 step)
 ----------------------------
 Connect to your server as root via SSH
 ```bash
@@ -18,7 +17,13 @@ Download the installation script, and run it:
 curl http://vestacp.com/pub/vst-install.sh | bash
 ```
 
-If the above example does not work, try this 2 step method:
+How to install (3 step)
+----------------------------
+If the above example does not work, try this 3 step method:
+Connect to your server as root via SSH
+```bash
+ssh root@your.server
+```
 
 Download the installation script:
 ```bash

+ 6 - 0
bin/v-add-dns-record

@@ -49,6 +49,12 @@ if [[ $rtype =~ NS|CNAME|MX|PTR|SRV ]]; then
     fi
 fi
 
+dvalue=${dvalue//\"/}
+
+if [[ "$dvalue" =~ [\;[:space:]] ]]; then
+    dvalue='"'"$dvalue"'"'
+fi
+
 
 #----------------------------------------------------------#
 #                    Verifications                         #

+ 40 - 20
bin/v-add-fs-archive

@@ -6,11 +6,11 @@
 
 user=$1
 archive=$2
-src=$3
+src0=$3
 
 # Checking arguments
-if [ -z "$src" ]; then
-    echo "Usage: USER ARCHIVE SOURCE"
+if [ -z "$src0" ]; then
+    echo "Usage: USER ARCHIVE FILE [FILE_2] [FILE_3] [FILE ...]"
     exit 1
 fi
 
@@ -21,36 +21,56 @@ if [ ! -e "$VESTA/data/users/$user" ]; then
 fi
 
 # Checking user homedir
-homedir=$(grep "^$user:" /etc/passwd | cut -f 6 -d :)
+homedir=$(grep "^$user:" /etc/passwd |cut -f 6 -d :)
 if [ -z $homedir ]; then
     echo "Error: user home directory doesn't exist"
     exit 12
 fi
 
 # Checking archive
-if [ -e "$archive.tar.gz" ]; then
-    echo "Error: archive already exist $archive.tar.gz"
+if [ -e "$archive" ]; then
+    echo "Error: archive already exist $archive"
     exit 1
 fi
 
 # Checking source path
-rpath=$(readlink -f "$src")
-if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
-    echo "Error: invalid source path $src"
-    exit 1
-fi
+IFS=$'\n'
+i=1
+for src in $*; do
+    if [ "$i" -gt 2 ]; then
+        rpath=$(readlink -f "$src")
+        if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
+            echo "Error: invalid source path $src"
+            exit 1
+        fi
+    fi
+    ((i++))
+done
 
-# Parsing current directory
-d=$(dirname "$src")
+i=1
+for src in $*; do
+    if [ "$i" -gt 2 ]; then
+        # Deleting leading home path
+        src=$(echo "$src"| sed -e "s|/home/$user/||")
 
-# Removing leading file path
-f=$(echo "$src" |sed -e "s|$d/||")
+        # Creating tar.gz archive
+        sudo -u $user tar -rf "${archive/.gz/}" -C /home/$user $src >\
+            /dev/null 2>&1
+        if [ "$?" -ne 0 ]; then
+            echo "Error: archive $archive was not created"
+            exit 3
+        fi
+    fi
+    ((i++))
+done
 
-# Creating tar.gz archive
-sudo -u $user tar -czf "$archive.tar.gz" -C $d $f >/dev/null 2>&1
-if [ "$?" -ne 0 ]; then
-    echo "Error: archive $archive.tar.gz was not created"
-    exit 3
+# Checking gzip
+if [[ "$archive" =~ \.gz$ ]]; then
+    sudo -u $user gzip "${archive/.gz/}" >/dev/null 2>&1
+    if [ "$?" -ne 0 ]; then
+        echo "Error: archive $archive was not gziped"
+        exit 3
+    fi
 fi
 
 exit

+ 1 - 1
bin/v-add-letsencrypt-user

@@ -12,7 +12,7 @@
 # Argument definition
 user=$1
 email=$2
-key_size=2048
+key_size=4096
 
 # Includes
 source $VESTA/func/main.sh

+ 2 - 2
bin/v-add-mail-domain-dkim

@@ -63,11 +63,11 @@ fi
 # Adding dns records
 if [ ! -z "$DNS_SYSTEM" ] && [ -e "$USER_DATA/dns/$domain.conf" ]; then
     p=$(cat $USER_DATA/mail/$domain.pub |grep -v ' KEY---' |tr -d '\n')
-    record='_domainkey'
+    record="_domainkey.$domain_idn"
     policy="\"t=y; o=~;\""
     $BIN/v-add-dns-record $user $domain $record TXT "$policy"
 
-    record='mail._domainkey'
+    record="mail._domainkey.$domain_idn"
     selector="\"k=rsa\; p=$p\""
     $BIN/v-add-dns-record $user $domain $record TXT "$selector"
 fi

+ 2 - 6
bin/v-add-remote-dns-domain

@@ -14,6 +14,7 @@ user=$1
 domain=$2
 flush=$3
 
+
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/remote.sh
@@ -27,12 +28,7 @@ source $VESTA/conf/vesta.conf
 check_args '2' "$#" 'USER DOMAIN [FLUSH]'
 is_format_valid 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check
 
 

+ 1 - 6
bin/v-add-remote-dns-record

@@ -29,12 +29,7 @@ is_format_valid 'user' 'domain' 'id'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'dns' 'DOMAIN' "$domain"
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check
 
 

+ 3 - 2
bin/v-add-user

@@ -66,8 +66,9 @@ mkdir $HOMEDIR/$user/conf
 
 if [ ! -z "$WEB_SYSTEM" ]; then
     mkdir $HOMEDIR/$user/conf/web $HOMEDIR/$user/web $HOMEDIR/$user/tmp
-    chmod 751 $HOMEDIR/$user/conf/web $HOMEDIR/$user/web
-    chmod 771 $HOMEDIR/$user/tmp
+    chmod 751 $HOMEDIR/$user/conf/web 
+    chmod 710 $HOMEDIR/$user/web
+    chmod 700 $HOMEDIR/$user/tmp
     chown $user:$user $HOMEDIR/$user/web $HOMEDIR/$user/tmp
 fi
 

+ 15 - 6
bin/v-add-web-domain

@@ -1,6 +1,6 @@
 #!/bin/bash
 # info: add web domain
-# options: USER DOMAIN [IP] [ALIASES] [PROXY_EXTENTIONS] [RESTART]
+# options: USER DOMAIN [IP] [ALIASES] [PROXY_EXTENSIONS] [RESTART]
 #
 # The function adds virtual host to a server. In cases when ip is
 # undefined in the script, "default" template will be used. The alias of
@@ -55,7 +55,7 @@ source $VESTA/conf/vesta.conf
 #----------------------------------------------------------#
 
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
-check_args '2' "$#" 'USER DOMAIN [IP] [RESTART] [ALIASES] [PROXY_EXTENTIONS]'
+check_args '2' "$#" 'USER DOMAIN [IP] [RESTART] [ALIASES] [PROXY_EXTENSIONS]'
 is_format_valid 'user' 'domain' 'aliases' 'ip' 'proxy_ext'
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
@@ -120,12 +120,21 @@ if [ ! -z "$WEB_BACKEND" ]; then
     check_result $? "Backend error" >/dev/null
 fi
 
-# Preparing domain variables
-if [ "$aliases" != 'none' ]; then
-    ALIAS="www.$domain,$aliases,$(get_ip_alias $domain)"
-else
+# Preparing domain aliases
+if [ "$aliases" = 'none' ]; then
     ALIAS=''
+else
+    ALIAS="www.$domain"
+    if [ ! -z "$aliases" ]; then
+        ALIAS="$ALIAS,$aliases"
+    fi
+    ip_alias=$(get_ip_alias $domain)
+    if [ ! -z "$ip_alias" ]; then
+        ALIAS="$ALIAS,$ip_alias"
+    fi
 fi
+
+# Preparing domain variables
 prepare_web_domain_values
 
 # Adding web server config

+ 2 - 2
bin/v-add-web-domain-proxy

@@ -12,8 +12,7 @@
 
 # Argument definition
 user=$1
-domain=$(idn -t --quiet -u "$2" )
-domain_idn=$(idn -t --quiet -a "$domain")
+domain=$2
 template=$3
 default_extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls,\
 exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
@@ -51,6 +50,7 @@ is_proxy_template_valid $template
 
 # Defining domain parameters
 get_domain_values 'web'
+prepare_web_domain_values
 local_ip=$(get_real_ip $IP)
 
 # Preparing domain values for the template substitution

+ 7 - 6
bin/v-backup-user

@@ -485,7 +485,7 @@ local_backup(){
         # Removing old backup
         for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
             backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
-            echo -e "$(date "+%F %T") Roated: $backup_date" |\
+            echo -e "$(date "+%F %T") Rotated: $backup_date" |\
                 tee -a $BACKUP/$user.log
             rm -f $BACKUP/$backup
         done
@@ -509,8 +509,6 @@ local_backup(){
     localbackup='yes'
     echo -e "$(date "+%F %T") Local: $BACKUP/$user.$date.tar" |\
         tee -a $BACKUP/$user.log
-    U_BACKUPS=$(ls $BACKUP/ |grep "^$user." |wc -l)
-    update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
 }
 
 
@@ -594,7 +592,7 @@ ftp_backup() {
         backups_rm_number=$((backups_count - BACKUPS + 1))
         for backup in $(echo "$backup_list" |head -n $backups_rm_number); do 
             backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar$//")
-            echo -e "$(date "+%F %T") Roated ftp backup: $backup_date" |\
+            echo -e "$(date "+%F %T") Rotated ftp backup: $backup_date" |\
                 tee -a $BACKUP/$user.log
             ftpc "cd $BPATH" "delete $backup"
         done
@@ -729,7 +727,7 @@ sftp_backup() {
         backups_rm_number=$((backups_count - BACKUPS + 1))
         for backup in $(echo "$backup_list" |head -n $backups_rm_number); do
             backup_date=$(echo $backup |sed -e "s/$user.//" -e "s/.tar.*$//")
-            echo -e "$(date "+%F %T") Roated sftp backup: $backup_date" |\
+            echo -e "$(date "+%F %T") Rotated sftp backup: $backup_date" |\
                 tee -a $BACKUP/$user.log
             sftpc "cd $BPATH" "rm $backup" > /dev/null 2>&1
         done
@@ -807,11 +805,14 @@ chmod 660 $USER_DATA/backup.conf
 # Deleting task from queue
 sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe
 
+U_BACKUPS=$(grep BACKUP $USER_DATA/backup.conf |wc -l)
+update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
+
 # Send notification
 if [ -e "$BACKUP/$user.log" ]; then
     subj="$user → backup has been completed"
     email=$(get_user_value '$CONTACT')
-    cat $BACKUP/$user.log #|$SENDMAIL -s "$subj" $email $notify
+    cat $BACKUP/$user.log |$SENDMAIL -s "$subj" $email $notify
     rm $BACKUP/$user.log
 fi
 

+ 1 - 6
bin/v-change-remote-dns-domain-exp

@@ -28,12 +28,7 @@ is_format_valid 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'dns' 'DOMAIN' "$domain"
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check
 
 

+ 1 - 6
bin/v-change-remote-dns-domain-soa

@@ -28,12 +28,7 @@ is_format_valid 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'dns' 'DOMAIN' "$domain"
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result 1 $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $VESTA/bin/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result 1 $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check
 
 

+ 1 - 6
bin/v-change-remote-dns-domain-ttl

@@ -28,12 +28,7 @@ is_format_valid 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'dns' 'DOMAIN' "$domain"
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check
 
 

+ 2 - 0
bin/v-change-sys-config-value

@@ -18,6 +18,8 @@ value=$2
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
+
 
 #----------------------------------------------------------#
 #                    Verifications                         #

+ 119 - 0
bin/v-change-sys-service-config

@@ -0,0 +1,119 @@
+#!/bin/bash
+# info: change service config
+# options: CONFIG SERVICE [RESTART]
+#
+# The function for changing service confguration.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+src=$1
+service=$2
+restart=$3
+echo "$0 $*" >/tmp/t.log
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'CONFIG SERVICE [RESTART]'
+if [ ! -e "$src" ]; then
+    check_result "$E_NOTEXIST" "$src config doesn't exist"
+fi
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining dst config path
+case $service in
+    nginx)          dst='/etc/nginx/nginx.conf';;
+    httpd)          dst='/etc/httpd/conf/httpd.conf';;
+    apache2)        dst='/etc/apache2/apache2.conf';;
+    exim)           dst='/etc/exim/exim.conf';;
+    exim4)          dst='/etc/exim4/exim4.conf.template';;
+    vsftpd)         dst=$(find /etc/vsftpd* -name 'vsftpd.conf');;
+    proftpd)        dst=$(find /etc/proftpd* -name 'proftpd.conf');;
+    php)            dst=$(find /etc/php* -name php.ini);;
+    mysql)          dst=$(find /etc/my* -name my.cnf);;
+    mariadb)        dst=$(find /etc/my* -name my.cnf);;
+    postgresql)     dst=$($BIN/v-list-sys-pgsql-config plain |cut -f 1);;
+    postgresql-hba) dst=$($BIN/v-list-sys-pgsql-config plain |cut -f 2);;
+    dovecot)        dst=$(find /etc/dovecot* -name dovecot.conf);;
+    dovecot-1)      dst='/etc/dovecot/conf.d/10-auth.conf';;
+    dovecot-2)      dst='/etc/dovecot/conf.d/10-logging.conf';;
+    dovecot-3)      dst='/etc/dovecot/conf.d/10-mail.conf';;
+    dovecot-4)      dst='/etc/dovecot/conf.d/10-master.conf';;
+    dovecot-5)      dst='/etc/dovecot/conf.d/10-ssl.conf';;
+    dovecot-6)      dst='/etc/dovecot/conf.d/20-imap.conf';;
+    dovecot-7)      dst='/etc/dovecot/conf.d/20-pop3.conf';;
+    dovecot-8)      dst='/etc/dovecot/conf.d/auth-passwdfile.conf.ext';;
+    named)          dst='/etc/named.conf';;
+    bind9)          dst='/etc/bind/named.conf';;
+    bind9-opt)      dst='/etc/bind/named.conf.options';;
+    spamd)          dst=$($BIN/v-list-sys-spamd-config plain);;
+    spamassassin)   dst=$($BIN/v-list-sys-spamd-config plain);;
+    clamd)          dst=$($BIN/v-list-sys-clamd-config plain);;
+    cron)           dst='/etc/crontab';;
+    crond)          dst='/etc/crontab';;
+    fail2ban)       dst='/etc/fail2ban/jail.local';;
+    *)              check_result $E_NOTEXIST "service $service doesn't exist"
+esac
+
+# Checking config path
+for config in $dst; do
+    if [ ! -e "$config" ]; then
+        check_result $E_NOTEXIST "$service config doesn't exist"
+    fi
+done
+
+# Checking diff between src and dst configs
+for config in $dst; do
+    diff -q $src $config >/dev/null
+
+    if [ $? -ne 0 ]; then
+        cp $config $config.vst.back
+        cp $src $config
+        update="yes"
+    fi
+done
+
+# Restarting service
+if [ "$update" = 'yes' ] && [ "$restart" != 'no' ]; then
+    if [ "$service" = 'php' ]; then
+        if [ "$WEB_SYSTEM" = "nginx" ]; then
+            service=$WEB_BACKEND
+        else
+            service=$WEB_SYSTEM
+        fi
+    fi
+    if [[ "$service" =~ - ]]; then
+        service=$(echo ${service%-*})
+    fi
+
+    service $service restart >/dev/null 2>&1
+    if [ $? -ne 0 ]; then
+        for config in $dst; do
+            mv -f $config.vst.back $config
+        done
+        check_result $E_RESTART "$service failed to start with new config"
+    fi
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$ARGUMENTS"
+
+exit

+ 3 - 3
bin/v-change-web-domain-backend-tpl

@@ -45,7 +45,7 @@ is_backend_template_valid $template
 prepare_web_backend
 
 # Deleting backend
-rm -f $pool/$backend.conf
+rm -f $pool/$backend_type.conf
 
 # Allocating backend port
 backend_port=9000
@@ -63,10 +63,10 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
         -e "s|%user%|$user|"\
         -e "s|%domain%|$domain|"\
         -e "s|%domain_idn%|$domain_idn|"\
-        -e "s|%backend%|$backend|g" > $pool/$backend.conf
+        -e "s|%backend%|$backend_type|g" > $pool/$backend_type.conf
 
 # Checking backend pool configuration
-if [ "$backend" = "$user" ]; then
+if [ "$backend_type" = "$user" ]; then
     conf=$USER_DATA/web.conf
     fields='$DOMAIN'
     nohead=1

+ 97 - 0
bin/v-change-web-domain-name

@@ -0,0 +1,97 @@
+#!/bin/bash
+# info: change web domain name
+# options: USER DOMAIN NEW_DOMAIN [RESTART]
+#
+# The call is used for changing the domain name.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument defenition
+user=$1
+domain=$2
+new_domain=$3
+restart=$4
+
+domain_idn="$domain"
+if [[ "$domain" = *[![:ascii:]]* ]]; then
+    domain_idn=$(idn -t --quiet -a $domain)
+fi
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+source $VESTA/func/ip.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'USER DOMAIN NEW_DOMAIN [RESTART]'
+is_format_valid 'user' 'domain'
+is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'web' 'DOMAIN' "$domain"
+is_object_unsuspended 'web' 'DOMAIN' "$domain"
+check_new_domain=$(grep "DOMAIN='$new_domain'" $VESTA/data/users/*/web.conf)
+if [ ! -z "$check_new_domain" ]; then
+    check_result $E_EXISTS "$new_domain already exists"
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Fetching domain variables
+get_domain_values 'web'
+
+# Changing domain in web.conf
+sed -i "s/DOMAIN='$domain'/DOMAIN='$new_domain'/" $USER_DATA/web.conf
+new_alias=$(echo "$ALIAS,$domain" |\
+    sed -e "s/,/\n/g"|\
+    sed -e "s/^$new_domain$//g"|\
+    sed -e "/^$/d"|\
+    sed -e ':a;N;$!ba;s/\n/,/g')
+
+# Updating domain alias
+if [ "$ALIAS" != "$new_alias" ]; then
+    sed -i "s/ALIAS='$ALIAS'/ALIAS='$new_alias'/" $USER_DATA/web.conf
+fi
+
+# Moving document root and domain logs
+mv $HOMEDIR/$user/web/$domain $HOMEDIR/$user/web/$new_domain/
+cd /var/log/$WEB_SYSTEM/domains
+mv $domain.log $new_domain.log
+mv $domain.error.log $new_domain.error.log
+mv $domain.bytes $new_domain.bytes
+rm -f $HOMEDIR/$user/web/$new_domain/logs/$domain.*
+
+# Updating domain certificates
+if [ -e "$USER_DATA/ssl/$domain.crt" ]; then
+    cd $USER_DATA/ssl
+    mv $domain.crt $new_domain.crt
+    mv $domain.ca $new_domain.ca
+    mv $domain.pem $new_domain.pem
+    mv $domain.key $new_domain.key
+    rm -f $HOMEDIR/$user/conf/web/ssl.$domain.*
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Rebuilding vhosts
+$BIN/v-rebuild-web-domains $user $restart
+
+# Logging
+log_history "changed web domain name $old_domain to $new_domain"
+log_event "$OK" "$EVENT"
+
+exit

+ 2 - 2
bin/v-change-web-domain-tpl

@@ -54,9 +54,9 @@ fi
 
 # Defining variables for new vhost config
 prepare_web_domain_values
-add_web_config "$WEB_SYSTEM" "$TPL.tpl"
+add_web_config "$WEB_SYSTEM" "$template.tpl"
 if [ "$SSL" = 'yes' ]; then
-    add_web_config "$WEB_SYSTEM" "$TPL.stpl"
+    add_web_config "$WEB_SYSTEM" "$template.stpl"
 fi
 
 

+ 1 - 6
bin/v-delete-remote-dns-domain

@@ -26,12 +26,7 @@ source $VESTA/conf/vesta.conf
 check_args '2' "$#" 'USER DOMAIN'
 is_format_valid 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check
 
 

+ 1 - 6
bin/v-delete-remote-dns-domains

@@ -22,12 +22,7 @@ source $VESTA/conf/vesta.conf
 #----------------------------------------------------------#
 
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check
 
 

+ 1 - 6
bin/v-delete-remote-dns-record

@@ -27,12 +27,7 @@ source $VESTA/conf/vesta.conf
 check_args '3' "$#" 'USER DOMAIN ID'
 is_format_valid 'user' 'domain' 'id'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check
 
 

+ 1 - 1
bin/v-generate-ssl-cert

@@ -21,7 +21,7 @@ org=$6
 org_unit=$7
 aliases=$8
 format=${9-shell}
-KEY_SIZE=2048
+KEY_SIZE=4096
 DAYS=365
 
 # Includes

+ 1 - 1
bin/v-list-cron-job

@@ -23,7 +23,7 @@ json_list() {
     echo -n '    "'$job'": {
         "MIN": "'$MIN'",
         "HOUR": "'$HOUR'",
-        "DAY": "'$HOUR'",
+        "DAY": "'$DAY'",
         "MONTH": "'$MONTH'",
         "WDAY": "'$WDAY'",
         "CMD": "'$CMD'",

+ 73 - 0
bin/v-list-sys-clamd-config

@@ -0,0 +1,73 @@
+#!/bin/bash
+# info: list clamd config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of clamd config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+
+# JSON list function
+json_list() {
+    echo '{
+    "CONFIG": {
+        "config_path": "'$config_path'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "config_path:    $config_path"
+}
+
+# PLAIN list function
+plain_list() {
+    echo "$config_path"
+}
+
+# CSV list function
+csv_list() {
+    echo "config_path"
+    echo "$config_path"
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+if [ -e '/etc/clamav/clamd.conf' ]; then
+    config_path='/etc/clamav/clamd.conf'
+else
+    if [ -e '/etc/clamd.conf' ]; then
+        config_path='/etc/clamd.conf'
+    fi
+    if [ -e '/etc/clamd.d/clamd.conf' ]; then
+        config_path='/etc/clamav/clamd.conf'
+    fi
+fi
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 103 - 0
bin/v-list-sys-dovecot-config

@@ -0,0 +1,103 @@
+#!/bin/bash
+# info: list dovecot config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of dovecot config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+
+# JSON list function
+json_list() {
+    echo '{
+    "CONFIG": {
+        "config_path": "'$config_path'",
+        "config_path1": "'$config_path1'",
+        "config_path2": "'$config_path2'",
+        "config_path3": "'$config_path3'",
+        "config_path4": "'$config_path4'",
+        "config_path5": "'$config_path5'",
+        "config_path6": "'$config_path6'",
+        "config_path7": "'$config_path7'",
+        "config_path8": "'$config_path8'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "config_path:    $config_path"
+    echo "config_path1:   $config_path1"
+    echo "config_path2:   $config_path2"
+    echo "config_path3:   $config_path3"
+    echo "config_path4:   $config_path4"
+    echo "config_path5:   $config_path5"
+    echo "config_path6:   $config_path6"
+    echo "config_path7:   $config_path7"
+    echo "config_path8:   $config_path8"
+}
+
+# PLAIN list function
+plain_list() {
+    echo -en "$config_path\t"
+    echo -en "$config_path1\t"
+    echo -en "$config_path2\t"
+    echo -en "$config_path3\t"
+    echo -en "$config_path4\t"
+    echo -en "$config_path5\t"
+    echo -en "$config_path6\t"
+    echo -en "$config_path7\t"
+    echo -e "$config_path8\t"
+}
+
+# CSV list function
+csv_list() {
+    echo -n "config_path,config_path1,config_path2,config_path3,"
+    echo "config_path4,config_path5,config_path6,config_path7,config_path8"
+    echo -n "$config_path,$config_path1,$config_path2,$config_path3,"
+    echo -n "$config_path4,$config_path5,$config_path6,$config_path7,"
+    echo "$config_path8"
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+if [ -e '/etc/dovecot.conf' ]; then
+    config_path='/etc/dovecot.conf'
+else
+    config_path='/etc/dovecot/dovecot.conf'
+    config_path1='/etc/dovecot/conf.d/10-auth.conf'
+    config_path2='/etc/dovecot/conf.d/10-logging.conf'
+    config_path3='/etc/dovecot/conf.d/10-mail.conf'
+    config_path4='/etc/dovecot/conf.d/10-master.conf'
+    config_path5='/etc/dovecot/conf.d/10-ssl.conf'
+    config_path6='/etc/dovecot/conf.d/20-imap.conf'
+    config_path7='/etc/dovecot/conf.d/20-pop3.conf'
+    config_path8='/etc/dovecot/conf.d/auth-passwdfile.conf.ext'
+fi
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 82 - 0
bin/v-list-sys-mysql-config

@@ -0,0 +1,82 @@
+#!/bin/bash
+# info: list mysql config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of mysql config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+# JSON list function
+json_list() {
+    eval $(echo "$config"|egrep "$keys"|\
+        sed -e "s/[ ]*=/=/" -e "s/=[ ]*/=\'/" -e "s/$/'/")
+    echo '{
+    "CONFIG": {
+        "max_user_connections": "'$max_user_connections'",
+        "max_connections": "'$max_connections'",
+        "wait_timeout": "'$wait_timeout'",
+        "interactive_timeout": "'$interactive_timeout'",
+        "max_allowed_packet": "'$max_allowed_packet'",
+        "config_path": "'$config_path'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "$config" |egrep "$keys" |tr '=' ' '
+    echo "config_path $config_path"
+}
+
+# PLAIN list function
+plain_list() {
+    echo "$config" |egrep "$keys" |tr '=' ' '
+    echo "config_path $config_path"
+}
+
+# CSV list function
+csv_list() {
+    echo "$keys" |sed "s/|/,/g"
+    echo "$config" |egrep "$keys" |tr '=' ' ' |awk '{print $2}' |tr '\n' ','
+    echo
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+config_path=$(find /etc/my* -name my.cnf)
+
+# Defining keys
+keys="max_user_connections|max_connections|wait_timeout|interactive_timeout"
+keys="${keys}|max_allowed_packet"
+
+# Reading config
+config=$(cat $config_path|grep -v "^;")
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list |column -t;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 88 - 0
bin/v-list-sys-nginx-config

@@ -0,0 +1,88 @@
+#!/bin/bash
+# info: list nginx config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of nginx config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+
+# JSON list function
+json_list() {
+    eval $(echo "$config" |egrep "$keys" |tr -d ';'| awk '{print $1"="$2}')
+    echo '{
+    "CONFIG": {
+        "worker_processes": "'$worker_processes'",
+        "worker_connections": "'$worker_connections'",
+        "send_timeout": "'$send_timeout'",
+        "proxy_connect_timeout": "'$proxy_connect_timeout'",
+        "proxy_send_timeout": "'$proxy_send_timeout'",
+        "proxy_read_timeout": "'$proxy_read_timeout'",
+        "client_max_body_size": "'$client_max_body_size'",
+        "gzip": "'$gzip'",
+        "gzip_comp_level": "'$gzip_comp_level'",
+        "charset": "'$charset'",
+        "config_path": "'$config_path'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "$config" |egrep "$keys" |tr -d ';'
+    echo "config_path    $config_path"
+}
+
+# PLAIN list function
+plain_list() {
+    echo "$config" |egrep "$keys" |tr -d ';'
+    echo "config_path $config_path"
+}
+
+# CSV list function
+csv_list() {
+    echo "$keys" |sed "s/ |/,/g"
+    echo "$config" |egrep "$keys" |awk '{print $2}' |tr -d ';' |tr '\n' ','
+    echo
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+config_path='/etc/nginx/nginx.conf'
+
+# Defining keys
+keys="worker_processes |worker_connections |send_timeout"
+keys="$keys |proxy_connect_timeout |proxy_send_timeout"
+keys="$keys |proxy_read_timeout |client_max_body_size"
+keys="$keys |gzip |gzip_comp_level |charset "
+
+
+# Reading nginx config
+config=$(cat $config_path)
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list |column -t;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 70 - 0
bin/v-list-sys-pgsql-config

@@ -0,0 +1,70 @@
+#!/bin/bash
+# info: list postgresql config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of postgresql config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+
+# JSON list function
+json_list() {
+    echo '{
+    "CONFIG": {
+        "pg_hba_path": "'$pg_hba_path'",
+        "config_path": "'$config_path'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "config_path:    $config_path"
+    echo "pg_hba_path:    $pg_hba_path"
+}
+
+# PLAIN list function
+plain_list() {
+    echo -e "$config_path\t$pg_hba_path"
+}
+
+# CSV list function
+csv_list() {
+    echo "config_path,pg_hba_path"
+    echo "$config_path,$pg_hba_path"
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+config_path=$(find /etc/postgresql /var/lib/pgsql/data -name \
+    postgresql.conf 2>/dev/null)
+pg_hba_path=$(find /etc/postgresql /var/lib/pgsql/data -name \
+    pg_hba.conf 2>/dev/null)
+
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 94 - 0
bin/v-list-sys-php-config

@@ -0,0 +1,94 @@
+#!/bin/bash
+# info: list php config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of php config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+# JSON list function
+json_list() {
+    eval $(echo "$config"|egrep "$keys"|\
+        sed -e "s/[ ]*=/=/" -e "s/=[ ]*/=\'/" -e "s/$/'/")
+    echo '{
+    "CONFIG": {
+        "memory_limit": "'$memory_limit'",
+        "max_execution_time": "'$max_execution_time'",
+        "max_input_time": "'$max_input_time'",
+        "upload_max_filesize": "'$upload_max_filesize'",
+        "post_max_size": "'$post_max_size'",
+        "display_errors": "'$display_errors'",
+        "error_reporting": "'$error_reporting'",
+        "config_path": "'$config_path'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "$config" |egrep "$keys" |tr -d '='
+    echo "config_path $config_path"
+}
+
+# PLAIN list function
+plain_list() {
+    echo "$config" |egrep "$keys" |tr -d '='
+    echo "config_path $config_path"
+}
+
+# CSV list function
+csv_list() {
+    echo "$keys" |sed "s/ |/,/g"
+    echo "$config" |egrep "$keys" |tr -d '=' |awk '{print $2}' |tr '\n' ','
+    echo
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+config_path=$(find /etc/php* -name php.ini)
+config_count=$(echo "$config_path" |wc -l)
+if [ "$config_count" -gt 1  ]; then
+    if [ "$WEB_SYSTEM" = "nginx" ]; then
+        config_path=$(echo "$config_path"| grep fpm)
+    else
+        config_path=$(echo "$config_path"| grep apache)
+    fi
+fi
+
+
+# Defining keys
+keys="memory_limit |max_execution_time |max_input_time"
+keys="$keys |upload_max_filesize |post_max_size"
+keys="$keys |display_errors |error_reporting "
+
+# Reading config
+config=$(cat $config_path|grep -v "^;")
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list |column -t;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 64 - 0
bin/v-list-sys-proftpd-config

@@ -0,0 +1,64 @@
+#!/bin/bash
+# info: list proftpd config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of proftpd config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+
+# JSON list function
+json_list() {
+    echo '{
+    "CONFIG": {
+        "config_path": "'$config_path'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "config_path:    $config_path"
+}
+
+# PLAIN list function
+plain_list() {
+    echo "$config_path"
+}
+
+# CSV list function
+csv_list() {
+    echo "config_path"
+    echo "$config_path"
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+config_path=$(find /etc/proftpd* -name proftpd.conf 2>/dev/null)
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 64 - 0
bin/v-list-sys-spamd-config

@@ -0,0 +1,64 @@
+#!/bin/bash
+# info: list spamassassin config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of spamassassin config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+
+# JSON list function
+json_list() {
+    echo '{
+    "CONFIG": {
+        "config_path": "'$config_path'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "config_path:    $config_path"
+}
+
+# PLAIN list function
+plain_list() {
+    echo "$config_path"
+}
+
+# CSV list function
+csv_list() {
+    echo "config_path"
+    echo "$config_path"
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+config_path=$(find /etc/spamassassin /etc/mail -name  local.cf 2>/dev/null)
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 1 - 1
bin/v-list-sys-vesta-updates

@@ -81,7 +81,7 @@ else
     TIME=$(date -d @$pkg_date +"%T")
 fi
 UPDATED='yes'
-if [ ! -z "$latest" ] && [ "$latest" != "vesta-$VERSION-$RELEASE" ]; then
+if [ ! -z "$latest" ] && [ "$latest" \> "vesta-$VERSION-$RELEASE" ]; then
     UPDATED='no'
 fi
 data="NAME='vesta' VERSION='$VERSION' RELEASE='$RELEASE' ARCH='$ARCH'"

+ 64 - 0
bin/v-list-sys-vsftpd-config

@@ -0,0 +1,64 @@
+#!/bin/bash
+# info: list vsftpd config parameters
+# options: [FORMAT]
+#
+# The function for obtaining the list of vsftpd config parameters.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+format=${1-shell}
+
+# Includes
+source $VESTA/func/main.sh
+
+# JSON list function
+json_list() {
+    echo '{
+    "CONFIG": {
+        "config_path": "'$config_path'"
+        }
+}'
+}
+
+# SHELL list function
+shell_list() {
+    echo "config_path:    $config_path"
+}
+
+# PLAIN list function
+plain_list() {
+    echo "$config_path"
+}
+
+# CSV list function
+csv_list() {
+    echo "config_path"
+    echo "$config_path"
+}
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining config path
+config_path=$(find /etc/vsftpd* -name vsftpd.conf 2>/dev/null)
+
+# Listing data
+case $format in
+    json)   json_list ;;
+    plain)  plain_list ;;
+    csv)    csv_list ;;
+    shell)  shell_list;;
+esac
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+exit

+ 2 - 1
bin/v-list-user-backup-exclusions

@@ -18,6 +18,7 @@ source $VESTA/func/main.sh
 
 # JSON list function
 json_list() {
+    set -f
     i=1
     echo '{'
     echo '    "WEB": {'
@@ -27,7 +28,7 @@ json_list() {
         object_keys=$(echo ${object//:/ } |wc -w)
         for key in $(echo "${object/:/ }"); do
             if [ "$j" -eq 1 ]; then
-                echo -n "        \"$key\": "
+                echo -n "        \"${key}\": "
                 if [ "$object_keys" -eq 1 ]; then
                     echo -n '""'
                 fi

+ 1 - 1
bin/v-list-user-log

@@ -27,7 +27,7 @@ json_list() {
         echo -n '    "'$ID'": {
         "CMD": "'$CMD'",
         "UNDO": "'$UNDO'",
-        "DATE": "'$DATE'",
+        "TIME": "'$TIME'",
         "DATE": "'$DATE'"
     }'
         if [ "$i" -lt "$objects" ]; then

+ 47 - 0
bin/v-open-fs-config

@@ -0,0 +1,47 @@
+#!/bin/bash
+# info: open config
+# options: CONFIG
+#
+# The function opens/reads config files on the file system
+
+src_file=$1
+
+# Checking arguments
+if [ -z "$src_file" ]; then
+    echo "Usage: CONFIG"
+    exit 1
+fi
+
+# Checking vesta user
+if [ ! -e "$VESTA/data/users/$user" ]; then
+    echo "Error: vesta user $user doesn't exist"
+    exit 3
+fi
+
+# Checking file on fs
+if [ ! -e "$src_file" ]; then
+    echo "Error: $src_file file doesn't exist"
+    exit 3
+fi
+
+# Checking path
+if [ ! -z "$src_file" ]; then
+    rpath=$(readlink -f "$src_file")
+    services="nginx|apache|httpd|php|ftp|bind|named|exim|dovecot|spamassassin"
+    services="$services|clam|mysql|postgresql|pgsql|cron|fail2ban|iptables"
+    spath=$(echo "$rpath" |egrep "$services")
+    if [ -z "$spath" ]; then
+        echo "Error: invalid source path $src_file"
+        exit 2
+    fi
+fi
+
+# Reading conf
+cat "$src_file" 2>/dev/null
+if [ $? -ne 0 ]; then
+    echo "Error: file $src_file was not opened"
+    exit 3
+fi
+
+# Exiting
+exit

+ 5 - 0
bin/v-open-fs-file

@@ -33,6 +33,11 @@ if [ ! -z "$src_file" ]; then
         echo "Error: invalid source path $src_file"
         exit 2
     fi
+    
+    if [ ! -f "$src_file" ]; then
+        echo "Error: file not found $src_file"
+        exit 2
+    fi
 fi
 
 # Reading file

+ 1 - 0
bin/v-restart-cron

@@ -12,6 +12,7 @@
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 send_email_report() {
     email=$(grep CONTACT $VESTA/data/users/admin/user.conf)

+ 1 - 0
bin/v-restart-dns

@@ -12,6 +12,7 @@
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 send_email_report() {
     if [ -e '/etc/named.conf' ]; then

+ 1 - 0
bin/v-restart-ftp

@@ -12,6 +12,7 @@
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 send_email_report() {
     email=$(grep CONTACT $VESTA/data/users/admin/user.conf)

+ 1 - 0
bin/v-restart-mail

@@ -12,6 +12,7 @@
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 send_email_report() {
     email=$(grep CONTACT $VESTA/data/users/admin/user.conf)

+ 1 - 0
bin/v-restart-proxy

@@ -12,6 +12,7 @@
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 send_email_report() {
     email=$(grep CONTACT $VESTA/data/users/admin/user.conf)

+ 1 - 0
bin/v-restart-service

@@ -14,6 +14,7 @@ service=$1
 
 # Includes
 source $VESTA/func/main.sh
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 
 #----------------------------------------------------------#

+ 1 - 0
bin/v-restart-web

@@ -12,6 +12,7 @@
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 send_email_report() {
     email=$(grep CONTACT $VESTA/data/users/admin/user.conf)

+ 1 - 0
bin/v-restart-web-backend

@@ -12,6 +12,7 @@
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
+PATH="$PATH:/usr/local/sbin:/sbin:/usr/sbin:/root/bin"
 
 send_email_report() {
     email=$(grep CONTACT $VESTA/data/users/admin/user.conf)

+ 1 - 1
bin/v-restore-user

@@ -488,7 +488,7 @@ if [ "$db" != 'no' ] && [ ! -z "$DB_SYSTEM" ]; then
         echo -e "$(date "+%F %T") $database" |tee -a $tmpdir/restore.log
 
         # Checking database existance
-        check_config=$(grep "DB='$db'" $USER_DATA/db.conf)
+        check_config=$(grep "DB='$database'" $USER_DATA/db.conf)
 
         # Unpacking database container
         tar xf $BACKUP/$backup -C $tmpdir ./db/$database

+ 1 - 6
bin/v-sync-dns-cluster

@@ -22,12 +22,7 @@ source $VESTA/conf/vesta.conf
 #----------------------------------------------------------#
 
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
-if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
-fi
-if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
-    check_result $E_EXISTS "another sync process already running"
-fi
+is_procces_running
 remote_dns_health_check 'no_email'
 
 

+ 3 - 3
bin/v-update-sys-rrd-mem

@@ -61,9 +61,9 @@ fi
 # Parsing data
 if [ "$period" = 'daily' ]; then
     mem=$(free -m)
-    used=$(echo "$mem" |awk '{print $3}'|head -n3 |tail -n1)
-    free=$(echo "$mem" |awk '{print $4}'|head -n3 |tail -n1)
-    swap=$(echo "$mem" |awk '{print $3}'|tail -n1)
+    used=$(echo "$mem" |grep Mem |awk '{print $3}')
+    free=$(echo "$mem" |grep Mem |awk '{print $4}')
+    swap=$(echo "$mem" |grep Swap |awk '{print $3}')
 
     # Updating rrd
     rrdtool update $RRD/mem/mem.rrd N:$used:$swap:$free

+ 1 - 3
bin/v-update-sys-rrd-mysql

@@ -37,9 +37,7 @@ fi
 
 # Parsing db hosts
 conf="$VESTA/conf/mysql.conf"
-fields='$HOST'
-nohead=1
-hosts=$(shell_list)
+hosts=$(grep HOST $conf |awk '{print $1}' |cut -f 2 -d \')
 check_row=$(echo "$hosts" |wc -l)
 if [ 0 -eq "$check_row" ]; then
     exit

+ 1 - 3
bin/v-update-sys-rrd-pgsql

@@ -37,9 +37,7 @@ fi
 
 # Parsing db hosts
 conf="$VESTA/conf/pgsql.conf"
-fields='$HOST'
-nohead=1
-hosts=$(shell_list)
+hosts=$(grep HOST $conf |awk '{print $1}' |cut -f 2 -d \')
 check_row=$(echo "$hosts" |wc -l)
 if [ 0 -eq "$check_row" ]; then
     exit

+ 91 - 0
bin/v-update-web-domain-ssl

@@ -0,0 +1,91 @@
+#!/bin/bash
+# info: updating ssl certificate for domain
+# options: USER DOMAIN SSL_DIR [RESTART]
+#
+# The function updates the SSL certificate for a domain. Parameter ssl_dir is a path
+# to directory where 2 or 3 ssl files can be found. Certificate file 
+# domain.tld.crt and its key domain.tld.key  are mandatory. Certificate
+# authority domain.tld.ca file is optional. 
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+domain=$(idn -t --quiet -u "$2" )
+domain_idn=$(idn -t --quiet -a "$domain")
+ssl_dir=$3
+restart="$4"
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+source $VESTA/func/ip.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]'
+validate_format 'user' 'domain' 'ssl_dir'
+is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
+is_system_enabled "$WEB_SSL" 'SSL_SUPPORT'
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+is_object_valid 'web' 'DOMAIN' "$domain"
+is_object_unsuspended 'web' 'DOMAIN' "$domain"
+is_object_value_exist 'web' 'DOMAIN' "$domain" '$SSL'
+is_web_domain_cert_valid
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding certificate to user data directory
+cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.crt
+cp -f $ssl_dir/$domain.key $USER_DATA/ssl/$domain.key
+cp -f $ssl_dir/$domain.crt $USER_DATA/ssl/$domain.pem
+if [ -e "$ssl_dir/$domain.ca" ]; then
+    cp -f $ssl_dir/$domain.ca $USER_DATA/ssl/$domain.ca
+    echo >> $USER_DATA/ssl/$domain.pem
+    cat $USER_DATA/ssl/$domain.ca >> $USER_DATA/ssl/$domain.pem
+fi
+chmod 660 $USER_DATA/ssl/$domain.*
+
+
+
+# Adding certificate to user dir
+cp -f $USER_DATA/ssl/$domain.crt $HOMEDIR/$user/conf/web/ssl.$domain.crt
+cp -f $USER_DATA/ssl/$domain.key $HOMEDIR/$user/conf/web/ssl.$domain.key
+cp -f $USER_DATA/ssl/$domain.pem $HOMEDIR/$user/conf/web/ssl.$domain.pem
+if [ -e "$USER_DATA/ssl/$domain.ca" ]; then
+    cp -f $USER_DATA/ssl/$domain.ca $HOMEDIR/$user/conf/web/ssl.$domain.ca
+fi
+
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Restarting web server
+if [ "$restart" != 'no' ]; then
+    $BIN/v-restart-web
+    check_result $? "Web restart failed" >/dev/null
+
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
+    fi
+fi
+
+# Logging
+log_history "update ssl certificate for $domain"
+log_event "$OK" "$EVENT"
+
+exit

+ 1 - 1
func/db.sh

@@ -387,7 +387,7 @@ get_mysql_disk_usage() {
     query="SELECT SUM( data_length + index_length ) / 1024 / 1024 \"Size\"
         FROM information_schema.TABLES WHERE table_schema='$database'"
     usage=$(mysql_query "$query" |tail -n1)
-    if [ "$usage" == 'NULL' ] || [ "${usage:0:1}" -eq '0' ]; then
+    if [ "$usage" == '' ] || [ "$usage" == 'NULL' ] || [ "${usage:0:1}" -eq '0' ]; then
         usage=1
     fi
     export LC_ALL=C

+ 17 - 30
func/domain.sh

@@ -223,7 +223,7 @@ add_web_config() {
     trigger="${2/.*pl/.sh}"
     if [ -x "$WEBTPL/$1/$WEB_BACKEND/$trigger" ]; then
         $WEBTPL/$1/$WEB_BACKEND/$trigger \
-            $user $domain $ip $HOMEDIR $HOMEDIR/$user/web/$domain/public_html
+            $user $domain $local_ip $HOMEDIR $HOMEDIR/$user/web/$domain/public_html
     fi
 }
 
@@ -237,7 +237,7 @@ get_web_config_lines() {
     fi
 
     vhost_lines=$(grep -niF "name $domain_idn" $2)
-    vhost_lines=$(echo "$vhost_lines" |egrep "$domain_idn$|$domain_idn ")
+    vhost_lines=$(echo "$vhost_lines" |egrep "$domain_idn($| |;)") #"
     vhost_lines=$(echo "$vhost_lines" |cut -f 1 -d :)
     if [ -z "$vhost_lines" ]; then
         check_result $E_PARSING "can't parse config $2"
@@ -271,8 +271,8 @@ del_web_config() {
     get_web_config_lines $WEBTPL/$1/$WEB_BACKEND/$2 $conf
     sed -i "$top_line,$bottom_line d" $conf
 
-    web_domains=$(grep DOMAIN $USER_DATA/web.conf |wc -l)
-    if [ "$web_domains" -eq '0' ]; then
+    web_domain=$(grep $domain $USER_DATA/web.conf |wc -l)
+    if [ "$web_domain" -eq '0' ]; then
         sed -i "/.*\/$user\/.*$1.conf/d" /etc/$1/conf.d/vesta.conf
         rm -f $conf
     fi
@@ -281,29 +281,21 @@ del_web_config() {
 # SSL certificate verification
 is_web_domain_cert_valid() {
     if [ ! -e "$ssl_dir/$domain.crt" ]; then
-        echo "Error: $ssl_dir/$domain.crt not found"
-        log_event "$E_NOTEXIST" "$ARGUMENTS"
-        exit $E_NOTEXIST
+        check_result $E_NOTEXIST "$ssl_dir/$domain.crt not found"
     fi
 
     if [ ! -e "$ssl_dir/$domain.key" ]; then
-        echo "Error: $ssl_dir/$domain.key not found"
-        log_event "$E_NOTEXIST" "$ARGUMENTS"
-        exit $E_NOTEXIST
+        check_result $E_NOTEXIST "$ssl_dir/$domain.key not found"
     fi
 
     crt_vrf=$(openssl verify $ssl_dir/$domain.crt 2>&1)
-    if [ ! -z "$(echo $crt_vrf | grep 'unable to load')" ]; then
-        echo "Error: SSL Certificate is not valid"
-        log_event "$E_INVALID" "$ARGUMENTS"
-        exit $E_INVALID
+    if [ ! -z "$(echo $crt_vrf |grep 'unable to load')" ]; then
+        check_result $E_INVALID "SSL Certificate is not valid"
     fi
 
-    if [ ! -z "$(echo $crt_vrf | grep 'unable to get local issuer')" ]; then
+    if [ ! -z "$(echo $crt_vrf |grep 'unable to get local issuer')" ]; then
         if [ ! -e "$ssl_dir/$domain.ca" ]; then
-            echo "Error: Certificate Authority not found"
-            log_event "$E_NOTEXIST" "$ARGUMENTS"
-            exit $E_NOTEXIST
+            check_result $E_NOTEXIST "Certificate Authority not found"
         fi
     fi
 
@@ -313,17 +305,16 @@ is_web_domain_cert_valid() {
         s2=$(openssl x509 -text -in $ssl_dir/$domain.ca 2>/dev/null)
         s2=$(echo "$s2" |grep Subject  |awk -F = '{print $6}' |head -n1)
         if [ "$s1" != "$s2" ]; then
-            echo "Error: SSL intermediate chain is not valid"
-            log_event "$E_NOTEXIST" "$ARGUMENTS"
-            exit $E_NOTEXIST
+            check_result $E_NOTEXIST "SSL intermediate chain is not valid"
         fi
     fi
 
-    key_vrf=$(grep 'PRIVATE KEY' $ssl_dir/$domain.key | wc -l)
+    key_vrf=$(grep 'PRIVATE KEY' $ssl_dir/$domain.key |wc -l)
     if [ "$key_vrf" -ne 2 ]; then
-        echo "Error: SSL Key is not valid"
-        log_event "$E_INVALID" "$ARGUMENTS"
-        exit $E_INVALID
+        check_result $E_INVALID "SSL Key is not valid"
+    fi
+    if [ ! -z "$(grep 'ENCRYPTED' $ssl_dir/$domain.key)" ]; then
+        check_result $E_FORBIDEN "SSL Key is protected (remove pass_phrase)"
     fi
 
     openssl s_server -quiet -cert $ssl_dir/$domain.crt \
@@ -332,11 +323,7 @@ is_web_domain_cert_valid() {
     sleep 0.5
     disown &> /dev/null
     kill $pid &> /dev/null
-    if [ "$?" -ne '0' ]; then
-        echo "Error: ssl certificate key pair is not valid"
-        log_event "$E_INVALID" "$ARGUMENTS"
-        exit $E_INVALID
-    fi
+    check_result $? "ssl certificate key pair is not valid" $E_INVALID
 }
 
 

+ 2 - 2
func/ip.sh

@@ -87,9 +87,9 @@ increase_ip_value() {
     fi
 
     sed -i "s/$web_key='$current_web'/$web_key='$new_web'/g" \
-        $VESTA/data/ips/$ip
+        $VESTA/data/ips/$sip
     sed -i "s/$usr_key='$current_usr'/$usr_key='$new_usr'/g" \
-        $VESTA/data/ips/$ip
+        $VESTA/data/ips/$sip
 }
 
 # Decrease ip value

+ 12 - 11
func/main.sh

@@ -1,3 +1,4 @@
+#!/usr/bin/env bash
 # Internal variables
 HOMEDIR='/home'
 BACKUP='/backup'
@@ -97,7 +98,7 @@ check_result() {
 # Argument list checker
 check_args() {
     if [ "$1" -gt "$2" ]; then
-        echo "Usage: $SCRIPT $3"
+        echo "Usage: $(basename $0) $3"
         check_result $E_ARGS "not enought arguments" >/dev/null
     fi
 }
@@ -448,6 +449,7 @@ sync_cron_jobs() {
     rm -f $crontab
     if [ "$CRON_REPORTS" = 'yes' ]; then
         echo "MAILTO=$CONTACT" > $crontab
+        echo 'CONTENT_TYPE="text/plain; charset=utf-8"' >> $crontab
     fi
     while read line; do
         eval $line
@@ -465,12 +467,12 @@ sync_cron_jobs() {
 is_user_format_valid() {
     if [ ${#1} -eq 1 ]; then
         if ! [[ "$1" =~ ^^[[:alnum:]]$ ]]; then
-            echo "invalid $2 format :: $1"
+            check_result $E_INVALID "invalid $2 format :: $1"
         fi
     else
         if ! [[ "$1" =~ ^[[:alnum:]][-|\.|_[:alnum:]]{0,28}[[:alnum:]]$ ]]
             then
-            echo "invalid $2 format :: $1"
+            check_result $E_INVALID "invalid $2 format :: $1"
         fi
     fi
 }
@@ -479,7 +481,7 @@ is_user_format_valid() {
 is_domain_format_valid() {
     object_name=${2-domain}
     exclude="[!|@|#|$|^|&|*|(|)|+|=|{|}|:|,|<|>|?|_|/|\|\"|'|;|%|\`| ]"
-    if [[ $1 =~ $exclude ]] || [[ $1 =~ ^[0-9]+$ ]] || [[ $1 =~ \.\. ]]; then
+    if [[ $1 =~ $exclude ]] || [[ $1 =~ ^[0-9]+$ ]] || [[ $1 =~ "\.\." ]]; then
         check_result $E_INVALID "invalid $object_name format :: $1"
     fi
 }
@@ -501,15 +503,14 @@ is_alias_format_valid() {
 is_ip_format_valid() {
     object_name=${2-ip}
     ip_regex='([1-9]?[0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])'
-    ip_clean=$(echo "${1%/[0-9][0-9]}")
-    ip_clean=$(echo "${1%/[0-9]}")
+    ip_clean=$(echo "${1%/*}")
     if ! [[ $ip_clean =~ ^$ip_regex\.$ip_regex\.$ip_regex\.$ip_regex$ ]]; then
         check_result $E_INVALID "invalid $object_name format :: $1"
     fi
     if [ $1 != "$ip_clean" ]; then
         ip_cidr="$ip_clean/"
         ip_cidr=$(echo "${1#$ip_cidr}")
-        if [[ "$ip_cidr" -gt 32 ]]; then
+        if [[ "$ip_cidr" -gt 32 ]] || [[ "$ip_cidr" =~ [:alnum:] ]]; then
             check_result $E_INVALID "invalid $object_name format :: $1"
         fi
     fi
@@ -589,7 +590,7 @@ is_dbuser_format_valid() {
 
 # DNS record type validator
 is_dns_type_format_valid() {
-    known_dnstype='A,AAAA,NS,CNAME,MX,TXT,SRV,DNSKEY,KEY,IPSECKEY,PTR,SPF'
+    known_dnstype='A,AAAA,NS,CNAME,MX,TXT,SRV,DNSKEY,KEY,IPSECKEY,PTR,SPF,TLSA'
     if [ -z "$(echo $known_dnstype |grep -w $1)" ]; then
         check_result $E_INVALID "invalid dns record type format :: $1"
     fi
@@ -601,10 +602,10 @@ is_dns_record_format_valid() {
         is_ip_format_valid "$1"
     fi
     if [ "$rtype" = 'NS' ]; then
-        is_domain_format_valid "$1" 'ns_record'
+        is_domain_format_valid "${1::-1}" 'ns_record'
     fi
     if [ "$rtype" = 'MX' ]; then
-        is_domain_format_valid "$1" 'mx_record'
+        is_domain_format_valid "${1::-1}" 'mx_record'
         is_int_format_valid "$priority" 'priority_record'
     fi
 
@@ -612,7 +613,7 @@ is_dns_record_format_valid() {
 
 # Email format validator
 is_email_format_valid() {
-    if [[ ! "$1" =~ "@" ]] ; then
+    if [[ ! "$1" =~ ^[A-Za-z0-9._%+-]+@[[:alnum:].-]+\.[A-Za-z]{2,63}$ ]] ; then
         check_result $E_INVALID "invalid email format :: $1"
     fi
 }

+ 10 - 0
func/remote.sh

@@ -1,3 +1,13 @@
+# Check if script already running or not
+is_procces_running() {
+    SCRIPT=$(basename $0)
+    for pid in $(pidof -x $SCRIPT); do
+        if [ $pid != $$ ]; then
+            check_result $E_INUSE "$SCRIPT is already running"
+        fi
+    done
+}
+
 send_api_cmd() {
     answer=$(curl -s -k \
         --data-urlencode "user=$USER" \

+ 3 - 0
install/debian/7/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 10 - 0
install/debian/7/php5-fpm/www.conf

@@ -0,0 +1,10 @@
+[www]
+listen = 127.0.0.1:9000
+listen.allowed_clients = 127.0.0.1
+user = www-data
+group = www-data
+pm = dynamic
+pm.max_children = 50
+pm.start_servers = 5
+pm.min_spare_servers = 3
+pm.max_spare_servers = 35

+ 2 - 2
install/debian/7/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 1 - 1
install/debian/8/clamav/clamd.conf

@@ -8,7 +8,7 @@ LocalSocketMode 666
 # TemporaryDirectory is not set to its default /tmp here to make overriding
 # the default with environment variables TMPDIR/TMP/TEMP possible
 User clamav
-AllowSupplementaryGroups true
+# AllowSupplementaryGroups true
 ScanMail true
 ScanArchive true
 ArchiveBlockEncrypted false

+ 3 - 0
install/debian/8/exim/exim4.conf.template

@@ -8,6 +8,9 @@
 #SPAM_SCORE = 50
 #CLAMD =  yes
 
+add_environment=<; PATH=/bin:/usr/bin
+keep_environment=
+
 domainlist local_domains = dsearch;/etc/exim4/domains/
 domainlist relay_to_domains = dsearch;/etc/exim4/domains/
 hostlist relay_from_hosts = 127.0.0.1

+ 3 - 0
install/debian/8/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/debian/8/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 0 - 0
install/rhel/5/fail2ban/fail2ban.action.conf → install/rhel/5/fail2ban/action.d/vesta.conf


+ 1 - 1
install/rhel/5/fail2ban/fail2ban.filter.conf → install/rhel/5/fail2ban/filter.d/vesta.conf

@@ -1,4 +1,4 @@
-# Fail2Ban filter for unsuccessful Vesta authentication attempts
+# Fail2Ban filter for unsuccesfull Vesta authentication attempts
 #
 
 [INCLUDES]

+ 0 - 0
install/rhel/5/fail2ban/fail2ban.jail.conf → install/rhel/5/fail2ban/jail.local


+ 4 - 0
install/rhel/5/nginx/phpmyadmin.inc

@@ -12,4 +12,8 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
+
 }

+ 2 - 2
install/rhel/5/templates/web/php-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 0 - 0
install/rhel/6/fail2ban/fail2ban.action.conf → install/rhel/6/fail2ban/action.d/vesta.conf


+ 1 - 1
install/rhel/6/fail2ban/fail2ban.filter.conf → install/rhel/6/fail2ban/filter.d/vesta.conf

@@ -1,4 +1,4 @@
-# Fail2Ban filter for unsuccessful Vesta authentication attempts
+# Fail2Ban filter for unsuccesfull Vesta authentication attempts
 #
 
 [INCLUDES]

+ 0 - 0
install/rhel/6/fail2ban/fail2ban.jail.conf → install/rhel/6/fail2ban/jail.local


+ 3 - 0
install/rhel/6/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/rhel/6/templates/web/php-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 1 - 1
install/rhel/7/clamav/clamd.conf

@@ -197,7 +197,7 @@ AllowSupplementaryGroups yes
 
 # Don't fork into background.
 # Default: no
-#Foreground yes
+Foreground yes
 
 # Enable debug messages in libclamav.
 # Default: no

+ 1 - 1
install/rhel/7/clamav/clamd.service

@@ -4,7 +4,7 @@ After = syslog.target nss-lookup.target network.target
 
 [Service]
 Type = simple
-ExecStart = /usr/sbin/clamd -c /etc/clamd.conf --nofork=yes
+ExecStart = /usr/sbin/clamd -c /etc/clamd.conf
 Restart = on-failure
 PrivateTmp = true
 

+ 1 - 1
install/rhel/7/exim/exim.conf

@@ -143,7 +143,7 @@ acl_check_data:
          hosts          = !+relay_from_hosts
          condition      = ${if < {$message_size}{100K}}
          condition      = ${if eq{$acl_m1}{yes}{yes}{no}}
-         spam           = nobody:true/defer_ok
+         spam           = spamd:true/defer_ok
          add_header     = X-Spam-Score: $spam_score_int
          add_header     = X-Spam-Bar: $spam_bar
          add_header     = X-Spam-Report: $spam_report

+ 0 - 0
install/rhel/7/fail2ban/fail2ban.action.conf → install/rhel/7/fail2ban/action.d/vesta.conf


+ 1 - 1
install/rhel/7/fail2ban/fail2ban.filter.conf → install/rhel/7/fail2ban/filter.d/vesta.conf

@@ -1,4 +1,4 @@
-# Fail2Ban filter for unsuccessful Vesta authentication attempts
+# Fail2Ban filter for unsuccesfull Vesta authentication attempts
 #
 
 [INCLUDES]

+ 0 - 0
install/rhel/7/fail2ban/fail2ban.jail.conf → install/rhel/7/fail2ban/jail.local


+ 3 - 0
install/rhel/7/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/rhel/7/templates/web/php-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 3 - 0
install/ubuntu/12.04/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/ubuntu/12.04/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 3 - 0
install/ubuntu/12.10/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/ubuntu/12.10/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 3 - 0
install/ubuntu/13.04/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/ubuntu/13.04/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 3 - 0
install/ubuntu/13.10/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/ubuntu/13.10/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 3 - 0
install/ubuntu/14.04/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 52 - 0
install/ubuntu/14.04/templates/web/nginx/php5-fpm/opencart.tpl

@@ -0,0 +1,52 @@
+server {
+    listen      %ip%:%web_port%;
+    server_name %domain_idn% %alias_idn%;
+    root        %docroot%;
+    index       index.php index.html index.htm;
+    access_log  /var/log/nginx/domains/%domain%.log combined;
+    access_log  /var/log/nginx/domains/%domain%.bytes bytes;
+    error_log   /var/log/nginx/domains/%domain%.error.log error;
+
+    location / {
+
+        try_files $uri $uri/ @opencart;
+
+        location ~* ^.+\.(jpeg|jpg|png|gif|bmp|ico|svg|css|js)$ {
+            expires     max;
+        }
+
+        location ~ [^/]\.php(/|$) {
+            fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
+            if (!-f $document_root$fastcgi_script_name) {
+                return  404;
+            }
+
+            fastcgi_pass    %backend_lsnr%;
+            fastcgi_index   index.php;
+            include         /etc/nginx/fastcgi_params;
+        }
+    }
+
+    location @opencart {
+        rewrite ^/(.+)$ /index.php?_route_=$1 last;
+    }
+
+    error_page  403 /error/404.html;
+    error_page  404 /error/404.html;
+    error_page  500 502 503 504 /error/50x.html;
+
+    location /error/ {
+        alias   %home%/%user%/web/%domain%/document_errors/;
+    }
+
+    location ~* "/\.(htaccess|htpasswd)$" {
+        deny    all;
+        return  404;
+    }
+
+    include     /etc/nginx/conf.d/phpmyadmin.inc*;
+    include     /etc/nginx/conf.d/phppgadmin.inc*;
+    include     /etc/nginx/conf.d/webmail.inc*;
+
+    include     %home%/%user%/conf/web/nginx.%domain%.conf*;
+}

+ 2 - 2
install/ubuntu/14.04/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 3 - 0
install/ubuntu/14.10/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/ubuntu/14.10/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 3 - 0
install/ubuntu/15.04/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/ubuntu/15.04/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

+ 3 - 0
install/ubuntu/15.10/nginx/phpmyadmin.inc

@@ -12,4 +12,7 @@ location /phpmyadmin {
         include fastcgi_params;
         fastcgi_param SCRIPT_FILENAME $request_filename;
     }
+    location ~* ^/phpmyadmin/(.+\.(jpg|jpeg|gif|css|png|js|ico|html|xml|txt))$ {
+        root /usr/share/;
+    }
 }

+ 2 - 2
install/ubuntu/15.10/templates/web/php5-fpm/socket.tpl

@@ -5,8 +5,8 @@ listen.allowed_clients = 127.0.0.1
 user = %user%
 group = %user%
 
-listen.owner = %user%
-listen.group = nginx
+listen.owner = www-data
+listen.group = www-data
 
 pm = dynamic
 pm.max_children = 50

Unele fișiere nu au fost afișate deoarece prea multe fișiere au fost modificate în acest diff