letsencrypt: Drop old app migration code

- In version 23.6.2 (Debian Bookworm), the migration code is already present.
This means all users on bookworm would have migrated already. We don't have
support users upgrading directly from a version older than bookworm.

Tests:

- First setup works as expected when starting the service on a fresh container.

Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org>
Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
Sunil Mohan Adapa 2025-05-15 13:45:23 -07:00 committed by James Valleroy
parent 3b1eba216a
commit 15f71fe7e0
No known key found for this signature in database
GPG Key ID: 77C0C75E7B650808
2 changed files with 0 additions and 68 deletions

View File

@ -126,11 +126,6 @@ class LetsEncryptApp(app_module.App):
return super().repair(remaining_checks)
def setup(self, old_version):
"""Install and configure the app."""
super().setup(old_version)
privileged.setup(old_version)
def certificate_obtain(domain):
"""Obtain a certificate for a domain and notify handlers."""

View File

@ -13,8 +13,6 @@ import subprocess
import sys
from typing import Any
import configobj
from plinth import action_utils
from plinth import app as app_module
from plinth import module_loader
@ -24,7 +22,6 @@ from plinth.modules import letsencrypt as le
TEST_MODE = False
LE_DIRECTORY = '/etc/letsencrypt/'
ETC_SSL_DIRECTORY = '/etc/ssl/'
RENEWAL_DIRECTORY = '/etc/letsencrypt/renewal/'
AUTHENTICATOR = 'webroot'
WEB_ROOT_PATH = '/var/www/html'
APACHE_PREFIX = '/etc/apache2/sites-available/'
@ -97,25 +94,6 @@ def _get_status() -> dict[str, Any]:
return domain_status
@privileged
def setup(old_version: int):
"""Upgrade old site configuration to new macro based style.
Nothing to do for first time setup and for newer versions.
"""
if old_version == 2:
_remove_old_hooks()
return
if old_version != 1:
return
domain_status = _get_status()
with action_utils.WebserverChange() as webserver_change:
for domain in domain_status:
_setup_webserver_config(domain, webserver_change)
@privileged
def get_status() -> dict[str, dict]:
"""Return a dictionary of currently configured domains."""
@ -165,47 +143,6 @@ def obtain(domain: str):
_setup_webserver_config(domain, webserver_change)
def _remove_old_hooks():
"""Remove old style renewal hooks from individual configuration files.
This has been replaced with global hooks by adding script files in
directory /etc/letsencrypt/renewal-hooks/{pre,post,deploy}/.
"""
for file_path in glob.glob(RENEWAL_DIRECTORY + '*.conf'):
try:
_remove_old_hooks_from_file(file_path)
except Exception as exception:
print('Error removing hooks from file:', file_path, exception)
def _remove_old_hooks_from_file(file_path: str):
"""Remove old style hooks from a single configuration file."""
config = configobj.ConfigObj(file_path)
edited = False
for line in config.initial_comment:
if 'edited by plinth' in line.lower():
edited = True
if not edited:
return
config.initial_comment = [
line for line in config.initial_comment
if 'edited by plinth' not in line.lower()
]
if 'pre_hook' in config['renewalparams']:
del config['renewalparams']['pre_hook']
if 'renew_hook' in config['renewalparams']:
del config['renewalparams']['renew_hook']
if 'post_hook' in config['renewalparams']:
del config['renewalparams']['post_hook']
config.write()
@privileged
def copy_certificate(managing_app: str, source_private_key: str,
source_certificate: str, private_key: str,