mikrotik services config
This commit is contained in:
@@ -317,10 +317,10 @@ class MikroTikManager(SSHManager):
|
||||
|
||||
# Certificate is current, check 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
|
||||
|
||||
|
||||
for service in services:
|
||||
success, stdout, stderr = self.execute_command(
|
||||
f'/ip service print where name="{service}"',
|
||||
@@ -328,23 +328,32 @@ class MikroTikManager(SSHManager):
|
||||
)
|
||||
|
||||
if success and stdout:
|
||||
if f'certificate={cert_name}' not in stdout and 'certificate=letsencrypt' not in stdout:
|
||||
logger.warning(f"Service {service} not using correct certificate")
|
||||
logger.debug(f"Service {service} output:\n{stdout}")
|
||||
|
||||
# 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
|
||||
else:
|
||||
logger.info(f"✓ Service {service} properly configured")
|
||||
else:
|
||||
logger.warning(f"Could not check service {service}")
|
||||
services_need_update = True
|
||||
|
||||
|
||||
if services_need_update:
|
||||
logger.info("Services need reconfiguration. Updating...")
|
||||
self.configure_services(services, cert_name)
|
||||
self.configure_services(services, "letsencrypt.pem_0")
|
||||
return False
|
||||
|
||||
logger.info("✓ Certificate and services are current. Skipping.")
|
||||
|
||||
logger.info("✓ Certificate and services are current.")
|
||||
return False
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"Error checking: {e}")
|
||||
return True
|
||||
|
||||
Reference in New Issue
Block a user