HestiaCP 7 лет назад
Родитель
Сommit
c63ecda7f8
7 измененных файлов с 83 добавлено и 32 удалено
  1. 19 16
      bin/v-backup-user
  2. 6 0
      bin/v-backup-users
  3. 24 7
      bin/v-list-users
  4. 4 0
      bin/v-update-user-stats
  5. 21 0
      func/main.sh
  6. 1 1
      web/edit/cron/index.php
  7. 8 8
      web/inc/i18n/es.php

+ 19 - 16
bin/v-backup-user

@@ -39,22 +39,7 @@ is_backup_enabled
 #                       Action                             #
 #----------------------------------------------------------#
 
-# block backup if current hour is after 6 AM
-WAIT_LOOP_ENTERED=0
-if pgrep -x "v-backup-users" > /dev/null
-then
-hour=$(date +"%H");
-    while [ "$hour" -gt "6" ]; do
-        if [ "$WAIT_LOOP_ENTERED" -eq 0 ]; then
-             $BIN/v-restart-web-backend
-        fi
-        WAIT_LOOP_ENTERED=1
-        current_date_time="`date "+%Y-%m-%d %H:%M:%S"`";
-        echo "$current_date_time - wait for backup user $user - hour $hour";
-        sleep 300
-        hour=$(date +"%H");
-    done
-fi
+wait_for_backup_if_it_is_not_time_for_backup
 
 # Set backup directory if undefined
 if [ -z "$BACKUP" ]; then
@@ -153,6 +138,7 @@ if [ ! -z "$WEB_SYSTEM" ] && [ "$WEB" != '*' ]; then
     i=0
 
     for domain in $web_list; do
+        wait_for_backup_if_it_is_not_time_for_backup
         ((i ++))
         echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
         mkdir -p $tmpdir/web/$domain/conf
@@ -326,6 +312,7 @@ if [ ! -z "$MAIL_SYSTEM" ] && [ "$MAIL" != '*' ]; then
 
     i=0
     for domain in $mail_list; do
+        wait_for_backup_if_it_is_not_time_for_backup
         ((i ++))
         echo -e "$(date "+%F %T") $domain" |tee -a $BACKUP/$user.log
         mkdir -p $tmpdir/mail/$domain/conf
@@ -398,6 +385,7 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
     conf="$USER_DATA/db.conf"
     db_list=$(echo "$db_list" |sed -e "s/  */\ /g" -e "s/^ //")
     for database in $db_list; do
+        wait_for_backup_if_it_is_not_time_for_backup
         ((i ++))
         get_database_values
 
@@ -412,6 +400,19 @@ if [ ! -z "$DB_SYSTEM" ] && [ "$DB" != '*' ]; then
         dumpgz="$tmpdir/db/$database/$database.$TYPE.sql.gz"
         grants="$tmpdir/db/$database/conf/$database.$TYPE.$DBUSER"
         if [ ! -f "$dumpgz" ]; then
+
+            while true
+            do
+                if pgrep -x "mysqldump" > /dev/null
+                then
+                    echo "Wait other mysqldump to finish"
+                    sleep 1
+                else
+                    echo "We can use mysqldump now"
+                    break
+                fi
+            done
+
             case $TYPE in
                 mysql) dump_mysql_database ;;
                 pgsql) dump_pgsql_database ;;
@@ -487,6 +488,8 @@ if [ "$USER" != '*' ]; then
             udir_list="$udir_list $udir"
             echo -e "$(date "+%F %T") adding $udir" |tee -a $BACKUP/$user.log
 
+            wait_for_backup_if_it_is_not_time_for_backup
+
             # Backup files and dirs
             tar -cpf- $udir |gzip -$BACKUP_GZIP - > $tmpdir/user_dir/$udir.tar.gz
         fi

+ 6 - 0
bin/v-backup-users

@@ -28,6 +28,12 @@ fi
 for user in $(grep '@' /etc/passwd |cut -f1 -d:); do
     check_suspend=$(grep "SUSPENDED='no'" $HESTIA/data/users/$user/user.conf)
     log=$HESTIA/log/backup.log
+    if [ ! -f "$VESTA/data/users/$user/user.conf" ]; then
+        continue;
+    fi
+    wait_for_backup_if_it_is_not_time_for_backup
+    check_suspend=$(grep "SUSPENDED='no'" $VESTA/data/users/$user/user.conf)
+    log=$VESTA/log/backup.log
     if [ ! -z "$check_suspend" ]; then
         echo -e "================================" >> $log
         echo -e "$user" >> $log

