cyberpanel
cyberpanel copied to clipboard
[BUG] Unnecessary service restarts
Describe the bug https://github.com/usmannasir/cyberpanel/blob/stable/plogical/renew.py incorrectly reboots postfix, dovecot, and lscpd services every day at 2:00 AM UTC. This is regardless of if there were new certificates retrieved or not.
To Reproduce What steps did you take when the issue occurred?
- Be root user
-
crontab -l
- See
0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/renew.py >/dev/null 2>&1
exists - Read
renew.py
- It does, in fact, reboot the machine every day at 2:00 AM UTC. Lines 129 through 140.
Expected behavior That postfix, dovecot, and lscpd don't get rebooted every day unnecessarily.
Screenshots Not necessary
Operating system: Ubuntu 20.04 LTS
CyberPanel version:
2.3 Build: 4 Current Commit: 92c7e88a17581c73da30abb7cb715805b8032ca9
Additional context None
As you know mail server ssl also depends upon the SSL so some time these need to restart after ssl
@shbs9 I'm not sure you understand the issue. The check happens at 2AM UTC and services are restarted whether certificates were issued or not.
Do you see how this on lines 129 - 140 is improperly indented? ( https://github.com/usmannasir/cyberpanel/blob/stable/plogical/renew.py#L129 ):
from plogical.processUtilities import ProcessUtilities
command = 'postmap -F hash:/etc/postfix/vmail_ssl.map'
ProcessUtilities.normalExecutioner(command)
command = 'systemctl restart postfix'
ProcessUtilities.normalExecutioner(command)
command = 'systemctl restart dovecot'
ProcessUtilities.normalExecutioner(command)
command = 'systemctl restart lscpd'
ProcessUtilities.normalExecutioner(command)
The fix here would be to only restart these services when a certificate is issued.
My approach to this would be:
- Assign a variable to False
- Only changing that variable to True if a certificate is issued
- Having an
if variable:
at the end, after all of the certificate stuff. - In this
if
, restart services. That way services are only restarted if necessary.
Does this make sense?
This is still an issue.