Fixes in proxy virtualhost

This commit is contained in:
absurdo 2023-12-14 23:51:40 +01:00
parent b2b879c3f8
commit d3d041f569
9 changed files with 84 additions and 21 deletions

View file

@ -35,9 +35,11 @@ name_service=os.path.basename(home_user[:-1]).strip()
domain=os.path.basename(home_user[:-1].replace(name_service, '')[:-1]).strip()
if home_user.find('/htdocs/', -8)!=-1:
home_user=home_user.replace('htdocs', 'flask')
if name_service=='htdocs':
name_service='flask'
#home_user=home_user.replace('flask', 'htdocs')
#print(domain)
@ -45,7 +47,7 @@ if subprocess.call('sudo systemctl stop %s-%s.service && sudo rm /etc/systemd/sy
print('Error: cannot delete app service in systemd...')
sys.exit(1)
if subprocess.call("sudo su %s -s /bin/bash -c 'rm -f -r %s'" % (args.user, args.home_user), shell=True) > 0:
if subprocess.call("sudo su %s -s /bin/bash -c 'rm -f -r %s'" % (args.user, home_user), shell=True) > 0:
print('Error: cannot delete %s' % args.home_user)
sys.exit(1)

View file

@ -148,12 +148,14 @@ if subprocess.call("sudo su %s -s /bin/bash -c 'git clone %s %sapp && cd %sapp &
sys.exit(1)
if path=='/':
base_name_file='{}-001-{}.conf'.format(args.domain, name)
base_name_file='{}-{}.conf'.format(args.domain, name)
else:
base_name_file='{}-000-{}.conf'.format(args.domain, name)
base_name_file='{}-{}.conf'.format(args.domain, name)
name_file='/home/{}/{}'.format(system_user, base_name_file)
apache_path='/proxy'
with open(name_file, 'w') as f:
f.write("ProxyPreserveHost On\n")
@ -177,9 +179,12 @@ with open(name_file, 'w') as f:
f.write("ProxyPass !\n")
f.write("</Location>\n")
else:
apache_path=''
print('Updating apache configuration for flask outside of htdocs...')
if subprocess.call('sudo mv {} /etc/{}/vhosts.d/extra && sudo chown root:root /etc/{}/vhosts.d/extra/{}'.format(name_file, apache_cmd, apache_cmd, base_name_file), shell=True) > 0:
if subprocess.call('sudo mv {} /etc/{}/vhosts.d/extra{} && sudo chown root:root /etc/{}/vhosts.d/extra{}/{}'.format(name_file, apache_cmd, apache_path, apache_cmd, apache_path, base_name_file), shell=True) > 0:
print('Error')
sys.exit(1)