Przeglądaj źródła

Merge branch 'master' of https://github.com/Neilpang/vesta

neil 10 lat temu
rodzic
commit
3d419795b0
100 zmienionych plików z 1659 dodań i 935 usunięć
  1. 4 0
      .gitignore
  2. 0 0
      LICENSE
  3. 10 4
      README.md
  4. 66 0
      bin/v-acknowledge-user-notification
  5. 67 0
      bin/v-activate-vesta-license
  6. 4 12
      bin/v-add-backup-host
  7. 4 6
      bin/v-add-cron-job
  8. 3 5
      bin/v-add-cron-reports
  9. 1 1
      bin/v-add-cron-restart-job
  10. 4 6
      bin/v-add-cron-vesta-autoupdate
  11. 2 6
      bin/v-add-database
  12. 3 7
      bin/v-add-database-host
  13. 53 18
      bin/v-add-dns-domain
  14. 44 52
      bin/v-add-dns-on-web-alias
  15. 4 5
      bin/v-add-dns-record
  16. 18 21
      bin/v-add-domain
  17. 1 1
      bin/v-add-firewall-ban
  18. 1 1
      bin/v-add-firewall-chain
  19. 1 1
      bin/v-add-firewall-rule
  20. 56 0
      bin/v-add-fs-archive
  21. 44 0
      bin/v-add-fs-directory
  22. 44 0
      bin/v-add-fs-file
  23. 2 6
      bin/v-add-mail-account
  24. 1 1
      bin/v-add-mail-account-alias
  25. 1 1
      bin/v-add-mail-account-autoreply
  26. 1 1
      bin/v-add-mail-account-forward
  27. 1 1
      bin/v-add-mail-account-fwd-only
  28. 1 1
      bin/v-add-mail-domain
  29. 2 2
      bin/v-add-mail-domain-antispam
  30. 2 2
      bin/v-add-mail-domain-antivirus
  31. 2 2
      bin/v-add-mail-domain-catchall
  32. 1 1
      bin/v-add-mail-domain-dkim
  33. 34 75
      bin/v-add-remote-dns-domain
  34. 18 27
      bin/v-add-remote-dns-host
  35. 35 56
      bin/v-add-remote-dns-record
  36. 57 0
      bin/v-add-sys-firewall
  37. 4 8
      bin/v-add-sys-ip
  38. 30 34
      bin/v-add-sys-quota
  39. 106 0
      bin/v-add-sys-sftp-jail
  40. 39 54
      bin/v-add-user
  41. 125 0
      bin/v-add-user-favourites
  42. 71 0
      bin/v-add-user-notification
  43. 1 1
      bin/v-add-user-package
  44. 66 0
      bin/v-add-user-sftp-jail
  45. 84 54
      bin/v-add-web-domain
  46. 8 10
      bin/v-add-web-domain-alias
  47. 3 5
      bin/v-add-web-domain-backend
  48. 7 6
      bin/v-add-web-domain-ftp
  49. 105 0
      bin/v-add-web-domain-httpauth
  50. 4 6
      bin/v-add-web-domain-proxy
  51. 7 9
      bin/v-add-web-domain-ssl
  52. 1 1
      bin/v-add-web-domain-stats
  53. 3 7
      bin/v-add-web-domain-stats-user
  54. 52 68
      bin/v-backup-user
  55. 4 2
      bin/v-backup-users
  56. 3 5
      bin/v-change-cron-job
  57. 2 6
      bin/v-change-database-host-password
  58. 1 1
      bin/v-change-database-owner
  59. 2 6
      bin/v-change-database-password
  60. 2 6
      bin/v-change-database-user
  61. 3 3
      bin/v-change-dns-domain-exp
  62. 5 6
      bin/v-change-dns-domain-ip
  63. 4 5
      bin/v-change-dns-domain-soa
  64. 4 5
      bin/v-change-dns-domain-tpl
  65. 5 6
      bin/v-change-dns-domain-ttl
  66. 4 5
      bin/v-change-dns-record
  67. 4 5
      bin/v-change-dns-record-id
  68. 1 1
      bin/v-change-domain-owner
  69. 1 1
      bin/v-change-firewall-rule
  70. 51 0
      bin/v-change-fs-file-permission
  71. 2 6
      bin/v-change-mail-account-password
  72. 1 1
      bin/v-change-mail-account-quota
  73. 2 2
      bin/v-change-mail-domain-catchall
  74. 18 55
      bin/v-change-remote-dns-domain-exp
  75. 20 56
      bin/v-change-remote-dns-domain-soa
  76. 20 70
      bin/v-change-remote-dns-domain-ttl
  77. 1 1
      bin/v-change-sys-config-value
  78. 1 1
      bin/v-change-sys-hostname
  79. 1 1
      bin/v-change-sys-ip-name
  80. 2 4
      bin/v-change-sys-ip-nat
  81. 1 1
      bin/v-change-sys-ip-owner
  82. 1 1
      bin/v-change-sys-ip-status
  83. 1 1
      bin/v-change-sys-language
  84. 1 1
      bin/v-change-sys-timezone
  85. 1 1
      bin/v-change-user-contact
  86. 9 4
      bin/v-change-user-language
  87. 1 1
      bin/v-change-user-name
  88. 29 10
      bin/v-change-user-ns
  89. 2 1
      bin/v-change-user-package
  90. 2 6
      bin/v-change-user-password
  91. 12 3
      bin/v-change-user-shell
  92. 2 2
      bin/v-change-user-template
  93. 5 8
      bin/v-change-web-domain-backend-tpl
  94. 2 6
      bin/v-change-web-domain-ftp-password
  95. 1 1
      bin/v-change-web-domain-ftp-path
  96. 76 0
      bin/v-change-web-domain-httpauth
  97. 12 14
      bin/v-change-web-domain-ip
  98. 5 7
      bin/v-change-web-domain-proxy-tpl
  99. 12 11
      bin/v-change-web-domain-sslcert
  100. 12 11
      bin/v-change-web-domain-sslhome

+ 4 - 0
.gitignore

@@ -0,0 +1,4 @@
+*.tar
+*.zip
+*.gzip
+*.gz

+ 0 - 0
LICENSE.txt → LICENSE


+ 10 - 4
README.md

@@ -13,17 +13,23 @@ Connect to your server as root via SSH
 ssh root@your.server
 ssh root@your.server
 ```
 ```
 
 
-Download the installation script
+Download the installation script, and run it:
 ```bash
 ```bash
-curl -O http://vestacp.com/pub/vst-install.sh
+curl http://vestacp.com/pub/vst-install.sh | bash
 ```
 ```
 
 
-Run it
+If the above example does not work, try this 2 step method:
+
+Download the installation script:
+```bash
+curl -O http://vestacp.com/pub/vst-install.sh
+```
+Then run it:
 ```bash
 ```bash
 bash vst-install.sh
 bash vst-install.sh
 ```
 ```
 
 
 License
 License
 ----------------------------
 ----------------------------
