| 
				
			 | 
			
			
				@@ -513,6 +513,11 @@ function restore_database_from_friend { 
			 | 
		
	
		
			
			| 
				513
			 | 
			
				513
			 | 
			
			
				         restore_directory_from_friend /root/temp${1} ${1} 
			 | 
		
	
		
			
			| 
				514
			 | 
			
				514
			 | 
			
			
				         RESTORE_SUBDIR="var" 
			 | 
		
	
		
			
			| 
				515
			 | 
			
				515
			 | 
			
			
				         if [ ${1} ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				516
			 | 
			
			
				+            if [ ! -d /var/www/${2}/htdocs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				517
			 | 
			
			
				+                mkdir -p /var/www/${2}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				518
			 | 
			
			
				+                chown www-data:www-data /var/www/${2}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				519
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				520
			 | 
			
			
				+ 
			 | 
		
	
		
			
			| 
				516
			 | 
			
				521
			 | 
			
			
				             if [ -d /var/www/${2}/htdocs ]; then 
			 | 
		
	
		
			
			| 
				517
			 | 
			
				522
			 | 
			
			
				                 if [ -d /root/temp${1}/${RESTORE_SUBDIR}/www/${2}/htdocs ]; then 
			 | 
		
	
		
			
			| 
				518
			 | 
			
				523
			 | 
			
			
				                     rm -rf /var/www/${2}/htdocs 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -538,7 +543,7 @@ function restore_database_from_friend { 
			 | 
		
	
		
			
			| 
				538
			 | 
			
				543
			 | 
			
			
				 function restore_database { 
			 | 
		
	
		
			
			| 
				539
			 | 
			
				544
			 | 
			
			
				     RESTORE_SUBDIR="root" 
			 | 
		
	
		
			
			| 
				540
			 | 
			
				545
			 | 
			
			
				     restore_app_name=$1 
			 | 
		
	
		
			
			| 
				541
			 | 
			
				
			 | 
			
			
				-    restore_app_dir=$2 
			 | 
		
	
		
			
			| 
				
			 | 
			
				546
			 | 
			
			
				+    restore_app_domain=$2 
			 | 
		
	
		
			
			| 
				542
			 | 
			
				547
			 | 
			
			
				  
			 | 
		
	
		
			
			| 
				543
			 | 
			
				548
			 | 
			
			
				     if [ -d $USB_MOUNT/backup/${restore_app_name} ]; then 
			 | 
		
	
		
			
			| 
				544
			 | 
			
				549
			 | 
			
			
				         echo $"Restoring ${restore_app_name} database" 
			 | 
		
	
	
		
			
			| 
				
			 | 
			
			
				@@ -572,23 +577,27 @@ function restore_database { 
			 | 
		
	
		
			
			| 
				572
			 | 
			
				577
			 | 
			
			
				         function_check restore_directory_from_usb 
			 | 
		
	
		
			
			| 
				573
			 | 
			
				578
			 | 
			
			
				         restore_directory_from_usb "/root/temp${restore_app_name}" "${restore_app_name}" 
			 | 
		
	
		
			
			| 
				574
			 | 
			
				579
			 | 
			
			
				         RESTORE_SUBDIR="var" 
			 | 
		
	
		
			
			| 
				575
			 | 
			
				
			 | 
			
			
				-        if [ ${restore_app_dir} ]; then 
			 | 
		
	
		
			
			| 
				576
			 | 
			
				
			 | 
			
			
				-            if [ -d /var/www/${restore_app_dir}/htdocs ]; then 
			 | 
		
	
		
			
			| 
				577
			 | 
			
				
			 | 
			
			
				-                if [ -d /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_dir}/htdocs ]; then 
			 | 
		
	
		
			
			| 
				578
			 | 
			
				
			 | 
			
			
				-                    rm -rf /var/www/${restore_app_dir}/htdocs 
			 | 
		
	
		
			
			| 
				579
			 | 
			
				
			 | 
			
			
				-                    mv /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_dir}/htdocs /var/www/${restore_app_dir}/ 
			 | 
		
	
		
			
			| 
				
			 | 
			
				580
			 | 
			
			
				+        if [ ${restore_app_domain} ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				581
			 | 
			
			
				+            if [ ! -d /var/www/${restore_app_domain}/htdocs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				582
			 | 
			
			
				+                mkdir -p /var/www/${restore_app_domain}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				583
			 | 
			
			
				+                chown www-data:www-data /var/www/${restore_app_domain}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				584
			 | 
			
			
				+            fi 
			 | 
		
	
		
			
			| 
				
			 | 
			
				585
			 | 
			
			
				+            if [ -d /var/www/${restore_app_domain}/htdocs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				586
			 | 
			
			
				+                if [ -d /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				587
			 | 
			
			
				+                    rm -rf /var/www/${restore_app_domain}/htdocs 
			 | 
		
	
		
			
			| 
				
			 | 
			
				588
			 | 
			
			
				+                    mv /root/temp${restore_app_name}/${RESTORE_SUBDIR}/www/${restore_app_domain}/htdocs /var/www/${restore_app_domain}/ 
			 | 
		
	
		
			
			| 
				580
			 | 
			
				589
			 | 
			
			
				                     if [ ! "$?" = "0" ]; then 
			 | 
		
	
		
			
			| 
				581
			 | 
			
				590
			 | 
			
			
				                         set_user_permissions 
			 | 
		
	
		
			
			| 
				582
			 | 
			
				591
			 | 
			
			
				                         backup_unmount_drive 
			 | 
		
	
		
			
			| 
				583
			 | 
			
				592
			 | 
			
			
				                         exit 683 
			 | 
		
	
		
			
			| 
				584
			 | 
			
				593
			 | 
			
			
				                     fi 
			 | 
		
	
		
			
			| 
				585
			 | 
			
				
			 | 
			
			
				-                    if [ -d /etc/letsencrypt/live/${restore_app_dir} ]; then 
			 | 
		
	
		
			
			| 
				586
			 | 
			
				
			 | 
			
			
				-                        ln -s /etc/letsencrypt/live/${restore_app_dir}/privkey.pem /etc/ssl/private/${restore_app_dir}.key 
			 | 
		
	
		
			
			| 
				587
			 | 
			
				
			 | 
			
			
				-                        ln -s /etc/letsencrypt/live/${restore_app_dir}/fullchain.pem /etc/ssl/certs/${restore_app_dir}.pem 
			 | 
		
	
		
			
			| 
				
			 | 
			
				594
			 | 
			
			
				+                    if [ -d /etc/letsencrypt/live/${restore_app_domain} ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				595
			 | 
			
			
				+                        ln -s /etc/letsencrypt/live/${restore_app_domain}/privkey.pem /etc/ssl/private/${restore_app_domain}.key 
			 | 
		
	
		
			
			| 
				
			 | 
			
				596
			 | 
			
			
				+                        ln -s /etc/letsencrypt/live/${restore_app_domain}/fullchain.pem /etc/ssl/certs/${restore_app_domain}.pem 
			 | 
		
	
		
			
			| 
				588
			 | 
			
				597
			 | 
			
			
				                     else 
			 | 
		
	
		
			
			| 
				589
			 | 
			
				598
			 | 
			
			
				                         # Ensure that the bundled SSL cert is being used 
			 | 
		
	
		
			
			| 
				590
			 | 
			
				
			 | 
			
			
				-                        if [ -f /etc/ssl/certs/${restore_app_dir}.bundle.crt ]; then 
			 | 
		
	
		
			
			| 
				591
			 | 
			
				
			 | 
			
			
				-                            sed -i "s|${restore_app_dir}.crt|${restore_app_dir}.bundle.crt|g" /etc/nginx/sites-available/${restore_app_dir} 
			 | 
		
	
		
			
			| 
				
			 | 
			
				599
			 | 
			
			
				+                        if [ -f /etc/ssl/certs/${restore_app_domain}.bundle.crt ]; then 
			 | 
		
	
		
			
			| 
				
			 | 
			
				600
			 | 
			
			
				+                            sed -i "s|${restore_app_domain}.crt|${restore_app_domain}.bundle.crt|g" /etc/nginx/sites-available/${restore_app_domain} 
			 | 
		
	
		
			
			| 
				592
			 | 
			
				601
			 | 
			
			
				                         fi 
			 | 
		
	
		
			
			| 
				593
			 | 
			
				602
			 | 
			
			
				                     fi 
			 | 
		
	
		
			
			| 
				594
			 | 
			
				603
			 | 
			
			
				                 fi 
			 |