cyberpanel icon indicating copy to clipboard operation
cyberpanel copied to clipboard

[BUG] Unnecessary service restarts

Open Lvl4Sword opened this issue 1 year ago • 5 comments

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?

  1. Be root user
  2. crontab -l
  3. See 0 2 * * * /usr/local/CyberCP/bin/python /usr/local/CyberCP/plogical/renew.py >/dev/null 2>&1 exists
  4. Read renew.py
  5. 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

Lvl4Sword avatar Aug 11 '23 08:08 Lvl4Sword

As you know mail server ssl also depends upon the SSL so some time these need to restart after ssl

shbs9 avatar Aug 15 '23 13:08 shbs9

@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.

Lvl4Sword avatar Aug 15 '23 21:08 Lvl4Sword

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)

Lvl4Sword avatar Aug 17 '23 05:08 Lvl4Sword

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?

Lvl4Sword avatar Aug 24 '23 23:08 Lvl4Sword

This is still an issue.

Lvl4Sword avatar Oct 01 '23 04:10 Lvl4Sword