-Vesta is licensed under  [GPL v3 ](https://github.com/serghey-rodin/vesta/blob/master/LICENSE.txt) license
+Vesta is licensed under  [GPL v3 ](https://github.com/serghey-rodin/vesta/blob/master/LICENSE) license
 
 

+ 66 - 0
bin/v-acknowledge-user-notification

@@ -0,0 +1,66 @@
+#!/bin/bash
+# info: update user notification
+# options: USER NOTIFICATION
+#
+# The function updates user notification.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+nid=$2
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'USER NOTIFICATION'
+validate_format 'user' 'nid'
+is_object_valid 'user' 'USER' "$user"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Updating notification
+update_object_value 'notifications' 'NID' "$nid" '$ACK' 'yes' 2>/dev/null
+
+# Checking last notification
+if [ -e "$USER_DATA/notifications.conf" ]; then
+    if [ -z "$(grep NID= $USER_DATA/notifications.conf)" ]; then
+        notice='no'
+    fi
+    if [ -z "$(grep "ACK='no'" $USER_DATA/notifications.conf)" ]; then
+        notice='no'
+    fi
+else
+    notice='no'
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating notification counter
+if [ "$notice" = 'no' ]; then
+    if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then
+        sed -i "s/^TIME/NOTIFICATIONS='no'\nTIME/g" $USER_DATA/user.conf
+    else
+        update_user_value "$user" '$NOTIFICATIONS' "no"
+    fi
+fi
+
+# Logging
+log_event "$OK" "$EVENT"
+
+exit

+ 67 - 0
bin/v-activate-vesta-license

@@ -0,0 +1,67 @@
+#!/bin/bash
+# info: activate vesta license
+# options: MODULE LICENSE
+#
+# The function activates and registers the vesta license
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+module=$(echo $1 | tr '[:lower:]' '[:upper:]')
+license=$2
+
+# Importing system environment
+source /etc/profile
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+# Checking arg number
+check_args '2' "$#" 'MODULE LICENSE'
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Activating license
+v_host='https://vestacp.com/checkout'
+answer=$(curl -s $v_host/activate.php?licence_key=$license&module=$module)
+check_result $? "cant' connect to vestacp.com " $E_CONNECT
+
+# Checking server answer
+if [[ "$answer" != '0' ]]; then
+    echo "Error: $module license $license is invalid"
+    exit $E_INVALID
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating vesta.conf
+if [ -z "$(grep "${module}_KEY" $VESTA/conf/vesta.conf)" ]; then
+    echo "${module}_KEY='$license'" >> $VESTA/conf/vesta.conf
+else
+    sed -i "s/${module}_KEY=.*/${module}_KEY='$license'/g" $VESTA/conf/vesta.conf
+fi
+
+# Activating sftpjail
+if [ "$module" = 'SFTPJAIL' ]; then
+    setsid $BIN/v-add-sys-sftp-jail 2>/dev/null
+fi
+
+# Logging
+log_event "$OK" "$EVENT"
+
+exit

+ 4 - 12
bin/v-add-backup-host

@@ -2,18 +2,18 @@
 # info: add backup host
 # info: add backup host
 # options: TYPE HOST USERNAME PASSWORD [PATH] [PORT]
 # options: TYPE HOST USERNAME PASSWORD [PATH] [PORT]
 #
 #
-# The function adds backup host
+# This function adds a backup host
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 type=$1
 type=$1
 host=$2
 host=$2
 user=$3
 user=$3
-password=$4
+password=$4; HIDE=4
 path=${5-/backup}
 path=${5-/backup}
 port=$6
 port=$6
 
 
@@ -21,10 +21,6 @@ port=$6
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 # Defining ftp command function
 # Defining ftp command function
 ftpc() {
 ftpc() {
     ftp -p -n $host $port <<EOF
     ftp -p -n $host $port <<EOF
@@ -102,11 +98,7 @@ if [ "$type" != 'local' ];then
     is_password_valid
     is_password_valid
     if [ "$type" = 'sftp' ]; then
     if [ "$type" = 'sftp' ]; then
         which expect >/dev/null 2>&1
         which expect >/dev/null 2>&1
-        if [ $? -ne 0 ];then
-            echo "Error: expect utility not found"
-            log_event "$E_NOTEXIST" "$EVENT"
-            exit $E_NOTEXIST
-        fi
+        check_result $? "expect command not found"  $E_NOTEXIST
     fi
     fi
 fi
 fi
 
 

+ 4 - 6
bin/v-add-cron-job

@@ -10,7 +10,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 min=$2
 min=$2
 hour=$3
 hour=$3
@@ -25,7 +25,7 @@ restart=$9
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Assing new value
+# Assigning new value
 A7="$command"
 A7="$command"
 
 
 
 
@@ -72,11 +72,9 @@ sync_cron_jobs
 # Increasing cron value
 # Increasing cron value
 increase_user_value $user '$U_CRON_JOBS'
 increase_user_value $user '$U_CRON_JOBS'
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "added cron job $job"
 log_history "added cron job $job"

+ 3 - 5
bin/v-add-cron-reports

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 # info: add cron reports
 # info: add cron reports
-# opions: user
+# options: user
 #
 #
 # The script for enabling reports on cron tasks and administrative
 # The script for enabling reports on cron tasks and administrative
 # notifications.
 # notifications.
@@ -10,7 +10,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 
 
 # Includes
 # Includes
@@ -46,9 +46,7 @@ sync_cron_jobs
 
 
 # Restart crond
 # Restart crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "enabled cron reporting"
 log_history "enabled cron reporting"

+ 1 - 1
bin/v-add-cron-restart-job

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 # info: add cron reports
 # info: add cron reports
-# opions: NONE
+# options: NONE
 #
 #
 # The script for enabling restart cron tasks
 # The script for enabling restart cron tasks
 
 

+ 4 - 6
bin/v-add-cron-vesta-autoupdate

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=admin
 user=admin
 
 
 # Includes
 # Includes
@@ -34,7 +34,7 @@ fi
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Define time somewhere at nigth
+# Define time somewhere at night
 min=$(gen_password '012345' '2')
 min=$(gen_password '012345' '2')
 hour=$(gen_password '1234567' '1')
 hour=$(gen_password '1234567' '1')
 day='*'
 day='*'
@@ -66,11 +66,9 @@ sync_cron_jobs
 # Increasing cron value
 # Increasing cron value
 increase_user_value $user '$U_CRON_JOBS'
 increase_user_value $user '$U_CRON_JOBS'
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "added cron job $job"
 log_history "added cron job $job"

+ 2 - 6
bin/v-add-database

@@ -15,11 +15,11 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 database="$user"_"$2"
 database="$user"_"$2"
 dbuser="$user"_"$3"
 dbuser="$user"_"$3"
-password=$4
+password=$4; HIDE=4
 type=${5-mysql}
 type=${5-mysql}
 host=$6
 host=$6
 charset=${7-UTF8}
 charset=${7-UTF8}
@@ -30,10 +30,6 @@ source $VESTA/func/main.sh
 source $VESTA/func/db.sh
 source $VESTA/func/db.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #

+ 3 - 7
bin/v-add-database-host

@@ -13,11 +13,11 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 type=$1
 type=$1
 host=$2
 host=$2
 dbuser=$3
 dbuser=$3
-password=$4
+password=$4; HIDE=4
 max_db=${6-500}
 max_db=${6-500}
 charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8}
 charsets=${7-UTF8,LATIN1,WIN1250,WIN1251,WIN1252,WIN1256,WIN1258,KOI8}
 template=${8-template1}
 template=${8-template1}
@@ -27,10 +27,6 @@ source $VESTA/func/main.sh
 source $VESTA/func/db.sh
 source $VESTA/func/db.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 is_mysql_host_alive() {
 is_mysql_host_alive() {
     mycnf=$(mktemp)
     mycnf=$(mktemp)
     echo "[client]">$mycnf
     echo "[client]">$mycnf
@@ -80,7 +76,7 @@ esac
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Concatentating db host string
+# Concatenating db host string
 case $type in
 case $type in
     mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass'";
     mysql) str="HOST='$host' USER='$dbuser' PASSWORD='$dbpass'";
            str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''";
            str="$str CHARSETS='$charsets' MAX_DB='$max_db' U_SYS_USERS=''";

+ 53 - 18
bin/v-add-dns-domain

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 # info: add dns domain
 # info: add dns domain
-# options: USER DOMAIN IP [NS1] [NS2] [NS3] [NS4] [RESTART]
+# options: USER DOMAIN IP [NS1] [NS2] [NS3] [..] [NS8] [RESTART]
 #
 #
 # The function adds DNS zone with records defined in the template. If the exp
 # The function adds DNS zone with records defined in the template. If the exp
 # argument isn't stated, the expiration date value will be set to next year.
 # argument isn't stated, the expiration date value will be set to next year.
@@ -13,7 +13,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
 domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
@@ -24,7 +24,11 @@ ns1=$4
 ns2=$5
 ns2=$5
 ns3=$6
 ns3=$6
 ns4=$7
 ns4=$7
-restart=$8
+ns5=$8
+ns6=$9
+ns7=${10}
+ns8=${11}
+restart=${12}
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -36,14 +40,13 @@ source $VESTA/conf/vesta.conf
 #                    Verifications                         #
 #                    Verifications                         #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-check_args '3' "$#" 'USER DOMAIN IP [NS1] [NS2] [NS3] [NS4]'
+check_args '3' "$#" 'USER DOMAIN IP [NS1] [NS2] [NS3] [..] [NS8] [RESTART]'
 validate_format 'user' 'domain' 'ip'
 validate_format 'user' 'domain' 'ip'
 is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
 is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_domain_new 'dns'
 is_domain_new 'dns'
 is_package_full 'DNS_DOMAINS'
 is_package_full 'DNS_DOMAINS'
-
 template=$(get_user_value '$DNS_TEMPLATE')
 template=$(get_user_value '$DNS_TEMPLATE')
 is_dns_template_valid
 is_dns_template_valid
 
 
@@ -64,6 +67,23 @@ if [ ! -z "$ns4" ]; then
     ns4=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
     ns4=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
     validate_format 'ns4'
     validate_format 'ns4'
 fi
 fi
+if [ ! -z "$ns5" ]; then
+    ns5=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+    validate_format 'ns5'
+fi
+if [ ! -z "$ns6" ]; then
+    ns6=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+    validate_format 'ns6'
+fi
+if [ ! -z "$ns7" ]; then
+    ns7=$(echo ${10} | sed -e 's/\.*$//g' -e 's/^\.*//g')
+    validate_format 'ns7'
+fi
+
+if [ ! -z "$ns8" ]; then
+    ns8=$(echo ${11} | sed -e 's/\.*$//g' -e 's/^\.*//g')
+    validate_format 'ns8'
+fi
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
@@ -81,6 +101,7 @@ if [ -z $ns2 ]; then
 fi
 fi
 soa="$ns1"
 soa="$ns1"
 exp=$(date +%F -d "+ 1 year")
 exp=$(date +%F -d "+ 1 year")
+serial=$(date +'%Y%m%d01')
 ttl=14400
 ttl=14400
 
 
 # Reading template
 # Reading template
@@ -88,13 +109,25 @@ template_data=$(cat $DNSTPL/$template.tpl)
 
 
 # Deleting unused nameservers
 # Deleting unused nameservers
 if [ -z "$ns3" ]; then
 if [ -z "$ns3" ]; then
-    template_data=$(echo "$template_data" | grep -v %ns3%)
+    template_data=$(echo "$template_data" |grep -v %ns3%)
 fi
 fi
 if [ -z "$ns4" ]; then
 if [ -z "$ns4" ]; then
-    template_data=$(echo "$template_data" | grep -v %ns4%)
+    template_data=$(echo "$template_data" |grep -v %ns4%)
+fi
+if [ -z "$ns5" ]; then
+    template_data=$(echo "$template_data" |grep -v %ns5%)
+fi
+if [ -z "$ns6" ]; then
+    template_data=$(echo "$template_data" |grep -v %ns6%)
+fi
+if [ -z "$ns7" ]; then
+    template_data=$(echo "$template_data" |grep -v %ns7%)
+fi
+if [ -z "$ns8" ]; then
+    template_data=$(echo "$template_data" |grep -v %ns8%)
 fi
 fi
 
 
-# Add dns zone to the user config
+# Adding dns zone to the user config
 echo "$template_data" |\
 echo "$template_data" |\
     sed -e "s/%ip%/$ip/g" \
     sed -e "s/%ip%/$ip/g" \
         -e "s/%domain_idn%/$domain_idn/g" \
         -e "s/%domain_idn%/$domain_idn/g" \
@@ -103,6 +136,10 @@ echo "$template_data" |\
         -e "s/%ns2%/$ns2/g" \
         -e "s/%ns2%/$ns2/g" \
         -e "s/%ns3%/$ns3/g" \
         -e "s/%ns3%/$ns3/g" \
         -e "s/%ns4%/$ns4/g" \
         -e "s/%ns4%/$ns4/g" \
+        -e "s/%ns5%/$ns5/g" \
+        -e "s/%ns6%/$ns6/g" \
+        -e "s/%ns7%/$ns7/g" \
+        -e "s/%ns8%/$ns8/g" \
         -e "s/%time%/$TIME/g" \
         -e "s/%time%/$TIME/g" \
         -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
         -e "s/%date%/$DATE/g" > $USER_DATA/dns/$domain.conf
 
 
@@ -111,13 +148,13 @@ records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')"
 
 
 # Adding dns.conf record
 # Adding dns.conf record
 dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
 dns_rec="DOMAIN='$domain' IP='$ip' TPL='$template' TTL='$ttl' EXP='$exp'"
-dns_rec="$dns_rec SOA='$soa' RECORDS='$records' SUSPENDED='no' TIME='$TIME'"
-dns_rec="$dns_rec DATE='$DATE'"
+dns_rec="$dns_rec SOA='$soa' SERIAL='$serial' SRC='' RECORDS='$records'"
+dns_rec="$dns_rec SUSPENDED='no' TIME='$TIME' DATE='$DATE'"
 
 
 echo "$dns_rec" >> $USER_DATA/dns.conf
 echo "$dns_rec" >> $USER_DATA/dns.conf
 chmod 660 $USER_DATA/dns.conf
 chmod 660 $USER_DATA/dns.conf
 
 
-# Create system configs
+# Creating system configs
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
     if [ -e '/etc/named.conf' ]; then
     if [ -e '/etc/named.conf' ]; then
         dns_conf='/etc/named.conf'
         dns_conf='/etc/named.conf'
@@ -135,14 +172,14 @@ if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
     # Updating domain dns zone
     # Updating domain dns zone
     update_domain_zone
     update_domain_zone
 
 
-    # Set permissions
-    chmod 640 $conf
-    chown root:$dns_group $conf
+    # Changing permissions
+    chmod 640 $HOMEDIR/$user/conf/dns/$domain.db
+    chown root:$dns_group $HOMEDIR/$user/conf/dns/$domain.db
 fi
 fi
 
 
 # Updating dns-cluster queue
 # Updating dns-cluster queue
 if [ ! -z "$DNS_CLUSTER" ]; then
 if [ ! -z "$DNS_CLUSTER" ]; then
-    cmd="$BIN/v-add-remote-dns-domain $user $domain no"
+    cmd="$BIN/v-add-remote-dns-domain $user $domain yes"
     echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
     echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
 fi
 fi
 
 
@@ -158,9 +195,7 @@ increase_user_value "$user" '$U_DNS_RECORDS' "$records"
 # Restart named
 # Restart named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed"
 fi
 fi
 
 
 # Logging
 # Logging

+ 44 - 52
bin/v-add-dns-on-web-alias

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
-# info: add dns domain or dns record based on web domain alias restart
-# options: USER DOMAIN
+# info: add dns domain or dns record after web domain alias
+# options: USER ALIAS IP [RESTART]
 #
 #
 # The function adds dns domain or dns record based on web domain alias.
 # The function adds dns domain or dns record based on web domain alias.
 
 
@@ -9,15 +9,11 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
-domain=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
-domain_idn=$(idn -t --quiet -a "$domain")
-dom_alias=$(idn -t --quiet -u "$3" )
-dom_alias=$(echo $dom_alias | sed -e 's/\.*$//g' -e 's/^\.*//g')
-dom_alias=$(echo $dom_alias | tr '[:upper:]' '[:lower:]')
-dom_alias_idn=$(idn -t --quiet -a "$dom_alias" )
-restart="$4"
+alias=$2
+ip=$3
+restart=$4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -29,58 +25,54 @@ source $VESTA/conf/vesta.conf
 #                    Verifications                         #
 #                    Verifications                         #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-check_args '3' "$#" 'USER DOMAIN ALIAS'
-validate_format 'user' 'domain'
-is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
+check_args '3' "$#" 'USER ALIAS IP [RESTART]'
+validate_format 'user' 'alias' 'ip'
 is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
 is_system_enabled "$DNS_SYSTEM" 'DNS_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
-is_object_valid 'web' 'DOMAIN' "$domain"
-is_object_unsuspended 'web' 'DOMAIN' "$domain"
+if [ -e "$USER_DATA/dns/$alias.conf" ]; then
+    exit
+fi
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Parsing domain values
-get_domain_values 'web'
+# Logging
+log_event "$OK" "$EVENT"
+
+# Define additional vars
+sub_domain=$(echo "$alias" |awk -F '.' '{print $1}')
+top_domain=$(echo "$alias" |sed -e "s/^$sub_domain.//")
+domain_lvl=$(echo "$alias" |grep -o "\." |wc -l)
+
+# Adding second level domain
+if [ "$domain_lvl" -eq 1 ] || [ "${#top_domain}" -le '6' ]; then
+    $BIN/v-add-dns-domain \
+        $user $alias $ip '' '' '' '' '' $restart >> /dev/null
+    exit
+fi
+
+# Adding top-level domain and then its sub
+$BIN/v-add-dns-domain $user $top_domain $ip '' '' '' '' $restart >> /dev/null
 
 
-# Check if it a simple domain
-if [ $(echo -e "${dom_alias//\./\n}" | wc -l) -le 2 ]; then
-    if [ ! -e "$USER_DATA/dns/$dom_alias.conf" ]; then
-        $BIN/v-add-dns-domain \
-            $user $dom_alias $IP '' '' '' '' '' $restart > /dev/null
-    fi
+# Checking top-level domain
+if [ ! -e "$USER_DATA/dns/$top_domain.conf" ]; then
+    exit
+fi
+
+# Checking subdomain record
+if [ "$sub_domain" == '*' ]; then
+    check_record=$(grep -w "RECORD='\*'" $USER_DATA/dns/$top_domain.conf)
 else
 else
-    # Check subdomain
-    sub=$(echo "$dom_alias" | cut -f1 -d . -s)
-    dom=$(echo "$dom_alias" | sed -e "s/^$sub.//" )
-
-    # Ignore short domains like co.uk, com.au and so on
-    if [ "${#dom}" -le '6' ]; then
-        exit
-    fi
-
-    if [ ! -e "$USER_DATA/dns/$dom.conf" ]; then
-        $BIN/v-add-dns-domain \
-            $user $dom $IP '' '' '' '' $restart > /dev/null
-
-        if [ $? -eq 0 ]; then
-            $BIN/v-add-dns-record \
-                $user $dom "$sub" A $IP '' '' $restart
-        fi
-    else
-        if [ "$sub" == '*' ]; then
-            rec=$(grep -w "RECORD='\*'" $USER_DATA/dns/$dom.conf)
-        else
-            rec=$(grep -w "RECORD='$sub'" $USER_DATA/dns/$dom.conf)
-        fi
-        if [ -z "$rec" ]; then
-            $BIN/v-add-dns-record \
-                 $user $dom "$sub" A $IP '' '' $restart > /dev/null
-        fi
-    fi
+    check_record=$(grep -w "RECORD='$sub_domain'" $USER_DATA/dns/$top_domain.conf)
+fi
+
+# Adding subdomain record
+if [ -z "$check_record" ]; then
+    $BIN/v-add-dns-record \
+        $user $top_domain "$sub_domain" A $ip '' '' $restart >> /dev/null
 fi
 fi
 
 
 
 
@@ -88,6 +80,6 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# No Logging
+# No logging
 
 
 exit
 exit

+ 4 - 5
bin/v-add-dns-record

@@ -12,7 +12,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
@@ -82,6 +82,7 @@ sort_dns_records
 
 
 # Updating zone
 # Updating zone
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
     update_domain_zone
     update_domain_zone
 fi
 fi
 
 
@@ -100,7 +101,7 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Upddate counters
+# Update counters
 records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
 records="$(wc -l $USER_DATA/dns/$domain.conf | cut -f1 -d ' ')"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 increase_user_value "$user" '$U_DNS_RECORDS'
 increase_user_value "$user" '$U_DNS_RECORDS'
@@ -108,9 +109,7 @@ increase_user_value "$user" '$U_DNS_RECORDS'
 # Restart named
 # Restart named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? $E_RESTART 'dns failed to restart'
 fi
 fi
 
 
 # Logging
 # Logging

+ 18 - 21
bin/v-add-domain

@@ -47,37 +47,34 @@ if [ -z "$ip" ]; then
     fi
     fi
 fi
 fi
 
 
-# Web domain
+# Working on web domain
 if [ ! -z "$WEB_SYSTEM" ]; then
 if [ ! -z "$WEB_SYSTEM" ]; then
     $BIN/v-add-web-domain $user $domain $ip 'no'
     $BIN/v-add-web-domain $user $domain $ip 'no'
-    return_code=$?
+    check_result $? "can't add web domain" >/dev/null
 fi
 fi
 
 
-# Proxy support
-if [ ! -z "$PROXY_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
-    extentions="jpg,jpeg,gif,png,ico,svg,css,zip,tgz,gz,rar,bz2,doc,xls"
-    extentions="$extentions,exe,pdf,ppt,txt,odt,ods,odp,odf,tar,wav"
-    extentions="$extentions,bmp,rtf,js,mp3,avi,mpeg,flv,html,htm"
-    $BIN/v-add-web-domain-proxy $user $domain 'default' "$extentions" 'no'
+# Working on DNS domain
+if [ ! -z "$DNS_SYSTEM" ]; then
+    $BIN/v-add-dns-domain $user $domain $ip "" "" "" "" "" 'no'
+    check_result $? "can't add dns domain" >/dev/null
 fi
 fi
 
 
-# DNS domain
-if [ ! -z "$DNS_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
-    $BIN/v-add-dns-domain $user $domain $ip 'no'
-    return_code=$?
-fi
-
-# Mail domain
-if [ ! -z "$MAIL_SYSTEM" ] && [ "$return_code" -eq 0 ]; then
+# Working on mail domain
+if [ ! -z "$MAIL_SYSTEM" ]; then
     $BIN/v-add-mail-domain $user $domain
     $BIN/v-add-mail-domain $user $domain
-    return_code=$?
+    check_result $? "can't add mail domain" >/dev/null
 fi
 fi
 
 
-# Restart services
-if [ "$restart" != 'no' ] && [ "$return_code" -eq 0 ]; then
+# Restarting services
+if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    $BIN/v-restart-proxy
+    check_result $? "can't restart web" > /dev/null
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "can't restart proxy" > /dev/null
+    fi
     $BIN/v-restart-dns
     $BIN/v-restart-dns
+    check_result $? "can't restart dns" > /dev/null
 fi
 fi
 
 
 
 
@@ -85,4 +82,4 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-exit $return_code
+exit

+ 1 - 1
bin/v-add-firewall-ban

@@ -12,7 +12,7 @@
 # Importing system variables
 # Importing system variables
 source /etc/profile
 source /etc/profile
 
 
-# Argument defenition
+# Argument definition
 ip=$1
 ip=$1
 chain=$(echo $2|tr '[:lower:]' '[:upper:]')
 chain=$(echo $2|tr '[:lower:]' '[:upper:]')
 
 

+ 1 - 1
bin/v-add-firewall-chain

@@ -12,7 +12,7 @@
 # Importing system variables
 # Importing system variables
 source /etc/profile
 source /etc/profile
 
 
-# Argument defenition
+# Argument definition
 chain=$(echo $1 | tr '[:lower:]' '[:upper:]')
 chain=$(echo $1 | tr '[:lower:]' '[:upper:]')
 port=$2
 port=$2
 protocol=${4-TCP}
 protocol=${4-TCP}

+ 1 - 1
bin/v-add-firewall-rule

@@ -12,7 +12,7 @@
 # Importing system variables
 # Importing system variables
 source /etc/profile
 source /etc/profile
 
 
-# Argument defenition
+# Argument definition
 action=$(echo $1|tr '[:lower:]' '[:upper:]')
 action=$(echo $1|tr '[:lower:]' '[:upper:]')
 ip=$2
 ip=$2
 port_ext=$3
 port_ext=$3

+ 56 - 0
bin/v-add-fs-archive

@@ -0,0 +1,56 @@
+#!/bin/bash
+# info: archive directory
+# options: USER ARCHIVE SOURCE
+#
+# The function creates tar archive
+
+user=$1
+archive=$2
+src=$3
+
+# Checking arguments
+if [ -z "$src" ]; then
+    echo "Usage: USER ARCHIVE SOURCE"
+    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 user homedir
+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"
+    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
+
+# Parsing current directory
+d=$(dirname "$src")
+
+# Removing leading file path
+f=$(echo "$src" |sed -e "s|$d/||")
+
+# 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
+fi
+
+exit

+ 44 - 0
bin/v-add-fs-directory

@@ -0,0 +1,44 @@
+#!/bin/bash
+# info: add directory
+# options: USER DIRECTORY
+#
+# The function creates new directory on the file system
+
+user=$1
+dst_dir=$2
+
+# Checking arguments
+if [ -z "$dst_dir" ]; then
+    echo "Usage: USER DIRECTORY"
+    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 user homedir
+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 destination path
+rpath=$(readlink -f "$dst_dir")
+if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
+    echo "Error: invalid destination path $dst_dir"
+    exit 2
+fi
+
+# Adding directory
+sudo -u $user mkdir -p "$dst_dir" >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+    echo "Error: directory $dst_dir was not created"
+    exit 3
+fi
+
+# Extiging
+exit

+ 44 - 0
bin/v-add-fs-file

@@ -0,0 +1,44 @@
+#!/bin/bash
+# info: add file
+# options: USER FILE
+#
+# The function creates new files on file system
+
+user=$1
+dst_file=$2
+
+# Checking arguments
+if [ -z "$dst_file" ]; then
+    echo "Usage: USER FILE"
+    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 user homedir
+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 destination path
+rpath=$(readlink -f "$dst_file")
+if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
+    echo "Error: invalid destination path $dst_dir"
+    exit 2
+fi
+
+# Creating file
+sudo -u $user touch "$dst_file" >/dev/null 2>&1
+if [ $? -ne 0 ]; then 
+    echo "Error: file $dst_file was not created"
+    exit 3
+fi
+
+# Exiting
+exit

+ 2 - 6
bin/v-add-mail-account

@@ -9,13 +9,13 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
 account=$(echo $3 | tr '[:upper:]' '[:lower:]')
 account=$(echo $3 | tr '[:upper:]' '[:lower:]')
-password=$4
+password=$4; HIDE=4
 quota=${5-unlimited}
 quota=${5-unlimited}
 
 
 # Includes
 # Includes
@@ -23,10 +23,6 @@ source $VESTA/func/main.sh
 source $VESTA/func/domain.sh
 source $VESTA/func/domain.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #

+ 1 - 1
bin/v-add-mail-account-alias

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

+ 1 - 1
bin/v-add-mail-account-autoreply

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

+ 1 - 1
bin/v-add-mail-account-forward

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

+ 1 - 1
bin/v-add-mail-account-fwd-only

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

+ 1 - 1
bin/v-add-mail-domain

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
 domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')

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

@@ -2,14 +2,14 @@
 # info: add mail domain antispam support
 # info: add mail domain antispam support
 # options: USER DOMAIN
 # options: USER DOMAIN
 #
 #
-# The function enables spamassasin for incomming emails.
+# The function enables spamassasin for incoming emails.
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

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

@@ -2,14 +2,14 @@
 # info: add mail domain antivirus support
 # info: add mail domain antivirus support
 # options: USER DOMAIN
 # options: USER DOMAIN
 #
 #
-# The function enables clamav scan for incomming emails.
+# The function enables clamav scan for incoming emails.
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

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

@@ -2,14 +2,14 @@
 # info: add mail domain catchall account
 # info: add mail domain catchall account
 # options: USER DOMAIN EMAIL
 # options: USER DOMAIN EMAIL
 #
 #
-# The function enables catchall account for incomming emails. 
+# The function enables catchall account for incoming emails.
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

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

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

+ 34 - 75
bin/v-add-remote-dns-domain

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$2
 domain=$2
 flush=$3
 flush=$3
@@ -27,101 +27,64 @@ source $VESTA/conf/vesta.conf
 check_args '2' "$#" 'USER DOMAIN [FLUSH]'
 check_args '2' "$#" 'USER DOMAIN [FLUSH]'
 validate_format 'user' 'domain'
 validate_format 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
-
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    echo "Error: dns-cluster.conf doesn't exist"
-    log_event "$E_NOTEXIST $EVENT"
-    exit $E_NOTEXIST
+    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
 fi
 fi
-
-number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
-if [ "$number_of_proc" -gt 2 ]; then
-    echo "Error: another sync process already exists"
-    log_event "$E_EXISTS $EVENT"
-    exit $E_EXISTS
+if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
+    check_result $E_EXISTS "another sync process already running"
 fi
 fi
+remote_dns_health_check
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Check domain existance
-check_local_domain=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf 2>/dev/null)
-if [ -z "$check_local_domain" ]; then
+# Parsing domain record
+str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf 2>/dev/null)
+if [ -z "$str" ]; then
     pipe="$VESTA/data/queue/dns-cluster.pipe"
     pipe="$VESTA/data/queue/dns-cluster.pipe"
-    str=$(grep -n "$SCRIPT $1 $2$" $pipe | cut -f1 -d: | head -n1)
-    if [ ! -z "$str" ]; then
-        sed -i "$str d"  $pipe
+    queue_str=$(grep -n "$SCRIPT $1 $2 " $pipe |cut -f1 -d: |head -n1)
+    if [ ! -z "$queue_str" ]; then
+        sed -i "$queue_str d"  $pipe
     fi
     fi
     exit
     exit
 fi
 fi
 
 
-old_ifs="$IFS"
 IFS=$'\n'
 IFS=$'\n'
+for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
 
 
-# Check remote dns nodes
-remote_dns_health_check
+    # Parsing remote dns host parameters
+    eval $cluster
 
 
-search_str=$(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf)
-for cluster_str in $search_str; do
+    # Parsing domain parameters
+    eval $str
 
 
-    # Get host values
-    eval $cluster_str
+    # Syncing domain data
+    cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME $flush 'no'
+    check_result $? "$HOST connection failed" $E_CONNECT
 
 
-    # Check connection type
-    if [ -z "TYPE" ]; then
-        TYPE='api'
-    fi
+    # Syncing domain records
+    tmp_file="/tmp/vst-sync.$DOMAIN"
+    cluster_file $USER_DATA/dns/$DOMAIN.conf $tmp_file
+    check_result $? "$HOST connection failed" $E_CONNECT
 
 
-    # Check recipient dns user
-    if [ -z "$DNS_USER" ]; then
-        DNS_USER='dns-cluster'
-    fi
-
-    # Switch on connection type
-    case $TYPE in
-        ssh) send_cmd="send_ssh_cmd" ;;
-        *)  send_cmd="send_api_cmd" ;;
-    esac
+    # Inserting synced records
+    cluster_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp_file 'no'
+    check_result $? "$HOST connection failed" $E_CONNECT
 
 
-    # Check dns exceptions
-    if [ -z "$DNS_CLUSTER_IGNORE" ]; then
-        DNS_CLUSTER_IGNORE='dns-cluster'
-    fi
+    # Rebuilding dns zone
+    cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
+    check_result $? "$HOST connection failed" $E_CONNECT
+done
 
 
-    # Check flush parameters
 
 
-    # Sync domain
-    str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
-    eval $str
 
 
-    $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME "$flush" 'no'
-    if [ $? -eq 0 ]; then
-        # Sync records
-        if [ "$TYPE" = 'ssh' ]; then
-            tmp=$(mktemp -u)
-            scp_cmd $USER_DATA/dns/$DOMAIN.conf $tmp
-            $send_cmd v-insert-dns-records $DNS_USER $DOMAIN $tmp 'no'
-        else
-            for str in $(cat $USER_DATA/dns/$DOMAIN.conf); do
-                str=$(echo "$str" | sed 's/"/\\"/g')
-                $send_cmd v-insert-dns-record $DNS_USER $DOMAIN "$str"
-            done
-        fi
-
-        # Rebuild dns zone
-        $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
-        if [ $? -ne 0 ]; then
-            echo "Error: $TYPE connection to $HOST failed"
-            log_event "$E_CONNECT $EVENT"
-            exit $E_CONNECT
-        fi
-    fi
-
-done
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
 
 
-# Update pipe
+# Updating pipe
 rm -f $tmpfile
 rm -f $tmpfile
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 str=$(grep -n "$SCRIPT $1 $2 " $pipe | cut -f1 -d: | head -n1)
 str=$(grep -n "$SCRIPT $1 $2 " $pipe | cut -f1 -d: | head -n1)
@@ -129,8 +92,4 @@ if [ ! -z "$str" ]; then
     sed -i "$str d"  $pipe
     sed -i "$str d"  $pipe
 fi
 fi
 
 
-#----------------------------------------------------------#
-#                       Vesta                              #
-#----------------------------------------------------------#
-
 exit
 exit

+ 18 - 27
bin/v-add-remote-dns-host

@@ -9,12 +9,17 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 host=$1
 host=$1
+HOST=$host
 port=$2
 port=$2
+PORT=$port
 user=$3
 user=$3
-password=$4
+USER=$user
+password=$4; HIDE=4
+PASSWORD=$password
 type=${5-api}
 type=${5-api}
+TYPE="$type"
 dns_user=${6-dns-cluster}
 dns_user=${6-dns-cluster}
 DNS_USER=$dns_user
 DNS_USER=$dns_user
 
 
@@ -23,10 +28,6 @@ source $VESTA/func/main.sh
 source $VESTA/func/remote.sh
 source $VESTA/func/remote.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding passwords
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #
@@ -61,36 +62,26 @@ else
     sed -i "s/DNS_CLUSTER=.*/DNS_CLUSTER='yes'/g" $VESTA/conf/vesta.conf
     sed -i "s/DNS_CLUSTER=.*/DNS_CLUSTER='yes'/g" $VESTA/conf/vesta.conf
 fi
 fi
 
 
-# Enabling restart queue
-HOST=$host
-PORT=$port
-USER=$user
-PASSWORD=$password
-case $type in
-    ssh) send_cmd="send_ssh_cmd" ;;
-    *)  send_cmd="send_api_cmd" ;;
-esac
-$send_cmd v-add-cron-restart-job
+# Enabling remote dns-cluster queue
+cluster_cmd v-add-cron-restart-job
+check_result $? "$HOST connection failed" $E_CONNECT
 
 
-# Sync current zones
+# Syncing all domains
 $BIN/v-sync-dns-cluster $host
 $BIN/v-sync-dns-cluster $host
