Commit 8b42c957 authored by Charlie Jacomme's avatar Charlie Jacomme

bug fixes on symlink exist

parent 2d630364
......@@ -8,10 +8,9 @@ import os
import grp
import sys
path =(os.path.dirname(os.path.abspath(__file__)))
config = ConfigParser()
config.read(path+'/config.ini')
config.read('config.ini')
api_hostname = config.get('Re2o', 'hostname')
api_password = config.get('Re2o', 'password')
......@@ -29,7 +28,7 @@ def reconfigure(api_client):
for user in users:
print('creation du home de {}'.format(user['pseudo']))
home = '/home-adh/{}/{}/'.format(user['pseudo'][0].lower(),user['pseudo'].lower())
home = '/home-adh/{}/{}'.format(user['pseudo'][0].lower(),user['pseudo'].lower())
uid = user['uid']
gid = user['gid']
......@@ -38,25 +37,25 @@ def reconfigure(api_client):
os.chown(home,int(uid),int(gid))
# Mail
if not os.path.exists(home + '/Mail'):
if not(os.path.exists(home + '/Mail')) and not(os.path.islink(home + '/Mail')):
os.makedirs(home + '/Mail', 0o700)
os.chown(home + '/Mail', int(uid), int(gid))
if not os.path.exists('/home-adh/mail/' + user['pseudo']):
os.chown(home + '/Mail', int(uid), int(gid))
if not(os.path.exists('/home-adh/mail/' + user['pseudo'])) and not(os.path.islink(home + '/Mail')):
os.makedirs('/home-adh/mail/' + user['pseudo'], 0o700)
os.chown('/home-adh/mail/' + user['pseudo'], int(uid), 8)
os.chown('/home-adh/mail/' + user['pseudo'], int(uid), 8)
# Owncloud dans le home
if not os.path.exists(home + '/OwnCloud'):
if not(os.path.exists(home + '/OwnCloud')) and not(os.path.islink(home + '/Owncloud')):
os.makedirs(home + '/OwnCloud')
os.chown(home + '/OwnCloud',int(uid),grp.getgrnam('www-data').gr_gid)
os.chmod(home + '/OwnCloud', 0o770)
os.chown(home + '/OwnCloud',int(uid),grp.getgrnam('www-data').gr_gid)
os.chmod(home + '/OwnCloud', 0o770)
# Simlink
link = '/home-adh/{}'.format(user['pseudo'].lower())
if not os.path.islink(link):
os.symlink(home, link)
if not (os.path.exists(home+'/Mail') and os.path.exists(home+'OwnCloud') and os.path.islink(link)):
if not ((os.path.exists(home+'/Mail') or os.path.islink(home + '/Mail')) and (os.path.exists(home+'/OwnCloud') or os.path.islink(home + '/OwnCloud')) and os.path.islink(link)):
error = True
print("error: {}".format(error))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment