Maindomain NPZE's modifs

This commit is contained in:
Kload 2013-02-26 20:36:37 +01:00
parent 7f990425c0
commit f6979c0fac
2 changed files with 54 additions and 20 deletions

View file

@ -5,6 +5,7 @@ import sys
import json import json
import shutil import shutil
import stat import stat
import yaml
from yunohost import YunoHostError, YunoHostLDAP, win_msg, random_password from yunohost import YunoHostError, YunoHostLDAP, win_msg, random_password
from yunohost_domain import domain_list, domain_add from yunohost_domain import domain_list, domain_add
@ -200,7 +201,18 @@ def app_install(app, domain, path='/', label=None, public=False, protected=True)
# TODO: Create appsettings and chmod it # TODO: Create appsettings and chmod it
# TODO: Remove scripts folder and /tmp files #yaml_dict = {
#'uid' : manifest['yunohost']['uid'],
#'name': manifest['Name'],
#'public': public,
#'protected': protected,
#'domain': domain,
#'path': path
#}
#yaml.dump(yaml_dict, f, default_flow_style=False)
## TODO: Remove scripts folder and /tmp files
def _extract_app_tarball(path): def _extract_app_tarball(path):

View file

@ -114,6 +114,28 @@ def tools_maindomain(old_domain, new_domain):
for line in lines: for line in lines:
sources.write(re.sub(r''+ old_domain +'', new_domain, line)) sources.write(re.sub(r''+ old_domain +'', new_domain, line))
lemon_tmp_conf = '/tmp/tmplemonconf'
if os.path.exists(lemon_tmp_conf): os.remove(lemon_tmp_conf)
lemon_conf_lines = [
"delete $tmp->{'locationRules'}->{'"+ old_domain +"'}->{'^/sso/'};", # Remove SSO access rule from old domain
"$tmp->{'domain'} = '"+ old_domain +"';", # Replace Lemon domain
"$tmp->{'ldapBase'} = 'dc=yunohost,dc=org';", # Set ldap basedn
"$tmp->{'portal'} = 'https://"+ new_domain +"/sso/';", # Set SSO url
"$tmp->{'locationRules'}->{'"+ new_domain +"'}->{'^/sso/'} = 'unprotect';" # Add SSO access rule to new domain
]
with open(lemon_tmp_conf,'a') as lemon_conf:
for line in lemon_conf_lines:
lemon_conf.write(line + '\n')
with open(lemon_tmp_conf,'a') as lemonscript:
# remove SSO apache conf dir from old domain conf
os.system('rm /etc/yunohost/apache/domains/' + old_domain + '.d/*.sso.conf')
# add SSO apache conf dir to new domain conf
os.system('cp /etc/yunohost/apache/templates/fixed.sso.conf /etc/yunohost/apache/domains/' + new_domain + '.d/fixed.sso.conf')
os.system('/etc/init.d/hostname.sh') os.system('/etc/init.d/hostname.sh')
# Regenerate certificate # Regenerate certificate