-return_code=$?
-if [ "$return_code" -ne 0 ]; then
-    exit $return_code
-fi
+check_result $? "$HOST sync failed" $E_CONNECT
 
 
-# Add dns-cluster cron job
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Adding local  dns-cluster cron job
 cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster"
 cmd="sudo /usr/local/vesta/bin/v-update-sys-queue dns-cluster"
 check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null)
 check_cron=$(grep "$cmd" $VESTA/data/users/admin/cron.conf 2> /dev/null)
 if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then
 if [ -z "$check_cron" ] && [ ! -z "$CRON_SYSTEM" ]; then
     $BIN/v-add-cron-job admin '*/5' '*' '*' '*' '*' "$cmd"
     $BIN/v-add-cron-job admin '*/5' '*' '*' '*' '*' "$cmd"
 fi
 fi
 
 
-
-#----------------------------------------------------------#
-#                       Vesta                              #
-#----------------------------------------------------------#
-
 # Logging
 # Logging
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 

+ 35 - 56
bin/v-add-remote-dns-record

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$2
 domain=$2
 id=$3
 id=$3
@@ -29,83 +29,62 @@ validate_format 'user' 'domain' 'id'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'dns' 'DOMAIN' "$domain"
 is_object_valid 'dns' 'DOMAIN' "$domain"
-is_object_valid "dns/$domain" 'ID' "$id"
-
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    echo "Error: dns-cluster.conf doesn't exist"
-    log_event "$E_NOTEXIST $EVENT"
-    exit $E_NOTEXIST
+    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
 fi
 fi
-
-number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
-if [ "$number_of_proc" -gt 2 ]; then
-    echo "Error: another sync process already exists"
-    log_event "$E_EXISTS $EVENT"
-    exit $E_EXISTS
+if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
+    check_result $E_EXISTS "another sync process already running"
 fi
 fi
+remote_dns_health_check
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-old_ifs="$IFS"
-IFS=$'\n'
+# Parsing record
+str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
+if [ -z "$str" ]; then
+    pipe="$VESTA/data/queue/dns-cluster.pipe"
+    queue_str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
+    if [ ! -z "$queue_str" ]; then
+        sed -i "$queue_str d"  $pipe
+    fi
+    exit
+fi
 
 
-# Check remote dns nodes
-remote_dns_health_check
+IFS=$'\n'
+for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
 
 
-for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
-    # Get host values
-    eval $cluster_str
+    # Parsing remote host parameters
+    eval $cluster
 
 
-    # Check connection type
-    if [ -z "TYPE" ]; then
-        TYPE='api'
-    fi
+    # Syncing serial
+    str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
+    cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
+    check_result $? "$HOST connection failed (soa sync)" $E_CONNECT
 
 
-    # Switch on connection type
-    case $TYPE in
-        ssh) send_cmd="send_ssh_cmd" ;;
-        *)  send_cmd="send_api_cmd" ;;
-    esac
+    # Syncing record
+    str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf | sed 's/"/\\"/g')
+    cluster_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no'
+    check_result $? "$HOST connection failed (record sync)" $E_CONNECT
 
 
-    # Check recipient dns user
-    if [ -z "$DNS_USER" ]; then
-        DNS_USER='dns-cluster'
-    fi
+    # Rebuilding dns zone
+    cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
+    check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
 
 
-    # Check dns exceptions
-    if [ -z "$DNS_CLUSTER_IGNORE" ]; then
-        DNS_CLUSTER_IGNORE='dns-cluster'
-    fi
+done
 
 
-    # Sync record
-    str=$(grep "ID='$id'" $USER_DATA/dns/$domain.conf)
-    str=$(echo "$str" | sed 's/"/\\"/g')
-    $send_cmd v-insert-dns-record $DNS_USER $domain "$str" 'no'
-    if [ $? -eq 0 ]; then
-        # Rebuild dns zone
-        $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
-        if [ $? -ne 0 ]; then
-            echo "Error: $TYPE connection to $HOST failed (rebuild)"
-            log_event "$E_CONNECT $EVENT"
-            exit $E_CONNECT
-        fi
-    fi
 
 
-done
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
 
 
-# Update pipe
+# Updating pipe
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
 str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
 if [ ! -z "$str" ]; then
 if [ ! -z "$str" ]; then
     sed -i "$str d"  $pipe
     sed -i "$str d"  $pipe
 fi
 fi
 
 
-
-#----------------------------------------------------------#
-#                       Vesta                              #
-#----------------------------------------------------------#
-
 exit
 exit

+ 57 - 0
bin/v-add-sys-firewall

@@ -0,0 +1,57 @@
+#!/bin/bash
+# info: add system firewall
+# options: NONE
+#
+# The script enables firewall
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+if [ "$FIREWALL_SYSTEM" = 'iptables' ]; then
+    exit
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding firewall directory
+mkdir -p $VESTA/data/firewall/
+
+# Adding default ruleset
+if [ ! -e "$VESTA/data/firewall/rules.conf" ]; then
+    cp $VESTA/install/rhel/7/* $VESTA/data/firewall/
+fi
+
+# Updating FIREWAL_SYSTEM value
+if [ -z "$(grep FIREWALL_SYSTEM $VESTA/conf/vesta.conf)" ]; then
+    echo "FIREWALL_SYSTEM='iptables'" >> $VESTA/conf/vesta.conf
+else
+    sed -i "s/FIREWALL_SYSTEM.*/FIREWALL_SYSTEM='iptables'/g" \
+        $VESTA/conf/vesta.conf
+fi
+
+# Updating firewall rules
+$BIN/v-update-firewall
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$EVENT"
+
+exit

+ 4 - 8
bin/v-add-sys-ip

@@ -5,7 +5,7 @@
 # The function adds ip address into a system. It also creates rc scripts. You
 # The function adds ip address into a system. It also creates rc scripts. You
 # can specify ip name which will be used as root domain for temporary aliases.
 # can specify ip name which will be used as root domain for temporary aliases.
 # For example, if you set a1.myhosting.com as name, each new domain created on
 # For example, if you set a1.myhosting.com as name, each new domain created on
-# this  ip will automaticaly receive alias $domain.a1.myhosting.com. Of course
+# this  ip will automatically receive alias $domain.a1.myhosting.com. Of course
 # you must have wildcard record *.a1.myhosting.com pointed to ip. This feature 
 # you must have wildcard record *.a1.myhosting.com pointed to ip. This feature 
 # is very handy when customer wants to test domain before dns migration.
 # is very handy when customer wants to test domain before dns migration.
 
 
