No prompt at first install

This commit is contained in:
Kloadut 2012-10-29 16:25:40 +01:00
parent 88ccca8c89
commit 15207ecef5
3 changed files with 8 additions and 6 deletions

View file

@ -480,8 +480,6 @@ tools:
### tools_postinstall() ### tools_postinstall()
postinstall: postinstall:
action_help: YunoHost post-install action_help: YunoHost post-install
connections:
- ldap
arguments: arguments:
-d: -d:
full: --domain full: --domain

View file

@ -245,7 +245,7 @@ class YunoHostError(Exception):
class YunoHostLDAP: class YunoHostLDAP:
""" Specific LDAP functions for YunoHost """ """ Specific LDAP functions for YunoHost """
def __init__(self): def __init__(self, password=False):
""" """
Connect to LDAP base Connect to LDAP base
@ -254,7 +254,10 @@ class YunoHostLDAP:
""" """
self.conn = ldap.initialize('ldap://localhost:389') self.conn = ldap.initialize('ldap://localhost:389')
self.base = 'dc=yunohost,dc=org' self.base = 'dc=yunohost,dc=org'
self.pwd = getpass.getpass(colorize(_('LDAP Admin Password: '), 'yellow')) if password:
self.pwd = password
else:
self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow'))
try: try:
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd) self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
except ldap.INVALID_CREDENTIALS: except ldap.INVALID_CREDENTIALS:

View file

@ -5,7 +5,7 @@ import sys
import yaml import yaml
import re import re
import getpass import getpass
from yunohost import YunoHostError, validate, colorize, get_required_args, win_msg from yunohost import YunoHostError, YunoHostLDAP, validate, colorize, get_required_args, win_msg
def tools_ldapinit(args, connections): def tools_ldapinit(args, connections):
@ -154,7 +154,7 @@ def tools_maindomain(args):
raise YunoHostError(17, _("There were a problem during domain changing")) raise YunoHostError(17, _("There were a problem during domain changing"))
def tools_postinstall(args, connections): def tools_postinstall(args):
""" """
Post-install configuration Post-install configuration
@ -166,6 +166,7 @@ def tools_postinstall(args, connections):
dict dict
""" """
connections = { 'ldap' : YunoHostLDAP(password='yunohost') }
try: try:
with open('/usr/share/yunohost/yunohost-config/others/installed') as f: pass with open('/usr/share/yunohost/yunohost-config/others/installed') as f: pass
except IOError: except IOError: