andre před 7 měsíci
rodič
revize
eee6e37911
1 změnil soubory, kde provedl 8 přidání a 8 odebrání
  1. 8 8
      controllers/SiteController.php

+ 8 - 8
controllers/SiteController.php

@@ -94,8 +94,6 @@ class SiteController {
     public static function revert($data): void {
         $username = $data['username'] ?? '';
         $domain = $data['domain'] ?? '';
-        $adminName = $data['admin_name'] ?? '';
-        $adminPassword = $data['admin_password'] ?? '';
         $webDir = "/home/$username/$domain";
         $placeholderdir = "/var/www/catchall";
 
@@ -295,26 +293,28 @@ class SiteController {
         $username = $data['username'] ?? '';
         $domain = $data['domain'] ?? '';
         if (empty($username)) {
-            error_log("terminate: ERROR: No username provided");
+            error_log("Undeploy: ERROR: No username provided");
             http_response_code(400);
             error_log(print_r($data,true));
             echo json_encode(['error' => 'Missing username']);
             return;
         }
         if( strpos(file_get_contents("/etc/passwd"),$username) == false) {
-            error_log("terminate: ERROR: User $username does not exist");
+            error_log("Undeploy: ERROR: User $username does not exist");
             http_response_code(400);
             error_log(print_r($data,true));
             echo json_encode(['error' => 'Unknown user']);
             return;
         }
         if(!empty($domain)) {
-            $configFile = "/etc/apache2/sites-enabled/$domain.conf";
+            $enableConfigFile = "/etc/apache2/sites-enabled/$domain.conf";
+            $disableConfigFile = "/etc/apache2/sites-available/$domain.conf";
             if ($GLOBALS['debug'] == true) { error_log("Remove config of user : " . $username); }
-            exec("sudo /usr/bin/rm -f $configFile 2>&1", $userOutput, $userReturnCode);
+            exec("sudo /usr/bin/rm -f $enableConfigFile 2>&1", $userOutput, $userReturnCode);
+            exec("sudo /usr/bin/rm -f $disableConfigFile 2>&1", $userOutput, $userReturnCode);
             exec("sudo /usr/bin/certbot delete --cert-name $domain --non-interactive 2>&1", $output, $returnCode);
             if ($returnCode !== 0) {
-                error_log("deploy: ERROR: certbot failed to delete certificate on $domain, details => " . implode("\n", $output));
+                error_log("Undeploy: ERROR: certbot failed to delete certificate on $domain, details => " . implode("\n", $output));
                 http_response_code(500);
                 echo json_encode(['error' => 'Certbot failed', 'details' => implode("\n", $output)]);
                 return;
@@ -322,7 +322,7 @@ class SiteController {
             exec('sudo /usr/bin/systemctl reload apache2  2>&1', $apacheOutput, $apacheReturnCode);
             if ($GLOBALS['debug'] == true) { error_log("Restarting Apache"); }
             if ($apacheReturnCode !== 0) {
-                error_log("deploy: ERROR: Apache Reload error, details => " . implode("\n", $apacheOutput));
+                error_log("Undeploy: ERROR: Apache Reload error, details => " . implode("\n", $apacheOutput));
                 http_response_code(500);
                 echo json_encode(['error' => 'Failed to reload Apache', 'details' => implode("\n", $apacheOutput)]);
                 return;