mikrotik services config
This commit is contained in:
		| @@ -317,10 +317,10 @@ class MikroTikManager(SSHManager): | |||||||
|              |              | ||||||
|             # Certificate is current, check services |             # Certificate is current, check services | ||||||
|             logger.info("Certificate is current. Verifying services...") |             logger.info("Certificate is current. Verifying services...") | ||||||
|              |  | ||||||
|             cert_name = "letsencrypt.pem_0" |             cert_names = ["letsencrypt.pem_0", "letsencrypt", "letsencrypt.pem"] | ||||||
|             services_need_update = False |             services_need_update = False | ||||||
|              |  | ||||||
|             for service in services: |             for service in services: | ||||||
|                 success, stdout, stderr = self.execute_command( |                 success, stdout, stderr = self.execute_command( | ||||||
|                     f'/ip service print where name="{service}"', |                     f'/ip service print where name="{service}"', | ||||||
| @@ -328,23 +328,32 @@ class MikroTikManager(SSHManager): | |||||||
|                 ) |                 ) | ||||||
|                  |                  | ||||||
|                 if success and stdout: |                 if success and stdout: | ||||||
|                     if f'certificate={cert_name}' not in stdout and 'certificate=letsencrypt' not in stdout: |                     logger.debug(f"Service {service} output:\n{stdout}") | ||||||
|                         logger.warning(f"Service {service} not using correct certificate") |                      | ||||||
|  |                     # Check if ANY of the expected certificate names appears in output | ||||||
|  |                     # (works for both tabular and key=value format) | ||||||
|  |                     cert_found = False | ||||||
|  |                     for cert_name in cert_names: | ||||||
|  |                         if cert_name in stdout: | ||||||
|  |                             cert_found = True | ||||||
|  |                             logger.info(f"✓ Service {service} using certificate: {cert_name}") | ||||||
|  |                             break | ||||||
|  |                      | ||||||
|  |                     if not cert_found: | ||||||
|  |                         logger.warning(f"Service {service} not using letsencrypt certificate") | ||||||
|                         services_need_update = True |                         services_need_update = True | ||||||
|                     else: |  | ||||||
|                         logger.info(f"✓ Service {service} properly configured") |  | ||||||
|                 else: |                 else: | ||||||
|                     logger.warning(f"Could not check service {service}") |                     logger.warning(f"Could not check service {service}") | ||||||
|                     services_need_update = True |                     services_need_update = True | ||||||
|              |  | ||||||
|             if services_need_update: |             if services_need_update: | ||||||
|                 logger.info("Services need reconfiguration. Updating...") |                 logger.info("Services need reconfiguration. Updating...") | ||||||
|                 self.configure_services(services, cert_name) |                 self.configure_services(services, "letsencrypt.pem_0") | ||||||
|                 return False |                 return False | ||||||
|              |  | ||||||
|             logger.info("✓ Certificate and services are current. Skipping.") |             logger.info("✓ Certificate and services are current.") | ||||||
|             return False |             return False | ||||||
|                  |                              | ||||||
|         except Exception as e: |         except Exception as e: | ||||||
|             logger.warning(f"Error checking: {e}") |             logger.warning(f"Error checking: {e}") | ||||||
|             return True |             return True | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Mateusz Gruszczyński
					Mateusz Gruszczyński