@@ -14,7 +14,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 ip=${1// /}
 ip=${1// /}
 netmask=$2
 netmask=$2
 interface="${3-eth0}"
 interface="${3-eth0}"
@@ -161,16 +161,12 @@ fi
 
 
 # Restarting web server
 # Restarting web server
 $BIN/v-restart-web
 $BIN/v-restart-web
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Web restart failed" >/dev/null
 
 
 # Restarting proxy server
 # Restarting proxy server
 if [ ! -z "$PROXY_SYSTEM" ]; then
 if [ ! -z "$PROXY_SYSTEM" ]; then
     $BIN/v-restart-proxy
     $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Proxy restart failed" >/dev/null
 fi
 fi
 
 
 # Restarting firewall
 # Restarting firewall

+ 30 - 34
bin/v-add-sys-quota

@@ -1,12 +1,12 @@
 #!/bin/bash
 #!/bin/bash
 # info: add system quota
 # info: add system quota
-# opions: NONE
+# options: NONE
 #
 #
-# The script enables filesystem quota on /home patition
+# The script enables filesystem quota on /home partition
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
-#                    Variable&Function                     #
+#                 Variable & Function                      #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Includes
 # Includes
@@ -19,21 +19,15 @@ source $VESTA/conf/vesta.conf
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Checking quota package
 # Checking quota package
-if [ ! -e "/usr/sbin/setquota" ]; then
+quota=$(which --skip-alias --skip-functions quota 2>/dev/null)
+if [ $? -ne 0 ]; then
     if [ -e "/etc/redhat-release" ]; then
     if [ -e "/etc/redhat-release" ]; then
         yum -y install quota >/dev/null 2>&1
         yum -y install quota >/dev/null 2>&1
-        result=$?
+        check_result $? "quota package installation failed" $E_UPDATE
     else
     else
         export DEBIAN_FRONTEND=noninteractive
         export DEBIAN_FRONTEND=noninteractive
         apt-get -y install quota >/dev/null 2>&1
         apt-get -y install quota >/dev/null 2>&1
-        result=$?
-    fi
-
-    # Checking installation status
-    if [ "$result" -ne 0 ]; then
-        echo "Error: quota package wasn't successfully installed"
-        log_event "$E_UPDATE" "$EVENT"
-        exit $E_UPDATE
+        check_result $? "quota package installation failed" $E_UPDATE
     fi
     fi
 fi
 fi
 
 
@@ -42,38 +36,40 @@ fi
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Adding usrquota option on /home partition
-mnt=$(df -P /home |awk '{print $6}' |tail -n1)
-lnr=$(cat -n /etc/fstab |awk '{print $1,$3}' |grep "$mnt$" |cut -f 1 -d ' ')
-options=$(sed -n ${lnr}p /etc/fstab |awk '{print $4}')
-if [ -z "$(echo $options |grep usrquota)" ]; then
-    sed -i "$lnr s/$options/$options,usrquota/" /etc/fstab
+# Adding group and user quota on /home partition
+mnt=$(df -P /home | awk '{print $6}' | tail -n1)
+lnr=$(cat -n /etc/fstab | awk '{print $1,$3}' | grep "$mnt$" | cut -f 1 -d ' ')
+opt=$(sed -n ${lnr}p /etc/fstab | awk '{print $4}')
+fnd='usrquota\|grpquota\|usrjquota=aquota.user\|grpjquota=aquota.group\|jqfmt=vfsv0'
+if [ $(echo $opt | tr ',' '\n' | grep -x $fnd | wc -l) -ne 5 ]; then
+    old=$(echo $(echo $opt | tr ',' '\n' | grep -v 'usrquota\|grpquota\|usrjquota=\|grpjquota=\|jqfmt=') | tr ' ' ',')
+    new='usrquota,grpquota,usrjquota=aquota.user,grpjquota=aquota.group,jqfmt=vfsv0'
+    sed -i "$lnr s/$opt/$old,$new/" /etc/fstab
     mount -o remount $mnt
     mount -o remount $mnt
 fi
 fi
 
 
-# Adding aquota.user file
-if [ ! -e "$mnt/aquota.user" ]; then
-    quotacheck -cu $mnt >/dev/null 2>&1
+# Adding v2 group and user quota index
+if [ ! -e "$mnt/aquota.user" ] || [ ! -e "$mnt/aquota.group" ]; then
+    quotaoff $mnt
+    quotacheck -cug $mnt >/dev/null 2>&1
+    quotacheck -aug >/dev/null 2>&1
 fi
 fi
 
 
-# Building fs quota index
-quotacheck -um $mnt
+# Adding quotacheck on reboot
+touch /forcequotacheck
 
 
-# Adding weekly cron job
-echo "quotacheck -um $mnt" > /etc/cron.daily/quotacheck
+# Adding cron job
+echo '#!/bin/bash' > /etc/cron.daily/quotacheck
+echo 'touch /forcequotacheck' >> /etc/cron.daily/quotacheck
 chmod a+x /etc/cron.daily/quotacheck
 chmod a+x /etc/cron.daily/quotacheck
 
 
-# Enabling fs quota
-if [ ! -z "$(quotaon -pa|grep " $mnt "|grep user|grep 'off')" ]; then
+# Enabling group and user quota
+if [ ! -z "$(quotaon -pa | grep " $mnt " | grep 'user\|group' | grep 'is off')" ]; then
     quotaon $mnt
     quotaon $mnt
-    if [ $? -ne 0 ]; then
-        echo "Error: quota can't be enabled on $mnt partition"
-        log_event "$E_DISK" "$EVENT"
-        exit $E_DISK
-    fi
+    check_result $? "quota can't be enabled in $mnt" $E_DISK
 fi
 fi
 
 
-# Updating DISK_QUOTA value
+# Updating vesta.conf value
 if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then
 if [ -z "$(grep DISK_QUOTA $VESTA/conf/vesta.conf)" ]; then
     echo "DISK_QUOTA='yes'" >> $VESTA/conf/vesta.conf
     echo "DISK_QUOTA='yes'" >> $VESTA/conf/vesta.conf
 else
 else

+ 106 - 0
bin/v-add-sys-sftp-jail

@@ -0,0 +1,106 @@
+#!/bin/bash
+# info: add system sftp jail
+# options: NONE
+#
+# The script enables sftp jailed environment
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Importing system environment  as we run this script
+# mostly by cron which do not read it by itself
+source /etc/profile
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+if [ -z "$SFTPJAIL_KEY" ]; then
+    exit
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Checking sshd directives
+config='/etc/ssh/sshd_config'
+sftp_n=$(grep -n "Subsystem.*sftp" $config |grep -v internal |grep -v ":#")
+sftp_i=$(grep -n "Subsystem.*sftp" $config |grep internal |grep -v ":#")
+
+# Disabling normal sftp
+if [ ! -z "$sftp_n" ]; then
+    fline=$(echo $sftp_n |cut -f 1 -d :)
+    sed -i "${fline}s/Subsystem.*sftp/#Subsystem sftp/" $config
+    restart='yes'
+fi
+
+# Enabling jailed sftp
+if [ -z "$sftp_i" ]; then
+    echo "Subsystem sftp internal-sftp" >> $config
+    echo "Match Group sftp-only" >> $config
+    echo "ChrootDirectory /chroot/%u" >> $config
+    echo "    AllowTCPForwarding no" >> $config
+    echo "    X11Forwarding no" >> $config
+    echo "    ForceCommand internal-sftp" >> $config
+    restart='yes'
+fi
+
+# Validating opensshd config
+if [ "$restart" = 'yes' ]; then
+    subj="OpenSSH restart failed"
+    email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
+    send_mail="$VESTA/web/inc/mail-wrapper.php"
+    /usr/sbin/sshd -t >/dev/null 2>&1
+    if [ "$?" -ne 0 ]; then
+        mail_text="OpenSSH can not be restarted. Please check config:
+            \n\n$(/usr/sbin/sshd -t)"
+        echo -e "$mail_text" | $send_mail -s "$subj" $email
+    else
+        service ssh restart >/dev/null 2>&1
+        service sshd restart >/dev/null 2>&1
+    fi
+fi
+
+# Adding sftp group
+groupadd sftp-only 2>/dev/null
+
+# Checking users
+shells="rssh|nologin"
+for user in $(grep "$HOMEDIR" /etc/passwd |egrep "$shells" |cut -f 1 -d:); do
+    $BIN/v-add-user-sftp-jail $user
+done
+
+# Adding v-add-sys-sftp-jail to startup
+if [ -e "/etc/rc.local" ]; then
+    check_sftp=$(grep $0 /etc/rc.local)
+    check_exit=$(grep ^exit /etc/rc.local)
+    if [ -z "$check_sftp" ]; then
+        if [ -z "$check_exit" ]; then
+            echo "$BIN/v-add-sys-sftp-jail" >> /etc/rc.local
+        else
+            sed -i "s|^exit|$BIN/v-add-sys-sftp-jail\nexit|" /etc/rc.local
+        fi
+    fi
+    chmod +x /etc/rc.local
+else
+    echo "$BIN/v-add-sys-sftp-jail" > /etc/rc.local
+    chmod +x /etc/rc.local
+fi
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_event "$OK" "$EVENT"
+
+exit

+ 39 - 54
bin/v-add-user

@@ -9,9 +9,9 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
-password=$2
+password=$2; HIDE=2
 email=$3
 email=$3
 package=${4-default}
 package=${4-default}
 fname=$5
 fname=$5
@@ -21,10 +21,6 @@ lname=$6
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A2='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 is_user_free() {
 is_user_free() {
     check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
     check_sysuser=$(cut -f 1 -d : /etc/passwd | grep -w "$user" )
     if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
     if [ ! -z "$check_sysuser" ] || [ -e "$USER_DATA" ]; then
@@ -62,11 +58,7 @@ shell=$(grep -w "$shell_conf" /etc/shells |head -n1)
 
 
 # Adding user
 # Adding user
 /usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
 /usr/sbin/useradd "$user" -s "$shell" -c "$email" -m -d "$HOMEDIR/$user"
-if [ $? -ne 0 ]; then
-    echo "Error: user creation failed"
-    log_event "$E_INVALID" "$EVENT"
-    exit $E_INVALID
-fi
+check_result $? "user creation failed" $E_INVALID
 
 
 # Adding password
 # Adding password
 echo "$user:$password" | /usr/sbin/chpasswd
 echo "$user:$password" | /usr/sbin/chpasswd
@@ -75,21 +67,15 @@ echo "$user:$password" | /usr/sbin/chpasswd
 mkdir $HOMEDIR/$user/conf
 mkdir $HOMEDIR/$user/conf
 
 
 if [ ! -z "$WEB_SYSTEM" ]; then
 if [ ! -z "$WEB_SYSTEM" ]; then
-    mkdir $HOMEDIR/$user/conf/web
-    mkdir $HOMEDIR/$user/web
-    mkdir $HOMEDIR/$user/tmp
-    chmod 751 $HOMEDIR/$user/conf/web
-    chmod 751 $HOMEDIR/$user/web
+    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 771 $HOMEDIR/$user/tmp
-    chown $user:$user $HOMEDIR/$user/web
-    chown $user:$user $HOMEDIR/$user/tmp
+    chown $user:$user $HOMEDIR/$user/web $HOMEDIR/$user/tmp
 fi
 fi
 
 
 if [ ! -z "$MAIL_SYSTEM" ]; then
 if [ ! -z "$MAIL_SYSTEM" ]; then
-    mkdir $HOMEDIR/$user/conf/mail
-    mkdir $HOMEDIR/$user/mail
-    chmod 751 $HOMEDIR/$user/mail
-    chmod 751 $HOMEDIR/$user/conf/mail
+    mkdir $HOMEDIR/$user/conf/mail $HOMEDIR/$user/mail
+    chmod 751 $HOMEDIR/$user/mail $HOMEDIR/$user/conf/mail
 fi
 fi
 
 
 if [ ! -z "$DNS_SYSTEM" ]; then
 if [ ! -z "$DNS_SYSTEM" ]; then
@@ -107,54 +93,47 @@ chattr +i $HOMEDIR/$user/conf
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Adding user dir
 # Adding user dir
-mkdir $USER_DATA
-chmod 770 $USER_DATA
+mkdir -p  $USER_DATA/ssl $USER_DATA/dns $USER_DATA/mail
 
 
 # Creating configuration files and pipes
 # Creating configuration files and pipes
-touch $USER_DATA/backup.conf
-chmod 660 $USER_DATA/backup.conf
-touch $USER_DATA/history.log
-chmod 660 $USER_DATA/history.log
-touch $USER_DATA/stats.log
-chmod 660 $USER_DATA/stats.log
-
+touch $USER_DATA/backup.conf \
+    $USER_DATA/history.log \
+    $USER_DATA/stats.log \
+    $USER_DATA/web.conf \
+    $USER_DATA/dns.conf \
+    $USER_DATA/mail.conf \
+    $USER_DATA/db.conf \
+    $USER_DATA/cron.conf
+
+chmod 770 $USER_DATA \
+    $USER_DATA/ssl \
+    $USER_DATA/dns \
+    $USER_DATA/mail
+
+chmod 660 $USER_DATA/backup.conf \
+    $USER_DATA/history.log \
+    $USER_DATA/stats.log \
+    $USER_DATA/web.conf \
+    $USER_DATA/dns.conf \
+    $USER_DATA/mail.conf \
+    $USER_DATA/db.conf \
+    $USER_DATA/cron.conf
+
+# Updating queue pipes
 echo "$BIN/v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe
 echo "$BIN/v-update-user-disk $user" >> $VESTA/data/queue/disk.pipe
-
 if [ ! -z "$WEB_SYSTEM" ]; then
 if [ ! -z "$WEB_SYSTEM" ]; then
-    mkdir $USER_DATA/ssl
-    chmod 770 $USER_DATA/ssl
-    touch $USER_DATA/web.conf
-    chmod 660 $USER_DATA/web.conf
     echo "$BIN/v-update-web-domains-traff $user" \
     echo "$BIN/v-update-web-domains-traff $user" \
         >> $VESTA/data/queue/traffic.pipe
         >> $VESTA/data/queue/traffic.pipe
     echo "$BIN/v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe
     echo "$BIN/v-update-web-domains-disk $user" >> $VESTA/data/queue/disk.pipe
 fi
 fi
-
-if [ ! -z "$DNS_SYSTEM" ]; then
-    mkdir $USER_DATA/dns
-    chmod 770 $USER_DATA/dns
-    touch $USER_DATA/dns.conf
-    chmod 660 $USER_DATA/dns.conf
-fi
-
 if [ ! -z "$MAIL_SYSTEM" ]; then
 if [ ! -z "$MAIL_SYSTEM" ]; then
-    mkdir $USER_DATA/mail
-    chmod 770 $USER_DATA/mail
-    touch $USER_DATA/mail.conf
-    chmod 660 $USER_DATA/mail.conf
     echo "$BIN/v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe
     echo "$BIN/v-update-mail-domains-disk $user" >> $VESTA/data/queue/disk.pipe
 fi
 fi
 
 
 if [ ! -z "$DB_SYSTEM" ]; then
 if [ ! -z "$DB_SYSTEM" ]; then
-    touch $USER_DATA/db.conf
-    chmod 660 $USER_DATA/db.conf
     echo "$BIN/v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe
     echo "$BIN/v-update-databases-disk $user" >> $VESTA/data/queue/disk.pipe
 fi
 fi
 
 
-if [ ! -z "$CRON_SYSTEM" ]; then
-    touch $USER_DATA/cron.conf
-    chmod 660 $USER_DATA/cron.conf
-fi
 
 
 # Filling user config
 # Filling user config
 if [ "$user" != 'admin' ]; then
 if [ "$user" != 'admin' ]; then
@@ -201,6 +180,7 @@ U_DATABASES='0'
 U_CRON_JOBS='0'
 U_CRON_JOBS='0'
 U_BACKUPS='0'
 U_BACKUPS='0'
 LANGUAGE=''
 LANGUAGE=''
+NOTIFICATIONS='no'
 TIME='$TIME'
 TIME='$TIME'
 DATE='$DATE'" > $USER_DATA/user.conf
 DATE='$DATE'" > $USER_DATA/user.conf
 chmod 660 $USER_DATA/user.conf
 chmod 660 $USER_DATA/user.conf
@@ -220,6 +200,11 @@ if [ -x "$VESTA/data/packages/$package.sh" ]; then
     $VESTA/data/packages/$package.sh "$user" "$email" "$fname" "$lname"
     $VESTA/data/packages/$package.sh "$user" "$email" "$fname" "$lname"
 fi
 fi
 
 
+# Adding jailed sftp env
+if [ ! -z "$SFTPJAIL_KEY" ]; then
+    $BIN/v-add-user-sftp-jail $user
+fi
+
 # Logging
 # Logging
 log_history "added system user $user" '' 'admin'
 log_history "added system user $user" '' 'admin'
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"

+ 125 - 0
bin/v-add-user-favourites

@@ -0,0 +1,125 @@
+#!/bin/bash
+# info: adding user favourites
+# options: USER SYSTEM OBJECT
+#
+# The function adds object to users favourites
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+system=$(echo "$2" |tr '[:lower:]' '[:upper:]')
+object=$3
+email=$3
+id=$3
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '3' "$#" 'USER SYSTEM OBJECT'
+validate_format 'user' 'system'
+case $system in 
+    MAIL_ACC)   validate_format 'email' ;;
+    CRON)       validate_format 'id' ;;
+    DNS_REC)    validate_format 'id' ;;
+    *)          validate_format 'object'
+esac
+is_object_valid 'user' 'USER' "$user"
+is_object_unsuspended 'user' 'USER' "$user"
+
+# Checking system
+case $system in
+    USER)       check='ok' ;;
+    WEB)        check='ok' ;;
+    DNS)        check='ok' ;;
+    DNS_REC)    check='ok' ;;
+    MAIL)       check='ok' ;;
+    MAIL_ACC)   check='ok' ;;
+    DB)         check='ok' ;;
+    CRON)       check='ok' ;;
+    BACKUP)     check='ok' ;;
+    IP)         check='ok' ;;
+    PACKAGE)    check='ok' ;;
+    FIREWALL)   check='ok' ;;
+    *)      check_args '2' '0' 'USER SYSTEM OBJECT'
+esac
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Flushing vars
+USER=''
+WEB=''
+DNS=''
+DNS_REC=''
+MAIL=''
+MAIL_ACC=''
+DB=''
+CRON=''
+BACKUP=''
+IP=''
+PACKAGE=''
+FIREWALL=''
+
+# Creating config just in case
+touch $USER_DATA/favourites.conf
+
+# Reading current values
+source $USER_DATA/favourites.conf
+
+# Assigning current system value
+eval value=\$$system
+
+# Checking if object is new
+check_fav=$(echo "$value" |tr ',' '\n'| grep "^$object$")
+if [ ! -z "$check_fav" ]; then
+    exit 0
+fi
+
+# Adding object to favorites
+if [ -z "$value" ]; then
+    value="$object"
+else
+    value="$value,$object"
+fi
+
+# Updating sytem
+eval $system=$value
+
+# Updating user favorites
+echo "USER='$USER'
+WEB='$WEB'
+DNS='$DNS'
+DNS_REC='$DNS_REC'
+MAIL='$MAIL'
+MAIL_ACC='$MAIL_ACC'
+DB='$DB'
+CRON='$CRON'
+BACKUP='$BACKUP'
+IP='$IP'
+PACKAGE='$PACKAGE'
+FIREWALL='$FIREWALL'" > $USER_DATA/favourites.conf
+
+# Changing file permission
+chmod 640 $USER_DATA/favourites.conf
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+log_history "added starred $object in $system listing"
+log_event "$OK" "$EVENT"
+
+exit

+ 71 - 0
bin/v-add-user-notification

