Added support to delete webapps
This commit is contained in:
parent
25aaa0a4bf
commit
4f7d88f995
4 changed files with 288 additions and 1 deletions
60
scripts/webapps/delete_app_apache.py
Normal file
60
scripts/webapps/delete_app_apache.py
Normal file
|
|
@ -0,0 +1,60 @@
|
|||
#!/usr/bin/python3 -u
|
||||
|
||||
import argparse
|
||||
import os
|
||||
#from pastafariutils.unix import add_user, del_user
|
||||
from pathlib import Path
|
||||
from subprocess import call, DEVNULL
|
||||
import json
|
||||
import time
|
||||
import shutil
|
||||
import pwd
|
||||
import distro
|
||||
import subprocess
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
parser=argparse.ArgumentParser(prog='delete_wordpress.py', description='A tool for delete wordpress')
|
||||
|
||||
parser.add_argument('--domain', help='Domain to delete', required=True)
|
||||
parser.add_argument('--webapp', help='Webapp config to delete', required=True)
|
||||
|
||||
args=parser.parse_args()
|
||||
|
||||
apache_cmd='apache2'
|
||||
|
||||
apachectl='apache2ctl'
|
||||
|
||||
linux_distro=distro.id()
|
||||
|
||||
if linux_distro!='debian' and linux_distro!='ubuntu':
|
||||
apache_cmd='httpd'
|
||||
apachectl='apachectl'
|
||||
|
||||
print('Deleting the apache configuration of webapp..')
|
||||
|
||||
# /etc/httpd/vhosts.d/php/prueba.cuchulu.com-php.conf
|
||||
"""
|
||||
apache_php='/etc/{}/vhosts.d/php/{}-php.conf'.format(apache_cmd, args.domain)
|
||||
|
||||
if os.path.isfile(apache_php):
|
||||
if subprocess.call("sudo rm %s" % (apache_php), shell=True) > 0:
|
||||
print('Error: cannot delete php config %s' % apache_php)
|
||||
sys.exit(1)
|
||||
"""
|
||||
|
||||
# /etc/httpd/vhosts.d/extra/prueba.cuchulu.com-wordpress.conf
|
||||
|
||||
apache_webapp='/etc/{}/vhosts.d/extra/{}-{}.conf'.format(apache_cmd, args.domain, args.webapp)
|
||||
|
||||
if os.path.isfile(apache_webapp):
|
||||
if subprocess.call("sudo rm %s" % (apache_webapp), shell=True) > 0:
|
||||
print('Error: cannot delete webapp config %s' % apache_webapp)
|
||||
sys.exit(1)
|
||||
|
||||
if subprocess.call("sudo systemctl restart %s" % (apache_cmd), shell=True) > 0:
|
||||
print('Error: cannot restart Apache server')
|
||||
sys.exit(1)
|
||||
|
||||
print('Deleted the apache configuration of webapp successfully..')
|
||||
Loading…
Add table
Add a link
Reference in a new issue