# -*- coding: utf-8 -*-
from setuphelpers import *

uninstallkey = ['']

def install():
    print('installing waptiut-pgina')
    install_exe_if_needed("pGinaSetup-3.1.8.0.exe",'/VERYSILENT /SUPPRESSMSGBOXES /NORESTART',key='',min_version='3.1.8.0')

    print('Copie du logo')
    copytree2(r'logo',r'C:\Program Files\pGina')

    print('Configuring pGina -> Activation,Desactivation des plugins')
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3',r'12FA152D-A2E3-4C8D-9535-5DCD49DFCB6D',10,type=REG_DWORD)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3',r'0f52390b-c781-43ae-bd62-553c77fa4cf7',14,type=REG_DWORD)

    print('Configuring pGina -> Ordre des plugins')
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3',r'IPluginAuthentification_Order',['0f52390b-c781-43ae-bd62-553c77fa4cf7','12fa152d-a2e3-4c8d-9535-5dcd49dfcb6d'],type=REG_MULTI_SZ)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3',r'IPluginAuthentificationGateway_Order',['12fa152d-a2e3-4c8d-9535-5dcd49dfcb6d','0f52390b-c781-43ae-bd62-553c77fa4cf7'],type=REG_MULTI_SZ)

    print('Configuring pGina ->Desactivation MOTD')
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3',r'EnableMotd',['False'],type=REG_MULTI_SZ)

    print('Configuring pGina -> Configuration du logo')
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3',r'TileImage',r'C:\Program Files\pGina\logo.bmp',type=REG_SZ)

    print('Configuring pGina -> Configuration du plugin LDAP')
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'LdapHost',['ldap.univ-tln.fr'],type=REG_MULTI_SZ)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'LdapPort',389,type=REG_DWORD)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'LdapTimeout',10,type=REG_DWORD)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'SearchDN',r'cn=privilege,dc=ldap-univ-tln,dc=fr',type=REG_SZ)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'SearchPW',r'Enattente',type=REG_SZ)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'SearchFilter',r'uid=%u',type=REG_SZ)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'SearchContexts',['ou=people,dc=ldap-univ-tln,dc=fr'],type=REG_MULTI_SZ)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'GroupAuthzRules',['Utilisateurs01','21'],type=REG_MULTI_SZ)
    registry_set(HKEY_LOCAL_MACHINE,r'SOFTWARE\pGina3\Plugins\0f52390b-c781-43ae-bd62-553c77fa4cf7',r'AuthzAllowOnError',r'True',type=REG_SZ)