@@ -0,0 +1,71 @@
+#!/bin/bash
+# info: add user notification
+# options: USER TOPIC NOTICE [TYPE]
+#
+# The function adds user notification.
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+topic=$(echo $2 |sed "s/'/%quote%/g")
+notice=$(echo $3 |sed "s/'/%quote%/g")
+type=$4
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '2' "$#" 'USER TOPIC NOTICE [TYPE]'
+validate_format 'user' 'topic' 'notice'
+is_object_valid 'user' 'USER' "$user"
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining notification id
+if [ -e "$USER_DATA/notifications.conf" ]; then
+    nid=$(grep "NID=" $USER_DATA/notifications.conf |cut -f 2 -d \')
+    nid=$(echo "$nid" |sort -n |tail -n1)
+    if [ ! -z "$nid" ]; then
+        nid="$((nid +1))"
+    else
+        nid=1
+    fi
+else
+    nid=1
+fi
+
+# Concatenating string
+str="NID='$nid' TOPIC='$topic' NOTICE='$notice' TYPE='$type'"
+str="$str ACK='no' TIME='$TIME' DATE='$DATE'"
+
+# Adding to config
+echo "$str" >> $USER_DATA/notifications.conf
+
+# Changing permissions
+chmod 660 $USER_DATA/notifications.conf
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating notification counter
+if [ -z "$(grep NOTIFICATIONS $USER_DATA/user.conf)" ]; then
+    sed -i "s/^TIME/NOTIFICATIONS='yes'\nTIME/g" $USER_DATA/user.conf
+else
+    update_user_value "$user" '$NOTIFICATIONS' "yes"
+fi
+
+exit

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

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 pkg_dir=$1
 pkg_dir=$1
 package=$2
 package=$2
 rewrite=$3
 rewrite=$3

+ 66 - 0
bin/v-add-user-sftp-jail

@@ -0,0 +1,66 @@
+#!/bin/bash
+# info: add user sftp jail
+# options: USER
+#
+# The script enables sftp jailed environment
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/conf/vesta.conf
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '1' "$#" 'USER'
+validate_format 'user'
+if [ -z "$SFTPJAIL_KEY" ]; then
+    exit
+fi
+user_str=$(grep "^$user:" /etc/passwd |egrep "rssh|nologin")
+if [ -z "$user_str" ]; then
+    exit
+fi
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Defining user homedir
+home="$(echo $user_str |cut -f 6 -d :)"
+
+# Adding chroot directory
+if [ ! -d "/chroot/$user/$home" ]; then
+    mkdir -p /chroot/$user/$home
+    chmod 750 /chroot/$user
+    chmod 775 /chroot/$user/$home
+    chown root:sftp-only /chroot/$user
+    chown $user:sftp-only /chroot/$user/$home
+fi
+
+# Adding user to sftp group
+usermod -a -G sftp-only $user
+
+# Mouting home directory
+if [ -z "$(mount |grep $home)" ]; then
+    mount -o bind $home /chroot/$user/$home/
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Logging
+#log_event "$OK" "$EVENT"
+
+exit

+ 84 - 54
bin/v-add-web-domain

@@ -1,11 +1,11 @@
 #!/bin/bash
 #!/bin/bash
 # info: add web domain
 # info: add web domain
-# options: USER DOMAIN IP [RESTART]
+# options: USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]
 #
 #
 # The function adds virtual host to a server. In cases when a template is
 # The function adds virtual host to a server. In cases when a template is
 # undefined in the script, the template "default" will be used. The alias of
 # undefined in the script, the template "default" will be used. The alias of
 # www.domain.tld type will be automatically assigned to the domain. If ip have
 # www.domain.tld type will be automatically assigned to the domain. If ip have
-# assocated dns name, this domain will also get the alias domain-tpl.$ipname.
+# associated dns name, this domain will also get the alias domain-tpl.$ipname.
 # An alias with the ip name is useful during the site testing while dns isn't
 # An alias with the ip name is useful during the site testing while dns isn't
 # moved to a server yet.
 # moved to a server yet.
 
 
@@ -14,14 +14,18 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
 domain=$(echo $domain | sed -e 's/\.*$//g' -e 's/^\.*//g')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
-ip=$3
+ip=$3; IP=$3
 restart=$4
 restart=$4
+aliases=$5
+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"
+extentions=${6-$default_extentions}
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -34,7 +38,7 @@ source $VESTA/conf/vesta.conf
 #                    Verifications                         #
 #                    Verifications                         #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-check_args '3' "$#" 'USER DOMAIN IP [RESTART]'
+check_args '3' "$#" 'USER DOMAIN IP [RESTART] [ALIASES] [PROXY_EXTENTIONS]'
 validate_format 'user' 'domain' 'ip'
 validate_format 'user' 'domain' 'ip'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
@@ -45,50 +49,60 @@ is_ip_avalable
 is_package_full 'WEB_DOMAINS'
 is_package_full 'WEB_DOMAINS'
 template=$(get_user_value '$WEB_TEMPLATE')
 template=$(get_user_value '$WEB_TEMPLATE')
 is_web_template_valid
 is_web_template_valid
+if [ ! -z "$aliases" ]; then
+    for domain_alias in $(echo "${aliases//,/ }"); do
+        is_domain_new 'web' "$domain_alias" 'alias'
+    done
+fi
+if [ ! -z "$PROXY_SYSTEM" ]; then
+    validate_format 'extentions'
+    proxy=$(get_user_value '$PROXY_TEMPLATE')
+    is_proxy_template_valid $proxy
+fi
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Define real ip in case of NAT
-IP=$ip
-ip=$(get_real_ip $ip)
-
-# Defining domain aliases
-ip_name=$(get_ip_name)
-ip_name_idn=$(idn -t --quiet -a "$ip_name")
-domain_alias="www.$domain"
-domain_alias_idn="www.$domain_idn"
-if [ ! -z "$ip_name" ]; then
-    domain_alias_dash="${domain//./-}.$ip_name"
-    domain_alias_dash_idn="${domain_idn//./-}.$ip_name_idn"
-    aliases="$domain_alias,$domain_alias_dash"
-    aliases_idn="$domain_alias_idn,$domain_alias_dash_idn"
-    alias_string="ServerAlias $domain_alias_idn $domain_alias_dash_idn"
-else
-    aliases="$domain_alias"
-    aliases_idn="$domain_alias_idn"
-    alias_string="ServerAlias $domain_alias_idn"
+# Checking domain backend in case PHP-FPM is configured
+if [ ! -z "$WEB_BACKEND" ]; then
+    is_web_backend_pool_valid
+    $BIN/v-add-web-domain-backend $user $domain
+    rc=$?
+    if [ $rc -ne 0 ]; then
+        exit $rc
+    fi
+    get_domain_backend_values
+    backend=$(get_user_value '$BACKEND_TEMPLATE')
+    if [ -z "$backend" ]; then
+        backend='default'
+    fi
 fi
 fi
 
 
-# Defining vars for add_config function
+# Defining variables for add_config function
+ip=$(get_real_ip $ip)
 group="$user"
 group="$user"
 email="info@$domain"
 email="info@$domain"
 docroot="$HOMEDIR/$user/web/$domain/public_html"
 docroot="$HOMEDIR/$user/web/$domain/public_html"
 tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
 tpl_file="$WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.tpl"
 conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
 conf="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.conf"
 
 
-# Checking backend
-if [ ! -z "$WEB_BACKEND" ]; then
-    is_web_backend_pool_valid
-    $BIN/v-add-web-domain-backend $user $domain
-    rc=$?
-    if [ $rc -ne 0 ]; then
-        exit $rc
+# Defining domain aliases
+ip_name=$(get_ip_name)
+if [ -z "$aliases" ]; then
+    if [ -z "$ip_name" ]; then
+        aliases="www.$domain"
+    else
+        aliases="www.$domain,${domain//./-}.$ip_name"
+    fi
+else
+    if [ ! -z "$ip_name" ]; then
+        aliases="$aliases,${domain//./-}.$ip_name"
     fi
     fi
-    get_domain_backend_values
 fi
 fi
+aliases_idn=$(idn -t --quiet -a $aliases)
+alias_string="ServerAlias ${aliases_idn//,/ }"
 
 
 # Adding web config
 # Adding web config
 add_web_config
 add_web_config
@@ -133,23 +147,21 @@ done
 
 
 # Changing file owner
 # Changing file owner
 chown -R $user:$user $HOMEDIR/$user/web/$domain
 chown -R $user:$user $HOMEDIR/$user/web/$domain
-chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.*
-chown root:$user $conf
+chown root:$user /var/log/$WEB_SYSTEM/domains/$domain.* $conf
 
 
 # Changing file permissions
 # Changing file permissions
-chmod 640 $conf
+chmod 640 $conf /var/log/$WEB_SYSTEM/domains/$domain.*
 chmod 551 $HOMEDIR/$user/web/$domain
 chmod 551 $HOMEDIR/$user/web/$domain
-chmod 751 $HOMEDIR/$user/web/$domain/private
-chmod 751 $HOMEDIR/$user/web/$domain/cgi-bin
-chmod 751 $HOMEDIR/$user/web/$domain/public_html
-chmod 751 $HOMEDIR/$user/web/$domain/public_shtml
-chmod 751 $HOMEDIR/$user/web/$domain/document_errors
-chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/*
-chmod -f -R 665 $HOMEDIR/$user/web/$domain/public_html/*
-chmod -f -R 665 $HOMEDIR/$user/web/$domain/document_errors/*
-chmod 551 $HOMEDIR/$user/web/$domain/stats
-chmod 551 $HOMEDIR/$user/web/$domain/logs
-chmod 640 /var/log/$WEB_SYSTEM/domains/$domain.*
+chmod 751 $HOMEDIR/$user/web/$domain/private \
+  $HOMEDIR/$user/web/$domain/cgi-bin \
+  $HOMEDIR/$user/web/$domain/public_html \
+  $HOMEDIR/$user/web/$domain/public_shtml \
+  $HOMEDIR/$user/web/$domain/document_errors
+chmod -f -R 665 $HOMEDIR/$user/web/$domain/cgi-bin/* \
+  $HOMEDIR/$user/web/$domain/public_html/* \
+  $HOMEDIR/$user/web/$domain/document_errors/* \
+chmod 551 $HOMEDIR/$user/web/$domain/stats \
+  $HOMEDIR/$user/web/$domain/logs
 
 
 # Running template trigger
 # Running template trigger
 if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
 if [ -x $WEBTPL/$WEB_SYSTEM/$WEB_BACKEND/$template.sh ]; then
@@ -167,6 +179,23 @@ if [ -z "$web_include" ] && [ "$WEB_SYSTEM" = 'nginx' ]; then
     echo "include $conf;" >> $web_conf
     echo "include $conf;" >> $web_conf
 fi
 fi
 
 
+# Checking proxy system
+if [ ! -z "$PROXY_SYSTEM" ]; then
+    PROXY_EXT="$extentions"
+    tpl_file="$WEBTPL/$PROXY_SYSTEM/$proxy.tpl"
+    conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
+    add_web_config
+    chown root:$user $conf
+    chmod 640 $conf
+    proxy_conf="/etc/$PROXY_SYSTEM/conf.d/vesta.conf"
+    if [ -z "$(grep "$conf" $proxy_conf)" ]; then
+        echo "include $conf;" >> $proxy_conf
+    fi
+    if [ -x $WEBTPL/$PROXY_SYSTEM/$proxy.sh ]; then
+        $WEBTPL/$PROXY_SYSTEM/$proxy.sh $user $domain $ip $HOMEDIR $docroot
+    fi
+fi
+
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Vesta                              #
 #                       Vesta                              #
@@ -178,22 +207,23 @@ increase_user_value "$user" '$U_WEB_DOMAINS'
 increase_user_value "$user" '$U_WEB_ALIASES'
 increase_user_value "$user" '$U_WEB_ALIASES'
 
 
 # Defining domain variables
 # Defining domain variables
-BACKEND_TPL=$(grep BACKEND_TEMPLATE $USER_DATA/user.conf |cut -f 2 -d \')
 str="DOMAIN='$domain' IP='$IP' IP6='' ALIAS='$aliases' TPL='$template'"
 str="DOMAIN='$domain' IP='$IP' IP6='' ALIAS='$aliases' TPL='$template'"
-str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5=''"
-str="$str BACKEND='$BACKEND_TPL' PROXY='' PROXY_EXT='' STATS='' STATS_USER=''"
+str="$str SSL='no' SSL_HOME='same' FTP_USER='' FTP_MD5='' BACKEND='$backend'"
+str="$str PROXY='$proxy' PROXY_EXT='$extentions' STATS='' STATS_USER=''"
 str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
 str="$str STATS_CRYPT='' U_DISK='0' U_BANDWIDTH='0' SUSPENDED='no'"
 str="$str TIME='$TIME' DATE='$DATE'"
 str="$str TIME='$TIME' DATE='$DATE'"
 
 
 # Registering domain
 # Registering domain
 echo "$str" >> $USER_DATA/web.conf
 echo "$str" >> $USER_DATA/web.conf
-chmod 660 $USER_DATA/web.conf
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    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
 fi
 fi
 
 

+ 8 - 10
bin/v-add-web-domain-alias

@@ -10,7 +10,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
@@ -39,7 +39,7 @@ is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_valid 'web' 'DOMAIN' "$domain"
 is_object_valid 'web' 'DOMAIN' "$domain"
 is_object_unsuspended 'web' 'DOMAIN' "$domain"
 is_object_unsuspended 'web' 'DOMAIN' "$domain"
-is_domain_new 'web' "$dom_alias"
+is_domain_new 'web' "$dom_alias" 'alias'
 is_package_full 'WEB_ALIASES'
 is_package_full 'WEB_ALIASES'
 
 
 
 
@@ -75,7 +75,7 @@ if [ "$SSL" = 'yes' ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     del_web_config
     del_web_config
@@ -100,16 +100,14 @@ update_object_value 'web' 'DOMAIN' "$domain" '$ALIAS' "$ALIAS"
 # Update counters
 # Update counters
 increase_user_value "$user" '$U_WEB_ALIASES'
 increase_user_value "$user" '$U_WEB_ALIASES'
 
 
-# Adding task to the vesta pipe
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 3 - 5
bin/v-add-web-domain-backend

@@ -9,11 +9,11 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$2
 domain=$2
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
-template=$3
+template=${3-default}
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -67,9 +67,7 @@ cat $WEBTPL/$WEB_BACKEND/$template.tpl |\
 # Restart backend server
 # Restart backend server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web-backend
     $BIN/v-restart-web-backend
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web backend restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 7 - 6
bin/v-add-web-domain-ftp

@@ -9,12 +9,12 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
 ftp_user=${1}_${3}
 ftp_user=${1}_${3}
-password=$4
+password=$4; HIDE=4
 ftp_path=$5
 ftp_path=$5
 
 
 # Includes
 # Includes
@@ -22,10 +22,6 @@ source $VESTA/func/main.sh
 source $VESTA/func/domain.sh
 source $VESTA/func/domain.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #
@@ -94,6 +90,11 @@ fi
 echo "$ftp_user:$password" | /usr/sbin/chpasswd
 echo "$ftp_user:$password" | /usr/sbin/chpasswd
 ftp_md5=$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)
 ftp_md5=$(awk -v user=$ftp_user -F : 'user == $1 {print $2}' /etc/shadow)
 
 
+# Adding jailed sftp env
+if [ ! -z "$SFTPJAIL_KEY" ]; then
+    $BIN/v-add-user-sftp-jail $ftp_user
+fi
+
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Vesta                              #
 #                       Vesta                              #

+ 105 - 0
bin/v-add-web-domain-httpauth

@@ -0,0 +1,105 @@
+#!/bin/bash
+# info: add password protection for web domain
+# options: USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART]
+#
+# The call is used for securing web domain with http auth
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+domain=$2
+auth_user=$3
+password=$4; HIDE=4
+restart=${5-yes}
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+source $VESTA/conf/vesta.conf
+
+# Defining htpasswd file
+htaccess="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.conf_htaccess"
+htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd"
+docroot="$HOMEDIR/$user/web/$domain/public_html"
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '4' "$#" 'USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART]'
+validate_format '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"
+is_password_valid
+get_domain_values 'web'
+if [ ! -z "$(echo "$AUTH_USER" |tr : '\n' |grep ^$auth_user$)" ]; then
+    echo "Error: auth user $auth_user already exists"
+    log_event "$E_EXISTS" "$EVENT"
+    exit $E_EXISTS
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding htaccess password protection
+if [ ! -e "$htaccess" ]; then
+    if [ "$WEB_SYSTEM" != 'nginx' ]; then
+        echo "<Directory $docroot>" > $htaccess
+        echo "    AuthUserFile $htpasswd" >> $htaccess
+        echo "    AuthName \"$domain access\"" >> $htaccess
+        echo "    AuthType Basic" >> $htaccess
+        echo "    Require valid-user" >> $htaccess
+        echo "</Directory>" >> $htaccess
+    else
+        echo "auth_basic  \"$domain password access\";" > $htaccess
+        echo "auth_basic_user_file    $htpasswd;" >> $htaccess
+    fi
+    restart_required='yes'
+fi
+
+# Adding httpasswd user
+auth_hash=$($BIN/v-generate-password-hash htpasswd htpasswd $password)
+touch $htpasswd
+chmod 640 $htpasswd $htaccess
+sed -i "/^$auth_user:/d" $htpasswd
+echo "$auth_user:$auth_hash" >> $htpasswd
+
+# Restarting web server
+if [ "$restart" != 'no' ] && [ "$restart_required" = 'yes' ]; then
+    $BIN/v-restart-web
+fi
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Preparing web.conf keys
+if [ ! -z "$AUTH_USER" ]; then
+    auth_user="$AUTH_USER:$auth_user"
+    auth_hash="$AUTH_HASH:$auth_hash"
+else
+    # Adding new key into web.conf
+    add_object_key "web" 'DOMAIN' "$domain" 'AUTH_USER' 'U_DISK'
+    add_object_key "web" 'DOMAIN' "$domain" 'AUTH_HASH' 'U_DISK'
+fi
+
+# Updating config
+update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_USER' "$auth_user"
+update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_HASH' "$auth_hash"
+
+# Logging
+log_history "added http auth user $httpauth_user on $domain"
+log_event "$OK" "$EVENT"
+
+exit

+ 4 - 6
bin/v-add-web-domain-proxy

@@ -10,7 +10,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -42,7 +42,7 @@ is_object_value_empty 'web' 'DOMAIN' "$domain" '$PROXY'
 if [ -z $template ]; then
 if [ -z $template ]; then
     template=$(get_user_value '$PROXY_TEMPLATE')
     template=$(get_user_value '$PROXY_TEMPLATE')
 fi
 fi
-is_proxy_template_valid
+is_proxy_template_valid $template
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
@@ -100,12 +100,10 @@ fi
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-proxy
     $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Proxy restart failed" >/dev/null
 fi
 fi
 
 
 log_history "enabled proxy support for $domain"
 log_history "enabled proxy support for $domain"

+ 7 - 9
bin/v-add-web-domain-ssl

@@ -14,7 +14,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -97,7 +97,7 @@ if [ -z "$(grep "$conf" $web_conf)" ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     add_web_config
     add_web_config
@@ -124,16 +124,14 @@ increase_user_value "$user" '$U_WEB_SSL'
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL' "yes"
 
 
-# Restart web server
+# Restarting web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 1 - 1
bin/v-add-web-domain-stats

@@ -13,7 +13,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")

+ 3 - 7
bin/v-add-web-domain-stats-user

@@ -9,21 +9,17 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 stats_user=$3
 stats_user=$3
-password=$4
+password=$4; HIDE=4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/func/domain.sh
 source $VESTA/func/domain.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #
@@ -43,7 +39,7 @@ is_password_valid
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Definining statistic dir
+# Defining statistic dir
 stats_dir="$HOMEDIR/$user/web/$domain/stats"
 stats_dir="$HOMEDIR/$user/web/$domain/stats"
 
 
 # Adding htaccess file
 # Adding htaccess file

+ 52 - 68
bin/v-backup-user

@@ -12,7 +12,7 @@
 # Importing system variables
 # Importing system variables
 source /etc/profile
 source /etc/profile
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 notify=${2-no}
 notify=${2-no}
 
 
@@ -54,12 +54,11 @@ if [ "$notify" != 'no' ]; then
     email=$(get_user_value '$CONTACT')
     email=$(get_user_value '$CONTACT')
 else
 else
     subj="$user → backup failed"
     subj="$user → backup failed"
-    email=$(grep CONTACT $VESTA/data/users/admin/user.conf | cut -f 2 -d \')
+    email=$(grep CONTACT $VESTA/data/users/admin/user.conf |cut -f 2 -d \')
 fi
 fi
-send_mail="$VESTA/web/inc/mail-wrapper.php"
 
 
 # Check load average
 # Check load average
-la=$(cat /proc/loadavg | cut -f 1 -d ' ' | cut -f 1 -d '.')
+la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
 i=0
 i=0
 while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
 while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
     echo "$(date "+%F %T") LoadAverage $la is above threshold. Sleeping..."
     echo "$(date "+%F %T") LoadAverage $la is above threshold. Sleeping..."
@@ -67,20 +66,20 @@ while [ "$la" -ge "$BACKUP_LA_LIMIT" ]; do
     if [ "$i" -ge "5" ]; then
     if [ "$i" -ge "5" ]; then
         mail_top=$(top -b| head -n 30)
         mail_top=$(top -b| head -n 30)
         mail_text="LoadAverage $i is above threshold\n\n$mail_top\n"
         mail_text="LoadAverage $i is above threshold\n\n$mail_top\n"
-        echo -e "$mail_text" | $send_mail -s "$subj" $email
+        echo -e "$mail_text" |$send_mail -s "$subj" $email
         echo "Error: LA is too high"
         echo "Error: LA is too high"
         sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
         sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
         log_event "$E_LA" "$EVENT"
         log_event "$E_LA" "$EVENT"
         exit $E_LA
         exit $E_LA
     fi
     fi
-    la=$(cat /proc/loadavg | cut -f 1 -d ' ' | cut -f 1 -d '.')
+    la=$(cat /proc/loadavg |cut -f 1 -d ' ' |cut -f 1 -d '.')
     (( ++i))
     (( ++i))
 done
 done
 
 
 # Creating temporary directory
 # Creating temporary directory
 tmpdir=$(mktemp -p $BACKUP -d)
 tmpdir=$(mktemp -p $BACKUP -d)
 if [ "$?" -ne 0 ]; then
 if [ "$?" -ne 0 ]; then
-    echo "Can't create tmp dir $tmpdir" | $send_mail -s "$subj" $email
+    echo "Can't create tmp dir $tmpdir" |$send_mail -s "$subj" $email
     echo "Error: can't create tmp dir"
     echo "Error: can't create tmp dir"
     log_event "$E_NOTEXIST" "$EVENT"
     log_event "$E_NOTEXIST" "$EVENT"
     exit $E_NOTEXIST
     exit $E_NOTEXIST
@@ -137,15 +136,15 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
     # Parsing domain exclusions
     # Parsing domain exclusions
     conf="$USER_DATA/web.conf"
     conf="$USER_DATA/web.conf"
     for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do
     for domain in $(search_objects 'web' 'SUSPENDED' "*" 'DOMAIN'); do
-        check_exl=$(echo -e "${WEB//,/\n}" |grep "^$domain$")
-        if [ -z "$check_exl" ]; then
+        exclusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain$")
+        if [ -z "$exclusion" ]; then
             web_list="$web_list $domain"
             web_list="$web_list $domain"
         else
         else
             echo "$(date "+%F %T") excluding $domain"
             echo "$(date "+%F %T") excluding $domain"
             msg="$msg\n$(date "+%F %T") excluding $domain"
             msg="$msg\n$(date "+%F %T") excluding $domain"
         fi
         fi
     done
     done
-    web_list=$(echo "$web_list" | sed -e "s/  */\ /g" -e "s/^ //")
+    web_list=$(echo "$web_list" |sed -e "s/  */\ /g" -e "s/^ //")
 
 
     i=0
     i=0
 
 
@@ -207,36 +206,26 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
         fi
         fi
 
 
         # Define exclude arguments
         # Define exclude arguments
+        exlusion=$(echo -e "$WEB" |tr ',' '\n' |grep "^$domain:")
         set -f
         set -f
         fargs=()
         fargs=()
-        fargs+=(-not)
-        fargs+=(-path)
-        fargs+=("./logs*")
-        check_exlusion=$(echo -e "${WEB//,/\n}" | grep "^$domain:")
-        if [ ! -z "$check_exlusion" ]; then
-            xdirs="$(echo -e "${check_exlusion//:/\n}" |grep -v $domain)"
+        fargs+=(--exclude='logs/*')
+        if [ ! -z "$exlusion" ]; then
+            xdirs="$(echo -e "$exlusion" |tr ':' '\n' |grep -v $domain)"
             for xpath in $xdirs; do
             for xpath in $xdirs; do
-                xpath="$(echo $xpath | sed -e 's/\/*$//' -e 's/^\/*//')"
-                fargs+=(-not)
-                fargs+=(-path)
-                fargs+=("./$xpath/*")
+                fargs+=(--exclude=$xpath/*)
                 echo "$(date "+%F %T") excluding directory $xpath"
                 echo "$(date "+%F %T") excluding directory $xpath"
                 msg="$msg\n$(date "+%F %T") excluding directory $xpath"
                 msg="$msg\n$(date "+%F %T") excluding directory $xpath"
             done
             done
         fi
         fi
+        set +f
 
 
         # Backup files
         # Backup files
         cd $HOMEDIR/$user/web/$domain
         cd $HOMEDIR/$user/web/$domain
-        find . ${fargs[@]} -type f -print0 |\
-            tar -cpf $tmpdir/web/$domain/domain_data.tar --null -T -
-
-        # Backup empty folders
-        find . ${fargs[@]} -type d -empty -print0 |\
-            tar -rpf $tmpdir/web/$domain/domain_data.tar --null -T -
+        tar -cpf $tmpdir/web/$domain/domain_data.tar * ${fargs[@]} 
 
 
         # Compress archive
         # Compress archive
         gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
         gzip -$BACKUP_GZIP $tmpdir/web/$domain/domain_data.tar
-        set +f
     done
     done
 
 
     # Print total
     # Print total
@@ -259,15 +248,15 @@ if [ ! -z "$DNS_SYSTEM" ] && [ "$DNS" != '*' ]; then
 
 
     # Parsing domain exclusions
     # Parsing domain exclusions
     for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
     for domain in $(search_objects 'dns' 'SUSPENDED' "*" 'DOMAIN'); do
-        check_exl=$(echo -e "${DNS//,/\n}" |grep "^$domain$")
-        if [ -z "$check_exl" ]; then
+        exclusion=$(echo "$DNS" |tr ',' '\n' |grep "^$domain$")
+        if [ -z "$exclusion" ]; then
             dns_list="$dns_list $domain"
             dns_list="$dns_list $domain"
         else
         else
             echo "$(date "+%F %T") excluding $domain"
             echo "$(date "+%F %T") excluding $domain"
             msg="$msg\n$(date "+%F %T") excluding $domain"
             msg="$msg\n$(date "+%F %T") excluding $domain"
         fi
         fi
     done
     done
-    dns_list=$(echo "$dns_list" | sed -e "s/  */\ /g" -e "s/^ //")
+    dns_list=$(echo "$dns_list" |sed -e "s/  */\ /g" -e "s/^ //")
 
 
     i=0
     i=0
     for domain in $dns_list; do
     for domain in $dns_list; do
@@ -312,7 +301,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
     # Parsing domain exclusions
     # Parsing domain exclusions
     conf="$USER_DATA/mail.conf"
     conf="$USER_DATA/mail.conf"
     for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do
     for domain in $(search_objects 'mail' 'SUSPENDED' "*" 'DOMAIN'); do
-        check_exl=$(echo -e "${MAIL//,/\n}" |grep "^$domain$")
+        check_exl=$(echo "$MAIL" |tr ',' '\n' |grep "^$domain$")
         if [ -z "$check_exl" ]; then
         if [ -z "$check_exl" ]; then
             mail_list="$mail_list $domain"
             mail_list="$mail_list $domain"
         else
         else
@@ -320,7 +309,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
             msg="$msg\n$(date "+%F %T") excluding $domain"
             msg="$msg\n$(date "+%F %T") excluding $domain"
         fi
         fi
     done
     done
-    mail_list=$(echo "$mail_list" | sed -e "s/  */\ /g" -e "s/^ //")
+    mail_list=$(echo "$mail_list" |sed -e "s/  */\ /g" -e "s/^ //")
 
 
     i=0
     i=0
     for domain in $mail_list; do
     for domain in $mail_list; do
@@ -348,8 +337,8 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
         # Backup emails
         # Backup emails
         cd $HOMEDIR/$user/mail/$domain_idn
         cd $HOMEDIR/$user/mail/$domain_idn
         for account in $(ls); do
         for account in $(ls); do
-            exclusion=$(echo -e "${MAIL//,/\n}" |grep "$domain:")
-            exclusion=$(echo -e "${exclusion//:/\n}" |grep "^$account$")
+            exclusion=$(echo "$MAIL" |tr ',' '\n' |grep "$domain:")
+            exclusion=$(echo "$exclusion" |tr ':' '\n' |grep "^$account$")
 
 
             # Checking exlusions
             # Checking exlusions
             if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then
             if [ -z "$exclusion" ] && [[ "$MAIL_SYSTEM" =~ exim ]]; then
@@ -390,8 +379,8 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
 
 
     # Parsing database exclusions
     # Parsing database exclusions
     for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do
     for database in $(search_objects 'db' 'SUSPENDED' "*" 'DB'); do
-        check_exl=$(echo -e "${DB//,/\n}" |grep "^$database$")
-        if [ -z "$check_exl" ]; then
+        exclusion=$(echo "$DB" |tr ',' '\n' |grep "^$database$")
+        if [ -z "$exclusion" ]; then
             db_list="$db_list $database"
             db_list="$db_list $database"
         else
         else
             echo "$(date "+%F %T") excluding $database"
             echo "$(date "+%F %T") excluding $database"
@@ -401,7 +390,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
 
 
     i=0
     i=0
     conf="$USER_DATA/db.conf"
     conf="$USER_DATA/db.conf"
-    db_list=$(echo "$db_list" | sed -e "s/  */\ /g" -e "s/^ //")
+    db_list=$(echo "$db_list" |sed -e "s/  */\ /g" -e "s/^ //")
     for database in $db_list; do
     for database in $db_list; do
         ((i ++))
         ((i ++))
         get_database_values
         get_database_values
@@ -477,9 +466,8 @@ if [ "$USER" != '*' ]; then
     if [ -e "$USER_DATA/backup-excludes.conf" ]; then
     if [ -e "$USER_DATA/backup-excludes.conf" ]; then
         source $USER_DATA/backup-excludes.conf
         source $USER_DATA/backup-excludes.conf
     fi
     fi
-    exlusion_list=$(echo -e "${USER//,/\n}")
     fargs=()
     fargs=()
-    for xpath in $exlusion_list; do
+    for xpath in $(echo "$USER" |tr ',' '\n'); do
         fargs+=(-not)
         fargs+=(-not)
         fargs+=(-path)
         fargs+=(-path)
         fargs+=("./$xpath*")
         fargs+=("./$xpath*")
@@ -490,28 +478,24 @@ if [ "$USER" != '*' ]; then
     IFS=$'\n'
     IFS=$'\n'
     set -f
     set -f
     i=0
     i=0
-    for udir in $(ls |egrep -v "conf|web|dns|mail"); do
-        check_exl=$(echo -e "${USER//,/\n}" |grep "^$udir$")
-        if [ -z "$check_exl" ]; then
+
+    for udir in $(ls -a |egrep -v "conf|web|dns|mail|^\.\.$|^\.$"); do
+        exclusion=$(echo "$USER" |tr ',' '\n' |grep "^$udir$")
+        if [ -z "$exclusion" ]; then
             ((i ++))
             ((i ++))
             udir_list="$udir_list $udir"
             udir_list="$udir_list $udir"
-            echo -e "$(date "+%F %T") adding directory $udir"
-            msg="$msg\n$(date "+%F %T") adding directory $udir"
-
-            # Backup files
-            find ./$udir ${fargs[@]} -type f -print0 |\
-                tar -cpf $tmpdir/user_dir/$udir.tar --null -T -
+            echo -e "$(date "+%F %T") adding $udir"
+            msg="$msg\n$(date "+%F %T") adding  $udir"
 
 
-            # Backup empty folders
-            find ./$udir ${fargs[@]} -type d -empty -print0 |\
-                tar -rpf $tmpdir/user_dir/$udir.tar --null -T -
+            # Backup files and dirs
+            tar -cpf $tmpdir/user_dir/$udir.tar $udir
 
 
             # Compress arhive
             # Compress arhive
             gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
             gzip -$BACKUP_GZIP $tmpdir/user_dir/$udir.tar
         fi
         fi
     done
     done
     set +f
     set +f
-    udir_list=$(echo "$udir_list" | sed -e "s/  */\ /g" -e "s/^ //")
+    udir_list=$(echo "$udir_list" |sed -e "s/  */\ /g" -e "s/^ //")
 
 
     # Print total
     # Print total
     if [ "$i" -eq 1 ]; then
     if [ "$i" -eq 1 ]; then
@@ -526,7 +510,7 @@ if [ "$USER" != '*' ]; then
 fi
 fi
 
 
 # Get backup size
 # Get backup size
-size="$(du -shm $tmpdir | cut -f 1)"
+size="$(du -shm $tmpdir |cut -f 1)"
 
 
 # Get current time
 # Get current time
 end_time=$(date '+%s')
 end_time=$(date '+%s')
@@ -540,15 +524,15 @@ local_backup(){
     rm -f $BACKUP/$user.$DATE.tar
     rm -f $BACKUP/$user.$DATE.tar
 
 
     # Checking retention
     # Checking retention
-    backup_list=$(ls -lrt $BACKUP/ | awk '{print $9}' |grep "^$user\.")
-    backups_count=$(echo "$backup_list" | wc -l)
+    backup_list=$(ls -lrt $BACKUP/ |awk '{print $9}' |grep "^$user\.")
+    backups_count=$(echo "$backup_list" |wc -l)
     if [ "$BACKUPS" -le "$backups_count" ]; then
     if [ "$BACKUPS" -le "$backups_count" ]; then
         backups_rm_number=$((backups_count - BACKUPS))
         backups_rm_number=$((backups_count - BACKUPS))
         (( ++backups_rm_number))
         (( ++backups_rm_number))
 
 
         # Removing old 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$//")
+        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") Roated: $backup_date"
             msg="$msg\n$(date "+%F %T") Rotated: $backup_date"
             msg="$msg\n$(date "+%F %T") Rotated: $backup_date"
             rm -f $BACKUP/$backup
             rm -f $BACKUP/$backup
@@ -576,7 +560,7 @@ local_backup(){
     localbackup='yes'
     localbackup='yes'
     echo -e "$(date "+%F %T") Local: $BACKUP/$user.$DATE.tar"
     echo -e "$(date "+%F %T") Local: $BACKUP/$user.$DATE.tar"
     msg="$msg\n$(date "+%F %T") Local: $BACKUP/$user.$DATE.tar"
     msg="$msg\n$(date "+%F %T") Local: $BACKUP/$user.$DATE.tar"
-    U_BACKUPS=$(ls $BACKUP/ | grep "^$user." | wc -l)
+    U_BACKUPS=$(ls $BACKUP/ |grep "^$user." |wc -l)
     update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
     update_user_value "$user" '$U_BACKUPS' "$U_BACKUPS"
 }
 }
 
 
@@ -599,7 +583,7 @@ ftp_backup() {
     # Checking config
     # Checking config
     if [ ! -e "$VESTA/conf/ftp.backup.conf" ]; then
     if [ ! -e "$VESTA/conf/ftp.backup.conf" ]; then
         ftp_conf_error="Can't open  $VESTA/conf/ftp.backup.conf"
         ftp_conf_error="Can't open  $VESTA/conf/ftp.backup.conf"
-        echo "$ftp_conf_error" | $send_mail -s "$subj" $email
+        echo "$ftp_conf_error" |$send_mail -s "$subj" $email
         echo "Error: $VESTA/conf/ftp.backup.conf doesn't exist"
         echo "Error: $VESTA/conf/ftp.backup.conf doesn't exist"
         sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
         sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
         log_event "$E_NOTEXIST" "$EVENT"
         log_event "$E_NOTEXIST" "$EVENT"
@@ -663,11 +647,11 @@ ftp_backup() {
 
 
     # Checking retention
     # Checking retention
     backup_list=$(ftpc "cd $BPATH" "ls" |awk '{print $9}' |grep "^$user\.")
     backup_list=$(ftpc "cd $BPATH" "ls" |awk '{print $9}' |grep "^$user\.")
-    backups_count=$(echo "$backup_list" | wc -l)
+    backups_count=$(echo "$backup_list" |wc -l)
     if [ "$backups_count" -ge "$BACKUPS" ]; then
     if [ "$backups_count" -ge "$BACKUPS" ]; then
         backups_rm_number=$((backups_count - BACKUPS + 1))
         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$//")
+        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") Roated ftp backup: $backup_date"
             msg="$msg\n$(date "+%F %T") Roated ftp backup: $backup_date"
             msg="$msg\n$(date "+%F %T") Roated ftp backup: $backup_date"
             ftpc "cd $BPATH" "delete $backup"
             ftpc "cd $BPATH" "delete $backup"
@@ -750,7 +734,7 @@ sftp_backup() {
     # Checking config
     # Checking config
     if [ ! -e "$VESTA/conf/sftp.backup.conf" ]; then
     if [ ! -e "$VESTA/conf/sftp.backup.conf" ]; then
         sftp_conf_error="Can't open  $VESTA/conf/sftp.backup.conf"
         sftp_conf_error="Can't open  $VESTA/conf/sftp.backup.conf"
-        echo "$sftp_conf_error" | $send_mail -s "$subj" $email
+        echo "$sftp_conf_error" |$send_mail -s "$subj" $email
         echo "Error: $VESTA/conf/sftp.backup.conf doesn't exist"
         echo "Error: $VESTA/conf/sftp.backup.conf doesn't exist"
         sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
         sed -i "/ $user /d" $VESTA/data/queue/backup.pipe
         log_event "$E_NOTEXIST" "$EVENT"
         log_event "$E_NOTEXIST" "$EVENT"
@@ -803,11 +787,11 @@ sftp_backup() {
 
 
     # Checking retention
     # Checking retention
     backup_list=$(sftpc "cd $BPATH" "ls -l" |awk '{print $9}' |grep "^$user\.")
     backup_list=$(sftpc "cd $BPATH" "ls -l" |awk '{print $9}' |grep "^$user\.")
-    backups_count=$(echo "$backup_list" | wc -l)
+    backups_count=$(echo "$backup_list" |wc -l)
     if [ "$backups_count" -ge "$BACKUPS" ]; then
     if [ "$backups_count" -ge "$BACKUPS" ]; then
         backups_rm_number=$((backups_count - BACKUPS + 1))
         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.*$//")
+        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") Roated sftp backup: $backup_date"
             msg="$msg\n$(date "+%F %T") Roated sftp backup: $backup_date"
             msg="$msg\n$(date "+%F %T") Roated sftp backup: $backup_date"
             sftpc "cd $BPATH" "rm $backup" > /dev/null 2>&1
             sftpc "cd $BPATH" "rm $backup" > /dev/null 2>&1
@@ -869,7 +853,7 @@ msg="$msg\n$(date "+%F %T") Runtime: $run_time $min"
 touch $USER_DATA/backup.conf
 touch $USER_DATA/backup.conf
 sed -i "/$user.$DATE.tar/d" $USER_DATA/backup.conf
 sed -i "/$user.$DATE.tar/d" $USER_DATA/backup.conf
 
 
-# Regestering new backup
+# Registering new backup
 backup_str="BACKUP='$user.$DATE.tar'"
 backup_str="BACKUP='$user.$DATE.tar'"
 backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
 backup_str="$backup_str TYPE='$BACKUP_SYSTEM' SIZE='$size'"
 backup_str="$backup_str WEB='${web_list// /,}'"
 backup_str="$backup_str WEB='${web_list// /,}'"
@@ -893,7 +877,7 @@ sed -i "/v-backup-user $user /d" $VESTA/data/queue/backup.pipe
 if [ "$notify" != 'no' ]; then
 if [ "$notify" != 'no' ]; then
     subj="$user → backup has been completed"
     subj="$user → backup has been completed"
     email=$(get_user_value '$CONTACT')
     email=$(get_user_value '$CONTACT')
-    echo -e "$msg" | $send_mail -s "$subj" $email
+    echo -e "$msg" |$send_mail -s "$subj" $email
 fi
 fi
 
 
 # Logging
 # Logging

+ 4 - 2
bin/v-backup-users

@@ -9,8 +9,8 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Importing system enviroment  as we run this script 
-# mostly by cron wich not read it by itself
+# Importing system environment  as we run this script
+# mostly by cron which not read it by itself
 source /etc/profile
 source /etc/profile
 
 
 # Includes
 # Includes
@@ -22,6 +22,8 @@ source $VESTA/conf/vesta.conf
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
+$BIN/v-check-vesta-license >/dev/null
+
 if [ -z "$BACKUP_SYSTEM" ]; then
 if [ -z "$BACKUP_SYSTEM" ]; then
     exit
     exit
 fi
 fi

+ 3 - 5
bin/v-change-cron-job

@@ -10,7 +10,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 job=$2
 job=$2
 min=$3
 min=$3
@@ -64,11 +64,9 @@ sync_cron_jobs
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart crond
+# Restarting crond
 $BIN/v-restart-cron
 $BIN/v-restart-cron
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+check_result $? "Cron restart failed" >/dev/null
 
 
 # Logging
 # Logging
 log_history "changed cron job $job"
 log_history "changed cron job $job"

+ 2 - 6
bin/v-change-database-host-password

@@ -9,21 +9,17 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 type=$1
 type=$1
 host=$2
 host=$2
 dbuser=$3
 dbuser=$3
-password=$4
+password=$4; HIDE=4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/func/db.sh
 source $VESTA/func/db.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #

+ 1 - 1
bin/v-change-database-owner

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 database=$1
 database=$1
 user=$2
 user=$2
 
 

+ 2 - 6
bin/v-change-database-password

@@ -10,20 +10,16 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 database=$2
 database=$2
-password=$3
+password=$3; HIDE=3
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/func/db.sh
 source $VESTA/func/db.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A3='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #

+ 2 - 6
bin/v-change-database-user

@@ -9,11 +9,11 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 database=$2
 database=$2
 dbuser="$user"_"$3"
 dbuser="$user"_"$3"
-password=$4
+password=$4; HIDE=4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -21,10 +21,6 @@ source $VESTA/func/db.sh
 source $VESTA/func/rebuild.sh
 source $VESTA/func/rebuild.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #

+ 3 - 3
bin/v-change-dns-domain-exp

@@ -1,5 +1,5 @@
 #!/bin/bash
 #!/bin/bash
-# info: change dns domain expiriation date
+# info: change dns domain expiration date
 # options: USER DOMAIN EXP
 # options: USER DOMAIN EXP
 #
 #
 # The function of changing the term of expiration domain's registration. The
 # The function of changing the term of expiration domain's registration. The
@@ -10,7 +10,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -57,7 +57,7 @@ fi
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Logging
 # Logging
-log_history "changed whois expiriation date for $domain"
+log_history "changed whois expiration date for $domain"
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 
 exit
 exit

+ 5 - 6
bin/v-change-dns-domain-ip

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -51,6 +51,7 @@ sed -i "s/$old/$ip/g" $USER_DATA/dns/$domain.conf
 
 
 # Updating zone
 # Updating zone
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
     update_domain_zone
     update_domain_zone
 fi
 fi
 
 
@@ -59,7 +60,7 @@ if [ ! -z "$DNS_CLUSTER" ]; then
     # Check for first sync
     # Check for first sync
     dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
     dlock=$(grep "domain $user $domain" $VESTA/data/queue/dns-cluster.pipe)
     if [ -z "$dlock" ]; then
     if [ -z "$dlock" ]; then
-        cmd="$BIN/v-add-remote-dns-domain $user $domain domain"
+        cmd="$BIN/v-add-remote-dns-domain $user $domain domain yes"
         echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
         echo "$cmd" >> $VESTA/data/queue/dns-cluster.pipe
     fi
     fi
 fi
 fi
@@ -69,12 +70,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 4 - 5
bin/v-change-dns-domain-soa

@@ -10,7 +10,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -45,6 +45,7 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$SOA' "$soa"
 
 
 # Updating zone
 # Updating zone
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
     update_domain_zone
     update_domain_zone
 fi
 fi
 
 
@@ -63,12 +64,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 4 - 5
bin/v-change-dns-domain-tpl

@@ -11,7 +11,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -67,6 +67,7 @@ records="$(wc -l $USER_DATA/dns/$domain.conf |cut -f 1 -d ' ')"
 
 
 # Updating zone
 # Updating zone
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
     update_domain_zone
     update_domain_zone
 fi
 fi
 
 
@@ -89,12 +90,10 @@ fi
 update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
 update_object_value 'dns' 'DOMAIN' "$domain" '$TPL' "$template"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 update_object_value 'dns' 'DOMAIN' "$domain" '$RECORDS' "$records"
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 5 - 6
bin/v-change-dns-domain-ttl

@@ -2,14 +2,14 @@
 # info: change dns domain ttl
 # info: change dns domain ttl
 # options: USER DOMAIN TTL
 # options: USER DOMAIN TTL
 #
 #
-# The function for chaning the time to live TTL parameter for all records.
+# The function for changing the time to live TTL parameter for all records.
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -44,6 +44,7 @@ update_object_value 'dns' 'DOMAIN' "$domain" '$TTL' "$ttl"
 
 
 # Updating zone
 # Updating zone
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
     update_domain_zone
     update_domain_zone
 fi
 fi
 
 
@@ -62,12 +63,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 4 - 5
bin/v-change-dns-record

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
@@ -77,6 +77,7 @@ sort_dns_records
 
 
 # Updating zone
 # Updating zone
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
     update_domain_zone
     update_domain_zone
 fi
 fi
 
 
@@ -95,12 +96,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 4 - 5
bin/v-change-dns-record-id

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
@@ -51,6 +51,7 @@ sort_dns_records
 
 
 # Updating zone
 # Updating zone
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
 if [[ "$DNS_SYSTEM" =~ named|bind ]]; then
+    update_domain_serial
     update_domain_zone
     update_domain_zone
 fi
 fi
 
 
@@ -69,12 +70,10 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart named
+# Restarting named
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-dns
     $BIN/v-restart-dns
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "DNS restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 1 - 1
bin/v-change-domain-owner

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 domain=$1
 domain=$1
 user=$2
 user=$2
 ip=$3
 ip=$3

+ 1 - 1
bin/v-change-firewall-rule

@@ -13,7 +13,7 @@
 # Importing system variables
 # Importing system variables
 source /etc/profile
 source /etc/profile
 
 
-# Argument defenition
+# Argument definition
 rule=$1
 rule=$1
 action=$(echo $2|tr '[:lower:]' '[:upper:]')
 action=$(echo $2|tr '[:lower:]' '[:upper:]')
 ip=$3
 ip=$3

+ 51 - 0
bin/v-change-fs-file-permission

@@ -0,0 +1,51 @@
+#!/bin/bash
+# info: change file permission
+# options: USER FILE PERMISSIONS
+#
+# The function changes file access permissions on the file system
+
+user=$1
+src_file=$2
+permissions=$3
+
+# Checking arguments
+if [ -z "$permissions" ]; then
+    echo "Usage: USER FILE PERMISSIONS"
+    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 user homedir
+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 source file
+if [ ! -f "$src_file" ]; then
+    echo "Error: source file doesn't exist $src_file"
+    exit 3
+fi
+
+# Checking source path
+rpath=$(readlink -f "$src_file")
+if [ -z "$(echo $rpath |egrep "^/tmp|^$homedir")" ]; then
+    echo "Error: invalid source path $src_file"
+    exit 2
+fi
+
+# Changing file permissions
+sudo -u $user chmod $permissions "$src_file" >/dev/null 2>&1
+if [ $? -ne 0 ]; then
+    echo "Error: access permission on $src_file was not changed"
+    exit 3
+fi
+
+# Exiting
+exit

+ 2 - 6
bin/v-change-mail-account-password

@@ -9,23 +9,19 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
 account=$3
 account=$3
-password=$4
+password=$4; HIDE=4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/func/domain.sh
 source $VESTA/func/domain.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4='******'
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #

+ 1 - 1
bin/v-change-mail-account-quota

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

+ 2 - 2
bin/v-change-mail-domain-catchall

@@ -2,14 +2,14 @@
 # info: change mail domain catchall email
 # info: change mail domain catchall email
 # options: USER DOMAIN EMAIL
 # options: USER DOMAIN EMAIL
 #
 #
-# The function changes mail domain cathcall.
+# The function changes mail domain catchall.
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')
 domain=$(echo $domain | tr '[:upper:]' '[:lower:]')

+ 18 - 55
bin/v-change-remote-dns-domain-exp

@@ -1,5 +1,5 @@
 #!/bin/bash
 #!/bin/bash
-# info: change remote dns domain expiriation date
+# info: change remote dns domain expiration date
 # options: USER DOMAIN
 # options: USER DOMAIN
 #
 #
 # The function synchronize dns domain with the remote server.
 # The function synchronize dns domain with the remote server.
@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$2
 domain=$2
 
 
@@ -28,79 +28,42 @@ validate_format 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'dns' 'DOMAIN' "$domain"
 is_object_valid 'dns' 'DOMAIN' "$domain"
-
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    echo "Error: dns-cluster.conf doesn't exist"
-    log_event "$E_NOTEXIST $EVENT"
-    exit $E_NOTEXIST
+    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
 fi
 fi
-
-number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
-if [ "$number_of_proc" -gt 2 ]; then
-    echo "Error: another sync process already exists"
-    log_event "$E_EXISTS $EVENT"
-    exit $E_EXISTS
+if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
+    check_result $E_EXISTS "another sync process already running"
 fi
 fi
+remote_dns_health_check
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-old_ifs="$IFS"
 IFS=$'\n'
 IFS=$'\n'
+for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
 
 
-# Check remote dns nodes
-remote_dns_health_check
-
-for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
-
-    # Get host values
-    eval $cluster_str
-
-    # Check connection type
-    if [ -z "TYPE" ]; then
-        TYPE='api'
-    fi
-
-    # Switch on connection type
-    case $TYPE in
-        ssh) send_cmd="send_ssh_cmd" ;;
-        *)  send_cmd="send_api_cmd" ;;
-    esac
-
-    # Check recipient dns user
-    if [ -z "$DNS_USER" ]; then
-        DNS_USER='dns-cluster'
-    fi
-
-    # Check dns exceptions
-    if [ -z "$DNS_CLUSTER_IGNORE" ]; then
-        DNS_CLUSTER_IGNORE='dns-cluster'
-    fi
+    # Parsing remote host parameters
+    eval $cluster
 
 
-    # Sync domain
+    # Syncing domain
     str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
     str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
-    eval $str
-    $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'scheduled'
-    if [ $? -ne 0 ]; then
-        echo "Error: $TYPE connection to $HOST failed"
-        log_event "$E_CONNECT $EVENT"
-        exit $E_CONNECT
-    fi
+    cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
+    check_result $? "$HOST connection failed (exp insert)" $E_CONNECT
 
 
 done
 done
 
 
-# Update pipe
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating pipe
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
 str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
 if [ ! -z "$str" ]; then
 if [ ! -z "$str" ]; then
     sed -i "$str d"  $pipe
     sed -i "$str d"  $pipe
 fi
 fi
 
 
-
-#----------------------------------------------------------#
-#                       Vesta                              #
-#----------------------------------------------------------#
-
 exit
 exit

+ 20 - 56
bin/v-change-remote-dns-domain-soa

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$2
 domain=$2
 
 
@@ -28,82 +28,46 @@ validate_format 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'dns' 'DOMAIN' "$domain"
 is_object_valid 'dns' 'DOMAIN' "$domain"
-
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    echo "Error: dns-cluster.conf doesn't exist"
-    log_event "$E_NOTEXIST $EVENT"
-    exit $E_NOTEXIST
+    check_result 1 $E_NOTEXIST "dns-cluster.conf doesn't exist"
 fi
 fi
-
-number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
-if [ "$number_of_proc" -gt 2 ]; then
-    echo "Error: another sync process already exists"
-    log_event "$E_EXISTS $EVENT"
-    exit $E_EXISTS
+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
 fi
+remote_dns_health_check
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-old_ifs="$IFS"
 IFS=$'\n'
 IFS=$'\n'
+for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
 
 
-# Check remote dns nodes
-remote_dns_health_check
-
-for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
-
-    # Get host values
-    eval $cluster_str
-
-    # Check connection type
-    if [ -z "TYPE" ]; then
-        TYPE='api'
-    fi
-
-    # Switch on connection type
-    case $TYPE in
-        ssh) send_cmd="send_ssh_cmd" ;;
-        *)  send_cmd="send_api_cmd" ;;
-    esac
-
-    # Check recipient dns user
-    if [ -z "$DNS_USER" ]; then
-        DNS_USER='dns-cluster'
-    fi
-
-    # Check dns exceptions
-    if [ -z "$DNS_CLUSTER_IGNORE" ]; then
-        DNS_CLUSTER_IGNORE='dns-cluster'
-    fi
+    # Parsing remote host parameters
+    eval $cluster
 
 
-    # Sync domain
+    # Syncing SOA
     str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
     str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
-    eval $str
-    $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
+    cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
+    check_result $? "$HOST connection failed (sync)" $E_CONNECT
 
 
-    # Rebuild dns zone
-    $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
-    if [ $? -ne 0 ]; then
-        echo "Error: $TYPE connection to $HOST failed (rebuild)"
-        log_event "$E_CONNECT $EVENT"
-        exit $E_CONNECT
-    fi
+    # Rebuilding dns zone
+    cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
+    check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
 
 
 done
 done
 
 
-# Update pipe
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating pipe
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
 str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
 if [ ! -z "$str" ]; then
 if [ ! -z "$str" ]; then
     sed -i "$str d"  $pipe
     sed -i "$str d"  $pipe
 fi
 fi
 
 
-
-#----------------------------------------------------------#
-#                       Vesta                              #
-#----------------------------------------------------------#
-
 exit
 exit

+ 20 - 70
bin/v-change-remote-dns-domain-ttl

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$2
 domain=$2
 
 
@@ -28,96 +28,46 @@ validate_format 'user' 'domain'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_system_enabled "$DNS_CLUSTER" 'DNS_CLUSTER'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'dns' 'DOMAIN' "$domain"
 is_object_valid 'dns' 'DOMAIN' "$domain"
-
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
 if [ ! -e "$VESTA/conf/dns-cluster.conf" ]; then
-    echo "Error: dns-cluster.conf doesn't exist"
-    log_event "$E_NOTEXIST $EVENT"
-    exit $E_NOTEXIST
+    check_result $E_NOTEXIST "dns-cluster.conf doesn't exist"
 fi
 fi
-
-number_of_proc=$(ps auxf | grep -v grep | grep $VESTA/bin/$SCRIPT | wc -l)
-if [ "$number_of_proc" -gt 2 ]; then
-    echo "Error: another sync process already exists"
-    log_event "$E_EXISTS $EVENT"
-    exit $E_EXISTS
+if [ "$(ps auxf |grep -v grep |grep $BIN/$SCRIPT |wc -l)" -gt 2 ]; then
+    check_result $E_EXISTS "another sync process already running"
 fi
 fi
+remote_dns_health_check
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Action                             #
 #                       Action                             #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-old_ifs="$IFS"
 IFS=$'\n'
 IFS=$'\n'
+for cluster in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
 
 
-# Check remote dns nodes
-remote_dns_health_check
+    # Parsing remote host parameters
+    eval $cluster
 
 
-# Starting cluster loop
-for cluster_str in $(grep "SUSPENDED='no'" $VESTA/conf/dns-cluster.conf); do
-
-    # Get host values
-    eval $cluster_str
-
-    # Check connection type
-    if [ -z "TYPE" ]; then
-        TYPE='api'
-    fi
-
-    # Switch on connection type
-    case $TYPE in
-        ssh) send_cmd="send_ssh_cmd" ;;
-        *)  send_cmd="send_api_cmd" ;;
-    esac
-
-    # Check host connection
-    $send_cmd v-list-sys-config
-    if [ $? -ne 0 ]; then
-        echo "Error: $TYPE connection to $HOST failed"
-        log_event "$E_CONNECT $EVENT"
-        exit $E_CONNECT
-    fi
-
-    # Check recipient dns user
-    if [ -z "$DNS_USER" ]; then
-        DNS_USER='dns-cluster'
-    fi
-    $send_cmd v-list-user $DNS_USER
-    if [ $? -ne 0 ]; then
-        echo "Error: dns user $DNS_USER doesn't exist"
-        log_event "$E_NOTEXIST $EVENT"
-        exit $E_NOTEXIST
-    fi
-
-    # Check dns exceptions
-    if [ -z "$DNS_CLUSTER_IGNORE" ]; then
-        DNS_CLUSTER_IGNORE='dns-cluster'
-    fi
-
-    # Sync domain
+    # Syncing TTL
     str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
     str=$(grep "DOMAIN='$domain'" $USER_DATA/dns.conf)
-    eval $str
-    $send_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'no'
+    cluster_cmd v-insert-dns-domain $DNS_USER "$str" $HOSTNAME 'domain' 'no'
+    check_result $? "$HOST connection failed (sync)" $E_CONNECT
 
 
-    # Rebuild dns zone
-    $send_cmd v-rebuild-dns-domain $DNS_USER $domain 'scheduled'
-    if [ $? -ne 0 ]; then
-        echo "Error: $TYPE connection to $HOST failed (rebuild)"
-        log_event "$E_CONNECT $EVENT"
-        exit $E_CONNECT
-    fi
+    # Rebuilding dns zone
+    cluster_cmd v-rebuild-dns-domain $DNS_USER $domain 'yes' 'no'
+    check_result $? "$HOST connection failed (rebuild)" $E_CONNECT
 
 
 done
 done
 
 
-# Update pipe
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Updating pipe
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 pipe="$VESTA/data/queue/dns-cluster.pipe"
 str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
 str=$(grep -n "$SCRIPT $1 $2 $3$" $pipe | cut -f1 -d: | head -n1)
 if [ ! -z "$str" ]; then
 if [ ! -z "$str" ]; then
     sed -i "$str d"  $pipe
     sed -i "$str d"  $pipe
 fi
 fi
 
 
-#----------------------------------------------------------#
-#                       Vesta                              #
-#----------------------------------------------------------#
-
 exit
 exit

+ 1 - 1
bin/v-change-sys-config-value

@@ -10,7 +10,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
 key=$(echo "$1" | tr '[:lower:]' '[:upper:]' )
 value=$2
 value=$2
 
 

+ 1 - 1
bin/v-change-sys-hostname

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 domain=$1
 domain=$1
 
 
 # Includes
 # Includes

+ 1 - 1
bin/v-change-sys-ip-name

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 ip=$1
 ip=$1
 ip_name=$2
 ip_name=$2
 
 

+ 2 - 4
bin/v-change-sys-ip-nat

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 ip=$1
 ip=$1
 nat_ip=$2
 nat_ip=$2
 restart=$3
 restart=$3
@@ -77,9 +77,7 @@ fi
 # Restart ftp server
 # Restart ftp server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-ftp
     $BIN/v-restart-ftp
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "FTP restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 1 - 1
bin/v-change-sys-ip-owner

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 ip=$1
 ip=$1
 user=$2
 user=$2
 
 

+ 1 - 1
bin/v-change-sys-ip-status

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 ip=$1
 ip=$1
 ip_status=$2
 ip_status=$2
 
 

+ 1 - 1
bin/v-change-sys-language

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 language=$1
 language=$1
 
 
 # Includes
 # Includes

+ 1 - 1
bin/v-change-sys-timezone

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 timezone=$1
 timezone=$1
 
 
 # Includes
 # Includes

+ 1 - 1
bin/v-change-user-contact

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 email=$2
 email=$2
 
 

+ 9 - 4
bin/v-change-user-language

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 language=$2
 language=$2
 
 
@@ -19,9 +19,14 @@ source $VESTA/conf/vesta.conf
 
 
 
 
 is_language_valid() {
 is_language_valid() {
-    if [ ! -e "$VESTA/web/inc/i18n/$language.php" ]; then
-        echo "Error: language $language not exist"
-        log_event "$E_NOTEXIST $EVENT"
+    if ! [[ "$1" =~ ^[[:alnum:]_-]+$ ]]; then
+        echo "Error: language $1 is not valid"
+        log_event "$E_INVALID" "$EVENT"
+        exit $E_INVALID
+    fi
+    if [ ! -e "$VESTA/web/inc/i18n/$1.php" ]; then
+        echo "Error: language $1 doesn't exist"
+        log_event "$E_NOTEXIST" "$EVENT"
         exit $E_NOTEXIST
         exit $E_NOTEXIST
     fi
     fi
 }
 }

+ 1 - 1
bin/v-change-user-name

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 fname=$2
 fname=$2
 lname=$3
 lname=$3

+ 29 - 10
bin/v-change-user-ns

@@ -1,20 +1,24 @@
 #!/bin/bash
 #!/bin/bash
 # info: change user nameservers
 # info: change user nameservers
-# options: USER NS1 NS2 [NS3] [NS4]
+# options: USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]
 #
 #
-# The function for changing default nameservers for speciefic user.
+# The function for changing default nameservers for specific user.
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
 ns1=$(echo $2 | sed -e 's/\.*$//g' -e 's/^\.*//g')
 ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
 ns2=$(echo $3 | sed -e 's/\.*$//g' -e 's/^\.*//g')
-ns3=$4
-ns4=$5
+ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+ns5=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+ns6=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+ns7=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+ns8=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g')
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -26,10 +30,10 @@ source $VESTA/conf/vesta.conf
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Checking args
 # Checking args
-check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4]'
+check_args '3' "$#" 'USER NS1 NS2 [NS3] [NS4] [NS5] [NS6] [NS7] [NS8]'
 
 
 # Checking argument format
 # Checking argument format
