From 8231aa715cc7d003bca6e4fdab5038a13c837da9 Mon Sep 17 00:00:00 2001 From: Antonio de la Rosa Date: Thu, 5 Sep 2024 23:23:57 +0200 Subject: [PATCH] Fixes in apache --- scripts/install_apache.py | 6 +++++- scripts/manage_apache.py | 25 ++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 4 deletions(-) diff --git a/scripts/install_apache.py b/scripts/install_apache.py index 8414dd0..3b87f86 100644 --- a/scripts/install_apache.py +++ b/scripts/install_apache.py @@ -131,7 +131,11 @@ if linux_distro=='rocky' or linux_distro=='almalinux' or linux_distro=='fedora': # Copy file -linux.shell_command('sudo cp modules/apache/scripts/check_mod_md.py /usr/local/bin && sudo chmod 755 /usr/local/bin/check_mod_md.py') +#linux.shell_command('sudo cp modules/apache/scripts/check_mod_md.py /usr/local/bin && sudo chmod 755 /usr/local/bin/check_mod_md.py') + +# echo "0 0,12 * * * root /opt/certbot/bin/python -c 'import random; import time; time.sleep(random.random() * 3600)' && sudo certbot renew -q" | sudo tee -a /etc/cron.d/certbot > /dev/null + +#linux.shell_command('echo "* * * * * root python /usr/local/bin/check_mod_md.py" | sudo tee -a /etc/cron.d/mod_md > /dev/null') #Restart apache diff --git a/scripts/manage_apache.py b/scripts/manage_apache.py index daab3ac..4c62092 100644 --- a/scripts/manage_apache.py +++ b/scripts/manage_apache.py @@ -181,7 +181,7 @@ def manage(): SSLEngine on """ - + """ vhost_ssl=vhost_ssl.replace('$port', args.ssl_port) vhost_ssl=vhost_ssl.replace('$ip', args.ip) vhost_ssl=vhost_ssl.replace('$email', args.email) @@ -218,8 +218,8 @@ def manage(): json_return={'error':0, 'status': 0, 'progress': 100, 'no_progress':0, 'message': 'Creating SSL Cert with Letsencrypt using mod_md...'} print(json.dumps(json_return)) - """ + ssl_debug='' if debug: @@ -292,7 +292,7 @@ def manage(): vhost+="\n\n"+vhost_ssl pass - """ + if type_ssl==2: vhost_ssl=vhost_ssl.replace('$port', args.ssl_port) vhost_ssl=vhost_ssl.replace('$ip', args.ip) @@ -589,6 +589,25 @@ def manage(): print(json.dumps(json_return)) #time.sleep(1) + # Delete certbot certificate if exists + + #sudo /opt/certbot/bin/certbot delete --cert-name server1.yotex.net -n + + if call("sudo /opt/certbot/bin/certbot delete --cert-name {} -n".format(args.domain), shell=True) > 0: + json_return['error']=0 + json_return['status']=0 + json_return['progress']=100 + json_return['message']='I cannot delete the certificate, please, if exists, clean manually' + + print(json.dumps(json_return)) + else: + json_return['error']=0 + json_return['status']=0 + json_return['progress']=100 + json_return['message']='Cleaning certbot ssl certificate for the domain' + + print(json.dumps(json_return)) + # Delete root_dir if exists # Change effective uid