+ 24 - 7
bin/v-list-users

@@ -15,10 +15,16 @@ format=${1-shell}
 # JSON list function
 json_list() {
     echo '{'
-    object_count=$(grep '@' /etc/passwd |wc -l)
     i=1
     while read USER; do
         source $HESTIA/data/users/$USER/user.conf
+        if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then
+            continue;
+        fi
+        if [ $i -gt 1 ]; then
+            echo ","
+        fi
+        source $VESTA/data/users/$USER/user.conf
         echo -n '    "'$USER'": {
         "FNAME": "'$FNAME'",
         "LNAME": "'$LNAME'",
@@ -74,14 +80,8 @@ json_list() {
         "TIME": "'$TIME'",
         "DATE": "'$DATE'"
         }'
-        if [ "$i" -lt "$object_count" ]; then
-            echo ','
-        else
-            echo
-        fi
         ((i++))
     done < <(grep '@' /etc/passwd |cut -f1 -d:)
-
     echo '}'
 }
 
@@ -91,6 +91,10 @@ shell_list() {
     echo "----   ---   ---   ---   ---    --   ----   --   ----   ----"
     while read USER; do
         source $HESTIA/data/users/$USER/user.conf
+        if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then
+            continue;
+        fi
+        source $VESTA/data/users/$USER/user.conf
         echo -n "$USER $PACKAGE $U_WEB_DOMAINS $U_DNS_DOMAINS $U_MAIL_DOMAINS"
         echo " $U_DATABASES $U_DISK $U_BANDWIDTH $SUSPENDED $DATE"
     done < <(grep '@' /etc/passwd |cut -f1 -d:)
@@ -100,6 +104,10 @@ shell_list() {
 plain_list() {
     while read USER; do
         source $HESTIA/data/users/$USER/user.conf
+        if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then
+            continue;
+        fi
+        source $VESTA/data/users/$USER/user.conf
         echo -ne "$USER\t$FNAME\t$LNAME\t$PACKAGE\t$WEB_TEMPLATE\t"
         echo -ne "$BACKEND_TEMPLATE\t$PROXY_TEMPLATE\t$DNS_TEMPLATE\t"
         echo -ne "$WEB_DOMAINS\t$WEB_ALIASES\t$DNS_DOMAINS\t$DNS_RECORDS\t"
@@ -132,6 +140,10 @@ csv_list() {
     echo "U_CRON_JOBS,U_BACKUPS,LANGUAGE,TIME,DATE"
     while read USER; do
         source $HESTIA/data/users/$USER/user.conf
+        if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then
+            continue;
+        fi
+        source $VESTA/data/users/$USER/user.conf
         echo -n "$USER,\"$FNAME\",\"$LNAME\",$PACKAGE,$WEB_TEMPLATE,"
         echo -n "$BACKEND_TEMPLATE,$PROXY_TEMPLATE,$DNS_TEMPLATE,"
         echo -n "$WEB_DOMAINS,$WEB_ALIASES,$DNS_DOMAINS,$DNS_RECORDS,"
@@ -153,6 +165,11 @@ raw_list() {
     while read USER; do
         echo $HESTIA/data/users/$USER/user.conf
         cat $HESTIA/data/users/$USER/user.conf
+        if [ ! -f "$VESTA/data/users/$USER/user.conf" ]; then
+            continue;
+        fi
+        echo $VESTA/data/users/$USER/user.conf
+        cat $VESTA/data/users/$USER/user.conf
     done < <(grep '@' /etc/passwd |cut -f1 -d:)
 }
 

+ 4 - 0
bin/v-update-user-stats

@@ -68,6 +68,10 @@ TOTAL_USERS=0
 # Updating user stats
 for user in $user_list; do
     USER_DATA=$HESTIA/data/users/$user
+    if [ ! -f "$VESTA/data/users/$user/user.conf" ]; then
+        continue;
+    fi
+    USER_DATA=$VESTA/data/users/$user
     source $USER_DATA/user.conf
     next_month=$(date +'%m/01/%y' -d '+ 1 month')
     DATE=$(date -d "$next_month -1day" +%F)

+ 21 - 0
func/main.sh

@@ -938,3 +938,24 @@ format_aliases() {
         aliases=$(echo "$aliases" |tr '\n' ',' |sed -e "s/,$//")
     fi
 }
+
+
+wait_for_backup_if_it_is_not_time_for_backup() {
+    # block backup if current hour is after 6 AM
+    WAIT_LOOP_ENTERED=0
+    if pgrep -x "v-backup-users" > /dev/null
+    then
+        hour=$(date +"%H");
+        while [ "$hour" -gt "6" ]; do
+            if [ "$WAIT_LOOP_ENTERED" -eq 0 ]; then
+                # do something when enter sleeping state
+                # $BIN/v-restart-web-backend
+            fi
+            WAIT_LOOP_ENTERED=1
+            current_date_time="`date "+%Y-%m-%d %H:%M:%S"`";
+            echo "$current_date_time - wait to backup user $user - current hour is $hour";
+            sleep 300
+            hour=$(date +"%H");
+        done
+    fi
+}

+ 1 - 1
web/edit/cron/index.php

@@ -23,7 +23,7 @@ $v_job = escapeshellarg($_GET['job']);
 exec (HESTIA_CMD."v-list-cron-job ".$user." ".$v_job." 'json'", $output, $return_var);
 check_return_code($return_var,$output);
 
-$data = json_decode(implode('', str_replace("\\", "\\\\", $output)), true);
+$data = json_decode(implode('', $output), true);
 unset($output);
 
 // Parse cron job

+ 8 - 8
web/inc/i18n/es.php

@@ -197,7 +197,7 @@ $LANG['es'] = array(
     'IP Addresses'  => 'Direcciones IP',
     'Backups'  => 'Respaldos',
     'Backup System'  => 'Sistema de Respaldo',
-    'backup exclusions' => 'configurar exlusiones',
+    'backup exclusions' => 'configurar exclusiones',
     'template'  => 'plantilla',
     'SSL Support'  => 'Soportar SSL',
     'SSL Home Directory'  => 'Directorio local del SSL',
@@ -641,9 +641,9 @@ $LANG['es'] = array(
     'Delete items' => 'Eliminando items',
     'Copy files' => 'Copiar archivos',
     'Move files' => 'Mover archivos',
-    'Are you sure you want to copy' => 'Estás seguro que deseas copiar',
-    'Are you sure you want to move' => 'Estás seguro que deseas mover',
-    'Are you sure you want to delete' => 'Estás seguro que deseas eliminar',
+    'Are you sure you want to copy' => 'Estás seguro de que deseas copiar',
+    'Are you sure you want to move' => 'Estás seguro de que deseas mover',
+    'Are you sure you want to delete' => 'Estás seguro de que deseas eliminar',
     'into' => 'en',
     'existing files will be replaced' => 'los archivos existentes serán reemplazados',
     'Original name' => 'Nombre original',
@@ -711,7 +711,7 @@ $LANG['es'] = array(
     'Disable and Cancel Licence' => 'Deshabilitar y Cancelar Licencia',
     'Licence Activated' => 'Licencia Activada',
     'Licence Deactivated' => 'Licencia Desactivada',
-    'Restrict users so that they cannot use SSH and access only their home directory.' => 'Restringue a los usuarios para que sólo puedan ingresar a su directorio local y prohíbe el acceso a SSH.',
+    'Restrict users so that they cannot use SSH and access only their home directory.' => 'Restringe a los usuarios para que sólo puedan ingresar a su directorio local y prohíbe el acceso a SSH.',
     'Browse, copy, edit, view, and retrieve all of your web domain files using fully featured File Manager.' => 'Navegar, copiar, editar, ver y descargar todos los archivos de tu página web utilizando el Administrador de Archivos.',
     'This is a commercial module, you would need to purchace license key to enable it.' => 'Este es un módulo comercial, tendrás que adquirir una licencia para poder activarlo.',
 
@@ -752,8 +752,8 @@ $LANG['es'] = array(
     'PUB_KEY' => 'CLAVE PÚBLICA',
     'ISSUER' => 'EMITIDO POR',
 
-    'Use server hostname' => 'Usar hostname del servidor',
-    'Use domain hostname' => 'Usar hostname del dominio',
+    'Use server hostname' => 'Usar el nombre del servidor',
+    'Use domain hostname' => 'Usar el dominio',
     'Use STARTTLS' => 'Usar STARTTLS',
     'Use SSL / TLS' => 'Usar SSL / TLS',
     'No encryption' => 'Sin encriptación',
@@ -761,6 +761,6 @@ $LANG['es'] = array(
 
     'maximum characters length, including prefix' => 'usar un máximo de %s caracteres, incluyendo prefijo',
 
-    'Email Credentials' => 'Email Credentials',
+    'Email Credentials' => 'Datos de acceso a la cuenta de correo',
     
 );