Bug #49274: Added check for spamassassin rules#11
Bug #49274: Added check for spamassassin rules#11castens wants to merge 1 commit intounivention:4.4-0from
Conversation
|
|
|
|
||
| from univention.lib.i18n import Translation | ||
| _ = Translation('univention-management-console-module-diagnostic').translate | ||
| run_descr = ["Trying to authenticate with machine password against LDAP Similar to running: univention-ldapsearch -LLLs base dn"] |
There was a problem hiding this comment.
This looks like a copy-pasted-text from the check used as a template for this new check. This must be updated.
| except subprocess.CalledProcessError: | ||
| raise Success('Spamassassin is not installed') | ||
|
|
||
| sa_version = subprocess.check_output(["spamassassin", "-V"]) |
There was a problem hiding this comment.
Multiple blanks here → pep8
Also use
perl -M'Mail::SpamAssassin' -e 'print($Mail::SpamAssassin::VERSION);'
to get the version in the right format, so you can remove the following 3 lines to parse and format the version number.
| 'label': 'update spamassassin rules' | ||
| }] | ||
| raise Critical('spamassassin rules could not be found', buttons=buttons) | ||
| if retest: raise ProblemFixed() |
| sa_version = subprocess.check_output(["spamassassin", "-V"]) | ||
| sa_version = sa_version.split()[2] | ||
| sa_version = sa_version.split('.') | ||
| folder_name = '%s.%03d%03d' % (int(sa_version[0]), int(sa_version[1]), int(sa_version[2])) |
There was a problem hiding this comment.
Maybe build the complete path here once, e.g.
folder_path = "/var/lib/spamassassin/%s.%03d%03d" % (…)
and use it below both times,
| sa_version = sa_version.split()[2] | ||
| sa_version = sa_version.split('.') | ||
| folder_name = '%s.%03d%03d' % (int(sa_version[0]), int(sa_version[1]), int(sa_version[2])) | ||
| if not os.path.exists("/var/lib/spamassassin/"+folder_name): |
There was a problem hiding this comment.
Concatenating strings with + is considered bad style in Python. See comment above.
| # Univention Management Console module: | ||
| # System Diagnosis UMC module | ||
| # | ||
| # Copyright 2016-2019 Univention GmbH |
| # | ||
| # Copyright 2016-2019 Univention GmbH | ||
| # | ||
| # http://www.univention.de/ |
| # You should have received a copy of the GNU Affero General Public | ||
| # License with the Debian GNU/Linux or Univention distribution in file | ||
| # /usr/share/common-licenses/AGPL-3; if not, see | ||
| # <http://www.gnu.org/licenses/>. |
| def run(_umc_instance, retest=False): | ||
| buttons = [] | ||
| try: | ||
| subprocess.check_call(["dpkg", "-s", "spamassassin"]) |
There was a problem hiding this comment.
Use dpkg-query -W spamassassin here please.
|
|
||
| def update_and_restart(umc_instance): | ||
| subprocess.check_call(["sa-update"]) | ||
| subprocess.check_call(["systemctl", "restart", "amavis.service"]) |
There was a problem hiding this comment.
- Use
systemctl try-reload-or-restart …as the service might not exists or currently is not running spamassass.serviceshould be added (to the same call assystemctlcan restart multiple services with one call).
univention/dist/ucs-ec2-tools#11
Thank you for providing a pull request!
Please make sure you considered the following things
Link to the issue in Bugzilla
https://forge.univention.org/bugzilla/show_bug.cgi?id=49274
Description of the changes
Added check for spamassassin rules