Commit 486f91d1 authored by Sunil Mohan Adapa's avatar Sunil Mohan Adapa Committed by Joseph Nuthalapati

letsencrypt: Remove old style hooks from all configuration files

Signed-off-by: Sunil Mohan Adapa's avatarSunil Mohan Adapa <>
Reviewed-by: Joseph Nuthalapati's avatarJoseph Nuthalapati <>
parent d8647aaf
......@@ -20,12 +20,15 @@ Configuration helper for Let's Encrypt.
import argparse
import glob
import json
import os
import re
import subprocess
import sys
import configobj
from plinth import action_utils
from plinth.modules import letsencrypt as le
......@@ -141,6 +144,10 @@ def subcommand_setup(arguments):
Nothing to do for first time setup and for newer versions.
if arguments.old_version == 2:
if arguments.old_version != 1:
......@@ -202,6 +209,48 @@ def subcommand_obtain(arguments):
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
for file_path in glob.glob(RENEWAL_DIRECTORY + '*.conf'):
except Exception as exception:
print('Error removing hooks from file:', file_path, exception)
def _remove_old_hooks_from_file(file_path):
"""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:
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']
def subcommand_run_pre_hooks(_):
"""Do nothing, kept for legacy LE configuration.
......@@ -33,7 +33,7 @@ from plinth.utils import format_lazy
from .manifest import backup
version = 2
version = 3
is_essential = True
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment