mirror of
https://github.com/YunoHost/moulinette.git
synced 2024-09-03 20:06:31 +02:00
fix postinstall
This commit is contained in:
parent
c16c9160b3
commit
8ca9f69691
2 changed files with 33 additions and 30 deletions
30
yunohost.py
30
yunohost.py
|
@ -106,7 +106,7 @@ def win_msg(astr):
|
|||
global win
|
||||
if os.isatty(1):
|
||||
print('\n' + colorize(_("Success: "), 'green') + astr + '\n')
|
||||
|
||||
|
||||
win.append(astr)
|
||||
|
||||
|
||||
|
@ -277,18 +277,22 @@ class YunoHostLDAP(Singleton):
|
|||
elif self.pwd:
|
||||
pass
|
||||
else:
|
||||
need_password = True
|
||||
while need_password:
|
||||
try:
|
||||
self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow'))
|
||||
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
|
||||
except KeyboardInterrupt, EOFError:
|
||||
raise YunoHostError(125, _("Interrupted"))
|
||||
except ldap.INVALID_CREDENTIALS:
|
||||
print(_('Invalid password... Try again'))
|
||||
else:
|
||||
need_password = False
|
||||
|
||||
try:
|
||||
with open('/etc/yunohost/passwd') as f:
|
||||
self.pwd = f.read()
|
||||
except IOError:
|
||||
need_password = True
|
||||
while need_password:
|
||||
try:
|
||||
self.pwd = getpass.getpass(colorize(_('Admin Password: '), 'yellow'))
|
||||
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
|
||||
except KeyboardInterrupt, EOFError:
|
||||
raise YunoHostError(125, _("Interrupted"))
|
||||
except ldap.INVALID_CREDENTIALS:
|
||||
print(_('Invalid password... Try again'))
|
||||
else:
|
||||
need_password = False
|
||||
|
||||
try:
|
||||
self.conn.simple_bind_s('cn=admin,' + self.base, self.pwd)
|
||||
self.connected = True
|
||||
|
|
33
yunohost.tac
33
yunohost.tac
|
@ -112,24 +112,23 @@ def http_exec(request, **kwargs):
|
|||
raise YunoHostError(168, _('Function not yet implemented : ') + dict['function'].split('.')[1])
|
||||
|
||||
# Execute requested function
|
||||
with YunoHostLDAP(password=request.getPassword()):
|
||||
try:
|
||||
with open('/var/run/yunohost.pid', 'r'):
|
||||
raise YunoHostError(1, _("A YunoHost command is already running"))
|
||||
except IOError:
|
||||
with open('/var/run/yunohost.pid', 'w') as f:
|
||||
f.write('ldap')
|
||||
os.system('chmod 400 /var/run/yunohost.pid')
|
||||
with open('/etc/yunohost/passwd', 'w') as f:
|
||||
f.write(request.getPassword())
|
||||
os.system('chmod 400 /etc/yunohost/passwd')
|
||||
try:
|
||||
with open('/var/run/yunohost.pid', 'r'):
|
||||
raise YunoHostError(1, _("A YunoHost command is already running"))
|
||||
except IOError:
|
||||
with open('/var/run/yunohost.pid', 'w') as f:
|
||||
f.write('ldap')
|
||||
os.system('chmod 400 /var/run/yunohost.pid')
|
||||
with open('/etc/yunohost/passwd', 'w') as f:
|
||||
f.write(request.getPassword())
|
||||
os.system('chmod 400 /etc/yunohost/passwd')
|
||||
try:
|
||||
result = func(**validated_args)
|
||||
except KeyboardInterrupt, EOFError:
|
||||
raise YunoHostError(125, _("Interrupted"))
|
||||
finally:
|
||||
os.remove('/etc/yunohost/passwd')
|
||||
os.remove('/var/run/yunohost.pid')
|
||||
result = func(**validated_args)
|
||||
except KeyboardInterrupt, EOFError:
|
||||
raise YunoHostError(125, _("Interrupted"))
|
||||
finally:
|
||||
os.remove('/etc/yunohost/passwd')
|
||||
os.remove('/var/run/yunohost.pid')
|
||||
if result is None:
|
||||
result = {}
|
||||
if len(yunohost.win) > 0:
|
||||
|
|
Loading…
Add table
Reference in a new issue