Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP: Added Rspamd installation #493

Open
wants to merge 47 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
c7499e5
Added Rspamd installation
Spitfireap Apr 4, 2023
f38b6e7
Fixed dict, few fixes
Spitfireap Apr 4, 2023
e8cf675
Better configuration
Spitfireap Apr 4, 2023
2558a6d
Removed installer.cfg
Spitfireap Apr 4, 2023
e433b34
fixed test
Spitfireap Apr 5, 2023
d8c116a
updated rspamd config
Spitfireap Jun 21, 2023
c071886
fix
Spitfireap Sep 5, 2023
798e522
App incompatibility detection, updated for 2.2.0
Spitfireap Sep 6, 2023
064d7e5
import fix
Spitfireap Sep 6, 2023
9298f21
Few fixes
tonioo Sep 12, 2023
dc35443
Fixed wrong settings initialization
tonioo Sep 14, 2023
210efd5
Fixed issues in rspamd script
tonioo Sep 14, 2023
136c8d9
Fixed wrong setting names
tonioo Sep 14, 2023
6301e4c
Consistency for variable names
tonioo Sep 14, 2023
56e8bce
Fixed wrong setting names!
tonioo Sep 14, 2023
dc3a0f0
Escape % character in config file
tonioo Sep 14, 2023
625985a
Fixed wrong access to config option
tonioo Sep 14, 2023
c768a4a
Fixed tests
tonioo Sep 14, 2023
b687c13
Make rspamd installation work
tonioo Sep 21, 2023
1e05f07
Convert codename to str
tonioo Sep 21, 2023
b49ba6d
Fixed wrong call to mkdir_safe
tonioo Sep 21, 2023
473019c
Better custom repo installation
tonioo Sep 21, 2023
8a45ead
Updated config and interactive mode
Spitfireap Sep 25, 2023
09fd2b7
Fixed config
Spitfireap Sep 25, 2023
bde57b0
Added possibility of if directive in each entry
Spitfireap Sep 25, 2023
5e476f0
Fixed new source bug, removed bionic, added dynamic defaults
Spitfireap Oct 15, 2023
95a0cac
Fixed capped default choice, removed old py2 code
Spitfireap Oct 15, 2023
ec7674b
small fix
Spitfireap Oct 15, 2023
43d8b19
small fix part 2
Spitfireap Oct 15, 2023
1ae8671
Bug fix
Spitfireap Oct 15, 2023
08f71fb
small fix part 3
Spitfireap Oct 15, 2023
7cec24f
small fix part 4
Spitfireap Oct 15, 2023
1e36d14
added sieve rule to move spam to junk folder
Spitfireap Jan 12, 2024
c5b3a25
Made 90-sieve a template
Spitfireap Jan 12, 2024
c98e6cd
Made junk sieve optional
Spitfireap Jan 12, 2024
a6cc0ca
create sieve dir if needed
Spitfireap Jan 12, 2024
c9c4caf
Fixed file copy issue
tonioo Feb 23, 2024
fb9f854
Update after rebase
Spitfireap Oct 3, 2024
58047d3
imported checks
Spitfireap Oct 31, 2024
12b5397
fix import
Spitfireap Oct 31, 2024
321219d
imported arguments
Spitfireap Oct 31, 2024
7ea73ba
Fixed indentation
Spitfireap Oct 31, 2024
8e14bf7
Fixed dovecot
Spitfireap Oct 31, 2024
f6c6c3e
Fixed dovecot #2
Spitfireap Oct 31, 2024
1161cbd
Added rspamd dashboard info
Spitfireap Oct 31, 2024
3fa0c37
Added Arc signing
Spitfireap Oct 31, 2024
53d98bd
Updated ARC
Spitfireap Dec 18, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -58,3 +58,8 @@ target/

# PyCharm
.idea/

#KDE
*.kdev4

installer.cfg
2 changes: 1 addition & 1 deletion checks.py → modoboa_installer/checks.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def check_version():
"Check README file for instructions about how to update.\n"
"No support will be provided without an up-to-date installer!"
)
answer = utils.user_input("Continue anyway? (Y/n) ")
answer = utils.user_input("Continue anyway? (y/N) ")
if not answer.lower().startswith("y"):
sys.exit(0)
else:
Expand Down
7 changes: 7 additions & 0 deletions modoboa_installer/compatibility_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,10 @@
"modoboa-sievefilters": "2.3.0",
"modoboa-postfix-autoreply": "2.3.0"
}

