mirror of
https://github.com/YunoHost/yunohost.git
synced 2024-09-03 20:06:10 +02:00
Be more robust against re-running the migration
This commit is contained in:
parent
aae7c6e296
commit
72e4a584ed
1 changed files with 20 additions and 14 deletions
|
@ -30,12 +30,18 @@ class MyMigration(Migration):
|
||||||
from yunohost.utils.ldap import _get_ldap_interface
|
from yunohost.utils.ldap import _get_ldap_interface
|
||||||
ldap = _get_ldap_interface()
|
ldap = _get_ldap_interface()
|
||||||
|
|
||||||
|
existing_perms_raw = ldap.search("ou=permission,dc=yunohost,dc=org", "(objectclass=permissionYnh)", ["cn"])
|
||||||
|
existing_perms = [perm['cn'][0] for perm in existing_perms_raw]
|
||||||
|
|
||||||
# Add SSH and SFTP permissions
|
# Add SSH and SFTP permissions
|
||||||
ldap_map = read_yaml('/usr/share/yunohost/yunohost-config/moulinette/ldap_scheme.yml')
|
ldap_map = read_yaml('/usr/share/yunohost/yunohost-config/moulinette/ldap_scheme.yml')
|
||||||
|
|
||||||
ldap.add("cn=ssh.main,ou=permission", ldap_map['depends_children']["cn=ssh.main,ou=permission"])
|
if "sftp.main" not in existing_perms:
|
||||||
ldap.add("cn=sftp.main,ou=permission", ldap_map['depends_children']["cn=sftp.main,ou=permission"])
|
ldap.add("cn=sftp.main,ou=permission", ldap_map['depends_children']["cn=sftp.main,ou=permission"])
|
||||||
|
|
||||||
|
if "ssh.main" not in existing_perms:
|
||||||
|
ldap.add("cn=ssh.main,ou=permission", ldap_map['depends_children']["cn=ssh.main,ou=permission"])
|
||||||
|
|
||||||
# Add a bash terminal to each users
|
# Add a bash terminal to each users
|
||||||
users = ldap.search('ou=users,dc=yunohost,dc=org', filter="(loginShell=*)", attrs=["dn", "uid", "loginShell"])
|
users = ldap.search('ou=users,dc=yunohost,dc=org', filter="(loginShell=*)", attrs=["dn", "uid", "loginShell"])
|
||||||
for user in users:
|
for user in users:
|
||||||
|
|
Loading…
Add table
Reference in a new issue