-validate_format 'user' 'ns1' 'ns2' 
+validate_format 'user' 'ns1' 'ns2'
 if [ ! -z "$ns3" ]; then
 if [ ! -z "$ns3" ]; then
     ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
     ns3=$(echo $4 | sed -e 's/\.*$//g' -e 's/^\.*//g')
     validate_format 'ns3'
     validate_format 'ns3'
@@ -38,7 +42,22 @@ if [ ! -z "$ns4" ]; then
     ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
     ns4=$(echo $5 | sed -e 's/\.*$//g' -e 's/^\.*//g')
     validate_format 'ns4'
     validate_format 'ns4'
 fi
 fi
-
+if [ ! -z "$ns5" ]; then
+    ns5=$(echo $6 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+    validate_format 'ns5'
+fi
+if [ ! -z "$ns6" ]; then
+    ns6=$(echo $7 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+    validate_format 'ns6'
+fi
+if [ ! -z "$ns7" ]; then
+    ns7=$(echo $8 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+    validate_format 'ns7'
+fi
+if [ ! -z "$ns8" ]; then
+    ns8=$(echo $9 | sed -e 's/\.*$//g' -e 's/^\.*//g')
+    validate_format 'ns8'
+fi
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 is_object_unsuspended 'user' 'USER' "$user"
 
 
@@ -48,7 +67,7 @@ is_object_unsuspended 'user' 'USER' "$user"
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Merging values
 # Merging values
-ns="$ns1,$ns2,$ns3,$ns4"
+ns="$ns1,$ns2,$ns3,$ns4,$ns5,$ns6,$ns7,$ns8"
 ns=$(echo "$ns" | sed -e "s/,,//g" -e "s/,$//")
 ns=$(echo "$ns" | sed -e "s/,,//g" -e "s/,$//")
 
 
 # Changing ns values
 # Changing ns values
@@ -60,7 +79,7 @@ update_user_value "$user" '$NS' "$ns"
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 # Logging
 # Logging
-log_history "changed user nameservers to $ns1, $ns2"
+log_history "updated nameservers $ns1 $ns2 $ns3 $ns4 $ns5 $ns6 $ns7 $ns8"
 log_event "$OK" "$EVENT"
 log_event "$OK" "$EVENT"
 
 
 exit
 exit

+ 2 - 1
bin/v-change-user-package

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 package=$2
 package=$2
 force=$3
 force=$3
@@ -148,6 +148,7 @@ U_DATABASES='$U_DATABASES'
 U_CRON_JOBS='$U_CRON_JOBS'
 U_CRON_JOBS='$U_CRON_JOBS'
 U_BACKUPS='$U_BACKUPS'
 U_BACKUPS='$U_BACKUPS'
 LANGUAGE='$LANGUAGE'
 LANGUAGE='$LANGUAGE'
+NOTIFICATIONS='$NOTIFICATIONS'
 TIME='$TIME'
 TIME='$TIME'
 DATE='$DATE'" > $USER_DATA/user.conf
 DATE='$DATE'" > $USER_DATA/user.conf
 }
 }

+ 2 - 6
bin/v-change-user-password

@@ -9,18 +9,14 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
-password=$2
+password=$2; HIDE=2
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A2="******"
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #

+ 12 - 3
bin/v-change-user-shell

@@ -2,14 +2,14 @@
 # info: change user shell
 # info: change user shell
 # options: USER SHELL
 # options: USER SHELL
 #
 #
-# The function changes system shell of a user. Shell gives abilty to use ssh.
+# The function changes system shell of a user. Shell gives ability to use ssh.
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 shell=$2
 shell=$2
 
 
@@ -36,9 +36,18 @@ is_object_unsuspended 'user' 'USER' "$user"
 shell_path=$(grep -w "$shell" /etc/shells | head -n1)
 shell_path=$(grep -w "$shell" /etc/shells | head -n1)
 
 
 # Changing passwd file
 # Changing passwd file
-/usr/bin/chsh -s "$shell_path" "$user" &>/dev/null
+/usr/bin/chsh -s "$shell_path" "$user" >/dev/null 2>&1
 shell=$(basename $shell_path)
 shell=$(basename $shell_path)
 
 
+# Adding jailed sftp env
+if [ ! -z "$SFTPJAIL_KEY" ]; then
+    if [[ "$shell" =~ nologin ]] || [[ "$shell" =~ rssh ]]; then
+        $BIN/v-add-user-sftp-jail $user >/dev/null 2>&1
+    else
+        $BIN/v-delete-user-sftp-jail $user >/dev/null 2>&1
+    fi
+fi
+
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                       Vesta                              #
 #                       Vesta                              #

+ 2 - 2
bin/v-change-user-template

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 type=$(echo "$2" | tr '[:lower:]' '[:upper:]')
 type=$(echo "$2" | tr '[:lower:]' '[:upper:]')
 template=$3
 template=$3
@@ -37,7 +37,7 @@ is_object_unsuspended 'user' 'USER' "$user"
 case $type in 
 case $type in 
     WEB) is_web_template_valid;
     WEB) is_web_template_valid;
         update_user_value "$user" '$WEB_TEMPLATE' "$template";;
         update_user_value "$user" '$WEB_TEMPLATE' "$template";;
