fix: remove unsupported letsencrypt_dns plugin and clean up related data handling

This commit is contained in:
Théophile Diot 2024-11-15 13:55:25 +01:00
parent 23b7ef6ee1
commit 826631291f
No known key found for this signature in database
GPG key ID: FA995104A0BA376A
2 changed files with 12 additions and 0 deletions

View file

@ -625,6 +625,10 @@ class Database:
del old_data["bw_plugins"][i]
break
if plugin["id"] == "letsencrypt_dns":
self.logger.warning(f"Plugin {plugin['id']} is no longer supported in 1.6.X versions, skipping it")
continue
if old_data and plugin["id"] not in found_plugins:
self.logger.warning(f'{plugin.get("type", "core").title()} Plugin "{plugin["id"]}" does not exist, creating it')
@ -1220,6 +1224,12 @@ class Database:
external_column = getattr(row, "external", None)
row = {column: getattr(row, column) for column in Base.metadata.tables[table_name].columns.keys() if hasattr(row, column)}
# ? As the letsencrypt_dns plugin is no longer supported, we need to remove the data
if (table_name == "bw_plugins" and row["id"] == "letsencrypt_dns") or (
table_name in ("bw_settings", "bw_jobs", "bw_plugin_pages", "bw_cli_commands") and row["plugin_id"] == "letsencrypt_dns"
):
continue
# ? As the external column has been replaced by the type column, we need to update the data if the column exists
if table_name == "bw_plugins" and external_column is not None:
row["type"] = "external" if external_column else "core"

View file

@ -578,6 +578,8 @@ if __name__ == "__main__":
stop(1)
LOGGER.info("Backup completed successfully, if you want to restore the backup, you can find it in /var/lib/bunkerweb/upgrade_backups")
rmtree(join(sep, "etc", "bunkerweb", "pro", "plugins", "letsencrypt_dns"), ignore_errors=True)
if SCHEDULER.db.readonly:
LOGGER.warning("The database is read-only, no need to save the changes in the configuration as they will not be saved")
else: