Commit 2c9f5ede authored by root's avatar root

création de depo

[submodule "re2oapi"]
path = re2oapi
url =
#Re2o Home
This service uses Re2oApi to verify and create the home directory of the users following the structure:
\symlink to {pseudo}
\{pseudo initial}
## Requirements
* python3
* requirements in
hostname =
username = my_api_username
password = my_api_password
#!/usr/bin/env python3
from configparser import ConfigParser
import socket
from re2oapi import Re2oAPIClient
from django.core.mail import send_mail
from django.template import loader, Context
import os
import grp
config = ConfigParser()'config.ini')
api_hostname = config.get('Re2o', 'hostname')
api_password = config.get('Re2o', 'password')
api_username = config.get('Re2o', 'username')
api_client = Re2oAPIClient(api_hostname,api_username,api_password)
client_hostname = socket.gethostname().split('.',1)[0]
def reconfigure(api_client):
users = api_client.list("users/homecreation")
error = False
for user in users:
print('creation du home de {}'.format(user['pseudo']))
home = '/home-adh/{}/{}/'.format(user['pseudo'][0].lower(),user['pseudo'].lower())
uid = user['uid']
gid = user['gid']
if not os.path.exists(home): # Home dosen't exist, create it
# Mail
if not os.path.exists(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.makedirs('/home-adh/mail/' + user['pseudo'], 0o700)
os.chown('/home-adh/mail/' + user['pseudo'], int(uid), 8)
# Owncloud dans le home
if not os.path.exists(home + '/OwnCloud'):
os.makedirs(home + '/OwnCloud')
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)):
error = True
print("error: {}".format(error))
input("passer au suivant ?")
api_client.patch(service['home'], data={'need_regen': error}) # regen it if there is an error
re2oapi @ c3277c2e
Subproject commit c3277c2e6eb3a85e8580c906266cad46c4043677
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