-    PROXY) is_proxy_template_valid;
+    PROXY) is_proxy_template_valid $template;
         update_user_value "$user" '$PROXY_TEMPLATE' "$template";;
         update_user_value "$user" '$PROXY_TEMPLATE' "$template";;
     DNS) is_dns_template_valid;
     DNS) is_dns_template_valid;
         update_user_value "$user" '$DNS_TEMPLATE' "$template";;
         update_user_value "$user" '$DNS_TEMPLATE' "$template";;

+ 5 - 8
bin/v-change-web-domain-backend-tpl

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -155,16 +155,13 @@ fi
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
 
 
-# Restart web
+# Restarting web
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web restart failed" >/dev/null
+
     $BIN/v-restart-web-backend
     $BIN/v-restart-web-backend
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Web backend restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 2 - 6
bin/v-change-web-domain-ftp-password

@@ -9,22 +9,18 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
 ftp_user=$3
 ftp_user=$3
-password=$4
+password=$4; HIDE=4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
 source $VESTA/func/domain.sh
 source $VESTA/func/domain.sh
 source $VESTA/conf/vesta.conf
 source $VESTA/conf/vesta.conf
 
 
-# Hiding password
-A4="******"
-EVENT="$DATE $TIME $SCRIPT $A1 $A2 $A3 $A4 $A5 $A6 $A7 $A8 $A9"
-
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 #                    Verifications                         #
 #                    Verifications                         #