APP_INCOMPATIBILITY = {
"opendkim": ["rspamd"],
"amavis": ["rspamd"],
"postwhite": ["rspamd"],
"spamassassin": ["rspamd"]
}
102 changes: 91 additions & 11 deletions modoboa_installer/config_dict_template.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,26 @@ def is_email(user_input):
}
]
},
{
"name": "antispam",
"values": [
{
"option": "enabled",
"default": "true",
"customizable": True,
"values": ["true", "false"],
"question": "Do you want to setup an antispam utility?"
},
{
"option": "type",
"default": "rspamd",
"customizable": True,
"question": "Please select your antispam utility",
"values": ["rspamd", "amavis"],
"if": ["antispam.enabled=true"]
}
]
},
{
"name": "certificate",
"values": [
Expand All @@ -50,7 +70,7 @@ def is_email(user_input):
},
{
"name": "letsencrypt",
"if": "certificate.type=letsencrypt",
"if": ["certificate.type=letsencrypt"],
"values": [
{
"option": "email",
Expand Down Expand Up @@ -85,7 +105,7 @@ def is_email(user_input):
},
{
"name": "postgres",
"if": "database.engine=postgres",
"if": ["database.engine=postgres"],
"values": [
{
"option": "user",
Expand All @@ -101,7 +121,7 @@ def is_email(user_input):
},
{
"name": "mysql",
"if": "database.engine=mysql",
"if": ["database.engine=mysql"],
"values": [
{
"option": "user",
Expand Down Expand Up @@ -185,10 +205,18 @@ def is_email(user_input):
"customizable": True,
"question": "Please enter Modoboa db password",
},
{
"option": "cron_error_recipient",
"default": "root",
"customizable": True,
"question":
"Please enter a mail recipient for cron error reports"
},
{
"option": "extensions",
"default": (
"modoboa-amavis "
"modoboa-rspamd "
"modoboa-webmail modoboa-contacts "
"modoboa-radicale"
),
Expand Down Expand Up @@ -229,12 +257,60 @@ def is_email(user_input):
]
},
{
"name": "amavis",
"name": "rspamd",
"if": ["antispam.enabled=true", "antispam.type=rspamd"],
"values": [
{
"option": "enabled",
"default": ["antispam.enabled=true", "antispam.type=rspamd"],
},
{
"option": "user",
"default": "_rspamd",
},
{
"option": "password",
"default": make_password,
"customizable": True,
"question": "Please enter Rspamd interface password",
},
{
"option": "dnsbl",
"default": "true",
},
{
"option": "dkim_keys_storage_dir",
"default": "/var/lib/dkim"
},
{
"option": "key_map_path",
"default": "/var/lib/dkim/keys.path.map"
},
{
"option": "selector_map_path",
"default": "/var/lib/dkim/selectors.path.map"
},
{
"option": "greylisting",
"default": "true"
},
{
"option": "whitelist_auth",
"default": "true"
},
{
"option": "whitelist_auth_weigth",
"default": "-5"
}
],
},
{
"name": "amavis",
"values": [
{
"option": "enabled",
"default": ["antispam.enabled=true", "antispam.type=amavis"],
},
{
"option": "user",
"default": "amavis",
Expand All @@ -254,8 +330,6 @@ def is_email(user_input):
{
"option": "dbpassword",
"default": make_password,
"customizable": True,
"question": "Please enter amavis db password"
},
],
},
Expand Down Expand Up @@ -305,7 +379,11 @@ def is_email(user_input):
},
{
"option": "radicale_auth_socket_path",
"default": "/var/run/dovecot/auth-radicale"
"default": "/var/run/dovecot/auth-radicale",
},
{
"option": "move_spam_to_junk",
"default": "true",
},
]
},
Expand All @@ -327,7 +405,7 @@ def is_email(user_input):
"values": [
{
"option": "enabled",
"default": "true",
"default": "false",
},
{
"option": "config_dir",
Expand Down Expand Up @@ -361,7 +439,7 @@ def is_email(user_input):
"values": [
{
"option": "enabled",
"default": "true",
"default": ["antispam.enabled=true", "antispam.type=amavis"],
},
{
"option": "config_dir",
Expand All @@ -371,10 +449,11 @@ def is_email(user_input):
},
{
"name": "spamassassin",
"if": ["antispam.enabled=true", "antispam.type=amavis"],
"values": [
{
"option": "enabled",
"default": "true",
"default": ["antispam.enabled=true", "antispam.type=amavis"],
},
{
"option": "config_dir",
Expand Down Expand Up @@ -440,10 +519,11 @@ def is_email(user_input):
},
{
"name": "opendkim",
"if": ["antispam.enabled=true", "antispam.type=amavis"],
"values": [
{
"option": "enabled",
"default": "true",
"default": ["antispam.enabled=true", "antispam.type=amavis"],
},
{
"option": "user",
Expand Down
51 changes: 51 additions & 0 deletions modoboa_installer/disclaimers.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
from . import utils


def installation_disclaimer(args, config):
"""Display installation disclaimer."""
hostname = config.get("general", "hostname")
utils.printcolor(
"Notice:\n"
"It is recommanded to run this installer on a FRESHLY installed server.\n"
"(ie. with nothing special already installed on it)\n",
utils.CYAN
)
utils.printcolor(
"Warning:\n"
"Before you start the installation, please make sure the following "
"DNS records exist for domain '{}':\n"
" {} IN A <IP ADDRESS OF YOUR SERVER>\n"
" @ IN MX {}.\n".format(
args.domain,
hostname.replace(".{}".format(args.domain), ""),
hostname
),
utils.YELLOW
)
utils.printcolor(
"Your mail server will be installed with the following components:",
utils.BLUE)


def upgrade_disclaimer(config):
"""Display upgrade disclaimer."""
utils.printcolor(
"Your mail server is about to be upgraded and the following components"
" will be impacted:", utils.BLUE
)


def backup_disclaimer():
"""Display backup disclamer. """
utils.printcolor(
"Your mail server will be backed up locally.\n"
" !! You should really transfer the backup somewhere else...\n"
" !! Custom configuration (like for postfix) won't be saved.", utils.BLUE)


def restore_disclaimer():
"""Display restore disclamer. """
utils.printcolor(
"You are about to restore a previous installation of Modoboa.\n"
"If a new version has been released in between, please update your database!",
utils.BLUE)
29 changes: 27 additions & 2 deletions modoboa_installer/package.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

import re

from os.path import isfile as file_exists

from . import utils


Expand Down Expand Up @@ -49,7 +51,30 @@ def prepare_system(self):
def restore_system(self):
utils.exec_cmd("rm -f {}".format(self.policy_file))

def update(self, force=False):
def add_custom_repository(self,
name: str,
url: str,
key_url: str,
codename: str,
with_source: bool = True):
key_file = f"/etc/apt/keyrings/{name}.gpg"
utils.exec_cmd(
f"wget -O - {key_url} | gpg --dearmor | tee {key_file} > /dev/null"
)
line_types = ["deb"]
if with_source:
line_types.append("deb-src")
for line_type in line_types:
line = (
f"{line_type} [arch=amd64 signed-by={key_file}] "
f"{url} {codename} main"
)
target_file = f"/etc/apt/sources.list.d/{name}.list"
tee_option = "-a" if file_exists(target_file) else ""
utils.exec_cmd(f'echo "{line}" | tee {tee_option} {target_file}')
self.index_updated = False

def update(self):
"""Update local cache."""
if self.index_updated and not force:
return
Expand Down Expand Up @@ -89,7 +114,7 @@ class RPMPackage(Package):

def __init__(self, dist_name):
"""Initialize backend."""
super(RPMPackage, self).__init__(dist_name)
super().__init__(dist_name)
if "centos" in dist_name:
self.install("epel-release")

Expand Down
7 changes: 4 additions & 3 deletions modoboa_installer/scripts/clamav.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,10 @@ def post_run(self):
"""Additional tasks."""
if package.backend.FORMAT == "deb":
user = self.config.get(self.appname, "user")
system.add_user_to_group(
user, self.config.get("amavis", "user")
)
if self.config.get("amavis", "enabled").lower() == "true":
system.add_user_to_group(
user, self.config.get("amavis", "user")
)
pattern = (
"s/^AllowSupplementaryGroups false/"
"AllowSupplementaryGroups true/")
Expand Down
Loading
Loading