From 4e2b648e7213e1bcf7206200683f472213a56521 Mon Sep 17 00:00:00 2001 From: Kloadut Date: Sun, 28 Oct 2012 15:24:10 +0100 Subject: [PATCH] le sexy time --- parse_args | 2 ++ yunohost_tools.py | 41 ++++++++++++++++++++++------------------- yunohost_user.py | 2 +- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/parse_args b/parse_args index 67e46b67..5d7746a7 100755 --- a/parse_args +++ b/parse_args @@ -123,6 +123,8 @@ def main(): display_error(error) return error.code else: + if result is None: + result = { 'Notice' : 'No result returned' } if os.isatty(1): pretty_print_dict(result) else: diff --git a/yunohost_tools.py b/yunohost_tools.py index 60ce5b54..1c971b77 100644 --- a/yunohost_tools.py +++ b/yunohost_tools.py @@ -130,25 +130,28 @@ def tools_maindomain(args): # Regenerate certificate tmp = '/usr/share/yunohost/yunohost-config' - os.system('echo "01" > '+ tmp +'/ssl/yunoCA/serial') - os.system('rm '+ tmp +'/ssl/yunoCA/index.txt') - os.system('touch '+ tmp +'/ssl/yunoCA/index.txt') - os.system('sed -i "s/' + args['old_domain'] + '/' + args['new_domain'] + '/g" '+ tmp +'/ssl/yunoCA/openssl.cnf') - os.system('openssl req -x509 -new -config '+ tmp +'/ssl/yunoCA/openssl.cnf -days 3650 -out '+ tmp +'/ssl/yunoCA/ca/cacert.pem -keyout '+ tmp +'/ssl/yunoCA/ca/cakey.pem -nodes -batch') - os.system('openssl req -new -config '+ tmp +'/ssl/yunoCA/openssl.cnf -days 730 -out '+ tmp +'/ssl/yunoCA/certs/yunohost_csr.pem -keyout '+ tmp +'/ssl/yunoCA/certs/yunohost_key.pem -nodes -batch') - os.system('openssl ca -config '+ tmp +'/ssl/yunoCA/openssl.cnf -days 730 -in '+ tmp +'/ssl/yunoCA/certs/yunohost_csr.pem -out '+ tmp +'/ssl/yunoCA/certs/yunohost_crt.pem -batch') - os.system('cp '+ tmp +'/ssl/yunoCA/ca/cacert.pem /etc/ssl/certs/ca-yunohost_crt.pem') - os.system('cp '+ tmp +'/ssl/yunoCA/certs/yunohost_key.pem /etc/ssl/private/') - os.system('cp '+ tmp +'/ssl/yunoCA/newcerts/01.pem /etc/ssl/certs/yunohost_crt.pem') - os.system('cp '+ tmp +'/ssl/yunoCA/newcerts/01.pem /etc/ejabberd/ejabberd.pem') - os.system('echo '+ args['new_domain'] +' > /usr/share/yunohost/yunohost-config/others/current_host') + a = os.system('echo "01" > '+ tmp +'/ssl/yunoCA/serial') + b = os.system('rm '+ tmp +'/ssl/yunoCA/index.txt') + c = os.system('touch '+ tmp +'/ssl/yunoCA/index.txt') + d = os.system('sed -i "s/' + args['old_domain'] + '/' + args['new_domain'] + '/g" '+ tmp +'/ssl/yunoCA/openssl.cnf') + e = os.system('openssl req -x509 -new -config '+ tmp +'/ssl/yunoCA/openssl.cnf -days 3650 -out '+ tmp +'/ssl/yunoCA/ca/cacert.pem -keyout '+ tmp +'/ssl/yunoCA/ca/cakey.pem -nodes -batch') + f = os.system('openssl req -new -config '+ tmp +'/ssl/yunoCA/openssl.cnf -days 730 -out '+ tmp +'/ssl/yunoCA/certs/yunohost_csr.pem -keyout '+ tmp +'/ssl/yunoCA/certs/yunohost_key.pem -nodes -batch') + g = os.system('openssl ca -config '+ tmp +'/ssl/yunoCA/openssl.cnf -days 730 -in '+ tmp +'/ssl/yunoCA/certs/yunohost_csr.pem -out '+ tmp +'/ssl/yunoCA/certs/yunohost_crt.pem -batch') + h = os.system('cp '+ tmp +'/ssl/yunoCA/ca/cacert.pem /etc/ssl/certs/ca-yunohost_crt.pem') + i = os.system('cp '+ tmp +'/ssl/yunoCA/certs/yunohost_key.pem /etc/ssl/private/') + j = os.system('cp '+ tmp +'/ssl/yunoCA/newcerts/01.pem /etc/ssl/certs/yunohost_crt.pem') + k = os.system('cp '+ tmp +'/ssl/yunoCA/newcerts/01.pem /etc/ejabberd/ejabberd.pem') + l = os.system('echo '+ args['new_domain'] +' > /usr/share/yunohost/yunohost-config/others/current_host') # Restart services - os.system('/etc/init.d/apache2 restart') - os.system('/etc/init.d/postfix restart') - os.system('/etc/init.d/ejabberd restart') + m = os.system('/etc/init.d/apache2 restart') + n = os.system('/etc/init.d/postfix restart') + o = os.system('/etc/init.d/ejabberd restart') - return { 'Success' : _("YunoHost main domain has been successfully changed") } + if a == b == c == d == e == f == g == h == i == j == k == l == m == n == o: + return { 'Success' : _("YunoHost main domain has been successfully changed") } + else: + return { 'Error' : _("There were a problem during domain changing") } def tools_postinstall(args, connections): @@ -172,15 +175,15 @@ def tools_postinstall(args, connections): args = get_required_args(args, {'domain' : _('Main domain name'), 'password' : _('New admin password') }, True) + # New domain config + tools_maindomain({ 'old_domain' : 'yunohost.org', 'new_domain' : args['domain']}) + # Initialize YunoHost LDAP base tools_ldapinit(args, connections) # Change LDAP admin password tools_adminpw({ 'old' : 'yunohost', 'new' : args['password']}) - # New domain config - tools_maindomain({ 'old_domain' : 'yunohost.org', 'new_domain' : args['domain']}) - os.system('touch /usr/share/yunohost/yunohost-config/others/installed') return { 'Success' : _("YunoHost has been successfully configured") } diff --git a/yunohost_user.py b/yunohost_user.py index c5b2be68..cede6745 100644 --- a/yunohost_user.py +++ b/yunohost_user.py @@ -80,7 +80,7 @@ def user_create(args, connections): 'gidNumber' : uid, 'uidNumber' : uid, 'homeDirectory' : '/home/' + args['username'], - 'loginShell' : '/bin/bash' + 'loginShell' : '/bin/false' } if yldap.add(rdn, attr_dict):