Просмотр исходного кода

Fix #1834 Include extra config when restoring backups

Jaap Marcus 3 лет назад
Родитель
Сommit
877bcdf2bf
2 измененных файлов с 24 добавлено и 3 удалено
  1. 19 2
      bin/v-restore-user
  2. 5 1
      func/domain.sh

+ 19 - 2
bin/v-restore-user

@@ -335,8 +335,25 @@ if [ "$web" != 'no' ] && [ -n "$WEB_SYSTEM" ]; then
                 $BIN/v-add-web-domain-backend $user $domain $BACKEND
             fi
         fi
-                
-        # Rebuilding vhost
+        
+        # Restoring custom user config
+        # Except certificates, .conf files
+        if [ ! -d "$HOMEDIR/$user/conf/web/$domain/" ]; then
+            mkdir -p $HOMEDIR/$user/conf/web/$domain/
+        fi
+        for file in $tmpdir/web/$domain/conf/*; do 
+            if [[ "$file" == *.ca ]] || [[ "$file" == *.crt ]]  || [[ "$file" == *.key ]]  || [[ "$file" == *.pem ]]  || [[ "$file" == *.conf ]]; then
+               continue;
+            fi
+            if grep "fastcgi_pass" file; then 
+               # Do not allow to run php under a different user
+               continue;
+            fi 
+            filename=$(basename $file) 
+            cp -f "$file" "$HOMEDIR/$user/conf/web/$domain/$filename"
+        done
+        
+        # Rebuilding vhost to prevent user overwrite default config changes not ideal 
         rebuild_web_domain_conf
         
         # Restoring web domain data

+ 5 - 1
func/domain.sh

@@ -230,7 +230,11 @@ prepare_web_domain_values() {
 
 # Add web config
 add_web_config() {
-    mkdir -p "$HOMEDIR/$user/conf/web/$domain"
+    # Check if folder already exists
+    if [ ! -d "$HOMEDIR/$user/conf/web/$domain" ]; then
+        mkdir -p "$HOMEDIR/$user/conf/web/$domain/"
+    fi
+    
     conf="$HOMEDIR/$user/conf/web/$domain/$1.conf"
     if [[ "$2" =~ stpl$ ]]; then
         conf="$HOMEDIR/$user/conf/web/$domain/$1.ssl.conf"