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