+ 1 - 1
bin/v-change-web-domain-ftp-path

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")

+ 76 - 0
bin/v-change-web-domain-httpauth

@@ -0,0 +1,76 @@
+#!/bin/bash
+# info: change password for http auth user
+# options: USER DOMAIN AUTH_USER AUTH_PASSWORD
+#
+# The call is used for changing http auth user password
+
+
+#----------------------------------------------------------#
+#                    Variable&Function                     #
+#----------------------------------------------------------#
+
+# Argument definition
+user=$1
+domain=$2
+auth_user=$3
+password=$4; HIDE=4
+
+# Includes
+source $VESTA/func/main.sh
+source $VESTA/func/domain.sh
+source $VESTA/conf/vesta.conf
+
+# Defining htpasswd file
+htpasswd="$HOMEDIR/$user/conf/web/$WEB_SYSTEM.$domain.htpasswd"
+
+
+#----------------------------------------------------------#
+#                    Verifications                         #
+#----------------------------------------------------------#
+
+check_args '4' "$#" 'USER DOMAIN AUTH_USER AUTH_PASSWORD [RESTART]'
+validate_format '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"
+is_password_valid
+get_domain_values 'web'
+if [ -z "$(echo "$AUTH_USER" |tr : '\n' |grep ^$auth_user$)" ]; then
+    echo "Error: auth user $auth_user doesn't exist"
+    log_event "$E_NOTEXIST" "$EVENT"
+    exit $E_NOTEXIST
+fi
+
+
+#----------------------------------------------------------#
+#                       Action                             #
+#----------------------------------------------------------#
+
+# Adding httpasswd user
+auth_hash=$($BIN/v-generate-password-hash htpasswd htpasswd $password)
+touch $htpasswd
+sed -i "/^$auth_user:/d" $htpasswd
+echo "$auth_user:$auth_hash" >> $htpasswd
+
+
+#----------------------------------------------------------#
+#                       Vesta                              #
+#----------------------------------------------------------#
+
+# Rebuilding AUTH_HASH variable
+position=$(echo $AUTH_USER |tr ':' '\n' |grep -n '' |grep ":$auth_user$" |\
+    cut -f 1 -d:)
+auth_hash=$(echo $AUTH_HASH |tr ':' '\n' |grep -n '' |\
+    sed -e "s%^$position:.*%$position:$auth_hash%" |\
+    cut -f 2 -d :| sed -e "/^$/d"| sed -e ':a;N;$!ba;s/\n/:/g')
+
+# Updating config
+update_object_value 'web' 'DOMAIN' "$domain" '$AUTH_HASH' "$auth_hash"
+
+# Logging
+log_history "changed auth user $httpauth_user password on $domain"
+log_event "$OK" "$EVENT"
+
+exit

+ 12 - 14
bin/v-change-web-domain-ip

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -59,17 +59,17 @@ if [ "$SSL" = 'yes' ]; then
 fi
 fi
 
 
 # Checking proxy
 # Checking proxy
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.tpl"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/$PROXY_SYSTEM.conf"
     replace_web_config
     replace_web_config
-fi
 
 
-# Checking SSL proxy
-if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then 
-    tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
-    conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
-    replace_web_config
+    # Checking SSL proxy
+    if [ "$SSL" = 'yes' ] && [ ! -z "$PROXY" ]; then 
+        tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
+        conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
+        replace_web_config
+    fi
 fi
 fi
 
 
 
 
@@ -87,13 +87,11 @@ update_object_value 'web' 'DOMAIN' "$domain" '$IP' "$3"
 # Restart web server
 # Restart web server
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-web
     $BIN/v-restart-web
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "WEB restart failed" >/dev/null
 
 
-    $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
     fi
     fi
 fi
 fi
 
 

+ 5 - 7
bin/v-change-web-domain-proxy-tpl

@@ -9,7 +9,7 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
@@ -39,7 +39,7 @@ is_object_unsuspended 'user' 'USER' "$user"
 is_object_valid 'web' 'DOMAIN' "$domain"
 is_object_valid 'web' 'DOMAIN' "$domain"
 is_object_unsuspended 'web' 'DOMAIN' "$domain"
 is_object_unsuspended 'web' 'DOMAIN' "$domain"
 is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
 is_object_value_exist 'web' 'DOMAIN' "$domain" '$PROXY'
-is_proxy_template_valid
+is_proxy_template_valid $template
 
 
 
 
 #----------------------------------------------------------#
 #----------------------------------------------------------#
@@ -87,16 +87,14 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Update config
+# Updating config
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY' "$PROXY"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
 update_object_value 'web' 'DOMAIN' "$domain" '$PROXY_EXT' "$extentions"
 
 
-# Restart web
+# Restarting proxy
 if [ "$restart" != 'no' ]; then
 if [ "$restart" != 'no' ]; then
     $BIN/v-restart-proxy
     $BIN/v-restart-proxy
-    if [ $? -ne 0 ]; then
-        exit $E_RESTART
-    fi
+    check_result $? "Proxy restart failed" >/dev/null
 fi
 fi
 
 
 # Logging
 # Logging

+ 12 - 11
bin/v-change-web-domain-sslcert

@@ -1,6 +1,6 @@
 #!/bin/bash
 #!/bin/bash
 # info: change domain ssl certificate
 # info: change domain ssl certificate
-# options: USER DOMAIN SSL_DIR
+# options: USER DOMAIN SSL_DIR [RESTART]
 #
 #
 # The function changes SSL domain certificate and the key. If ca file present
 # The function changes SSL domain certificate and the key. If ca file present
 # it will be replaced as well.
 # it will be replaced as well.
@@ -10,11 +10,12 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
 ssl_dir=$3
 ssl_dir=$3
+restart=$4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -26,7 +27,7 @@ source $VESTA/conf/vesta.conf
 #                    Verifications                         #
 #                    Verifications                         #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-check_args '3' "$#" 'USER DOMAIN SSL_DIR'
+check_args '3' "$#" 'USER DOMAIN SSL_DIR [RESTART]'
 validate_format 'user' 'domain' 'ssl_dir'
 validate_format 'user' 'domain' 'ssl_dir'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
@@ -69,15 +70,15 @@ fi
 #                       Vesta                              #
 #                       Vesta                              #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Restart web server
-$BIN/v-restart-web
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+# Restarting web server
+if [ "$restart" != 'no' ]; then
+    $BIN/v-restart-web
+    check_result $? "Web restart failed" >/dev/null
 
 
-$BIN/v-restart-proxy
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
+    fi
 fi
 fi
 
 
 # Logging
 # Logging

+ 12 - 11
bin/v-change-web-domain-sslhome

@@ -5,11 +5,12 @@
 #                    Variable&Function                     #
 #                    Variable&Function                     #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-# Argument defenition
+# Argument definition
 user=$1
 user=$1
 domain=$(idn -t --quiet -u "$2" )
 domain=$(idn -t --quiet -u "$2" )
 domain_idn=$(idn -t --quiet -a "$domain")
 domain_idn=$(idn -t --quiet -a "$domain")
 ssl_home=$3
 ssl_home=$3
+restart=$4
 
 
 # Includes
 # Includes
 source $VESTA/func/main.sh
 source $VESTA/func/main.sh
@@ -21,7 +22,7 @@ source $VESTA/conf/vesta.conf
 #                    Verifications                         #
 #                    Verifications                         #
 #----------------------------------------------------------#
 #----------------------------------------------------------#
 
 
-check_args '3' "$#" 'USER DOMAIN SSL_HOME'
+check_args '3' "$#" 'USER DOMAIN SSL_HOME [RESTART]'
 validate_format 'user' 'domain'
 validate_format 'user' 'domain'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_system_enabled "$WEB_SYSTEM" 'WEB_SYSTEM'
 is_object_valid 'user' 'USER' "$user"
 is_object_valid 'user' 'USER' "$user"
@@ -55,7 +56,7 @@ esac
 replace_web_config
 replace_web_config
 
 
 # Checking proxy config
 # Checking proxy config
-if [ ! -z "$PROXY" ]; then
+if [ ! -z "$PROXY_SYSTEM" ] && [ ! -z "$PROXY" ]; then
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     tpl_file="$WEBTPL/$PROXY_SYSTEM/$PROXY.stpl"
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     conf="$HOMEDIR/$user/conf/web/s$PROXY_SYSTEM.conf"
     replace_web_config
     replace_web_config
@@ -69,15 +70,15 @@ fi
 # Update config
 # Update config
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
 update_object_value 'web' 'DOMAIN' "$domain" '$SSL_HOME' "$SSL_HOME"
 
 
-# Restart web server
-$BIN/v-restart-web
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
-fi
+# Restarting web server
+if [ "$restart" != 'no' ]; then
+    $BIN/v-restart-web
+    check_result $? "Web restart failed" >/dev/null
 
 
-$BIN/v-restart-proxy
-if [ $? -ne 0 ]; then
-    exit $E_RESTART
+    if [ ! -z "$PROXY_SYSTEM" ]; then
+        $BIN/v-restart-proxy
+        check_result $? "Proxy restart failed" >/dev/null
+    fi
 fi
 fi
 
 
 # Logging
 # Logging

Niektóre pliki nie zostały wyświetlone z powodu dużej ilości zmienionych plików