Fixed new source bug, removed bionic, added dynamic defaults
This commit is contained in:
@@ -253,10 +253,11 @@ ConfigDictTemplate = [
|
||||
},
|
||||
{
|
||||
"name": "rspamd",
|
||||
"if": ["antispam.enabled=true", "antispam.type=amavis"],
|
||||
"values": [
|
||||
{
|
||||
"option": "enabled",
|
||||
"default": "true",
|
||||
"default": ["antispam.enabled=true", "antispam.type=amavis"],
|
||||
},
|
||||
{
|
||||
"option": "user",
|
||||
@@ -265,6 +266,8 @@ ConfigDictTemplate = [
|
||||
{
|
||||
"option": "password",
|
||||
"default": make_password,
|
||||
"customizable": True,
|
||||
"question": "Please enter Rspamd interface password",
|
||||
},
|
||||
{
|
||||
"option": "dnsbl",
|
||||
@@ -298,12 +301,10 @@ ConfigDictTemplate = [
|
||||
},
|
||||
{
|
||||
"name": "amavis",
|
||||
"if": ["antispam.enabled=true", "antispam.type=amavis"],
|
||||
"values": [
|
||||
{
|
||||
"option": "enabled",
|
||||
"default-if": "true",
|
||||
"default": "false",
|
||||
"default": ["antispam.enabled=true", "antispam.type=amavis"],
|
||||
},
|
||||
{
|
||||
"option": "user",
|
||||
@@ -422,12 +423,10 @@ ConfigDictTemplate = [
|
||||
},
|
||||
{
|
||||
"name": "postwhite",
|
||||
"if": ["antispam.enabled=true", "antispam.type=amavis"],
|
||||
"values": [
|
||||
{
|
||||
"option": "enabled",
|
||||
"default-if": "true",
|
||||
"default": "false",
|
||||
"default": ["antispam.enabled=true", "antispam.type=amavis"],
|
||||
},
|
||||
{
|
||||
"option": "config_dir",
|
||||
@@ -441,8 +440,7 @@ ConfigDictTemplate = [
|
||||
"values": [
|
||||
{
|
||||
"option": "enabled",
|
||||
"default-if": "true",
|
||||
"default": "false",
|
||||
"default": ["antispam.enabled=true", "antispam.type=amavis"],
|
||||
},
|
||||
{
|
||||
"option": "config_dir",
|
||||
@@ -512,8 +510,7 @@ ConfigDictTemplate = [
|
||||
"values": [
|
||||
{
|
||||
"option": "enabled",
|
||||
"default-if": "true",
|
||||
"default": "false",
|
||||
"default": ["antispam.enabled=true", "antispam.type=amavis"],
|
||||
},
|
||||
{
|
||||
"option": "user",
|
||||
|
||||
@@ -57,7 +57,7 @@ class DEBPackage(Package):
|
||||
with_source: bool = True):
|
||||
key_file = f"/etc/apt/keyrings/{name}.gpg"
|
||||
utils.exec_cmd(
|
||||
f"wget -O - {key_url} | gpg --dearmor | sudo tee {key_file} > /dev/null"
|
||||
f"wget -O - {key_url} | gpg --dearmor | tee {key_file} > /dev/null"
|
||||
)
|
||||
line_types = ["deb"]
|
||||
if with_source:
|
||||
|
||||
@@ -46,10 +46,6 @@ class Rspamd(base.Installer):
|
||||
0, 0
|
||||
)
|
||||
|
||||
if codename == "bionic":
|
||||
package.backend.install("software-properties-common")
|
||||
utils.exec_cmd("add-apt-repository ppa:ubuntu-toolchain-r/test")
|
||||
|
||||
package.backend.add_custom_repository(
|
||||
"rspamd",
|
||||
"http://rspamd.com/apt-stable/",
|
||||
|
||||
@@ -323,18 +323,14 @@ def validate(value, config_entry):
|
||||
return True
|
||||
|
||||
|
||||
def get_entry_value(entry, interactive):
|
||||
if entry.get("default-if") is not None and interactive:
|
||||
# In case in interactive we try to look for a default-if
|
||||
default_entry = entry["default-if"]
|
||||
else:
|
||||
default_entry = entry["default"]
|
||||
|
||||
def get_entry_value(entry, interactive, config):
|
||||
default_entry = entry("default")
|
||||
if type(default_entry) is type(list()):
|
||||
default_value = check_if_condition(config, default_entry)
|
||||
if callable(default_entry):
|
||||
default_value = default_entry()
|
||||
default_value = entry["default"]()
|
||||
else:
|
||||
default_value = default_entry
|
||||
|
||||
user_value = None
|
||||
if entry.get("customizable") and interactive:
|
||||
while (user_value != '' and not validate(user_value, entry)):
|
||||
@@ -384,7 +380,8 @@ def load_config_template(interactive):
|
||||
)
|
||||
)
|
||||
value = get_entry_value(config_entry,
|
||||
interactive_section)
|
||||
interactive_section,
|
||||
config)
|
||||
config.set(section["name"], config_entry["option"], value)
|
||||
return config
|
||||
|
||||
@@ -550,7 +547,7 @@ def check_app_compatibility(section, config):
|
||||
if section in APP_INCOMPATIBILITY.keys():
|
||||
for app in APP_INCOMPATIBILITY[section]:
|
||||
if config.getboolean(app, "enabled"):
|
||||
error(f"{section} cannont be installed if {app} is enabled. "
|
||||
error(f"{section} cannot be installed if {app} is enabled. "
|
||||
"Please disable one of them.")
|
||||
incompatible_app.append(app)
|
||||
return len(incompatible_app) == 0
|
||||
|
||||
Reference in New Issue
Block a user