2018-12-18 09:39:17 +01:00
|
|
|
#!/bin/bash
|
|
|
|
|
|
|
|
#
|
|
|
|
# Initialisation of LDAP Directory
|
|
|
|
#
|
|
|
|
|
|
|
|
|
|
|
|
#
|
|
|
|
# Run command as particular user
|
|
|
|
#
|
|
|
|
function runAs() {
|
|
|
|
USER=${1}
|
|
|
|
shift
|
|
|
|
CMD="su ${USER} -s /bin/bash -c ${@}"
|
|
|
|
|
|
|
|
eval ${CMD}
|
|
|
|
return ${?}
|
|
|
|
}
|
|
|
|
|
2020-12-15 13:48:29 +01:00
|
|
|
function addLDAPschema()
|
2018-12-18 09:39:17 +01:00
|
|
|
{
|
2020-12-15 13:48:29 +01:00
|
|
|
LDIF="/etc/cadolesldap/init/cadolesldap.ldif"
|
|
|
|
USER="openldap"
|
|
|
|
CMD="\"slapadd -l ${LDIF} -f \"/etc/ldap/slapd.conf\"\""
|
2018-12-18 09:39:17 +01:00
|
|
|
|
2020-12-15 13:48:29 +01:00
|
|
|
service slapd stop
|
|
|
|
runAs ${USER} ${CMD}
|
|
|
|
result=$((result+${?}))
|
|
|
|
service slapd start
|
|
|
|
return ${result}
|
|
|
|
}
|
2018-12-18 09:39:17 +01:00
|
|
|
|
2020-12-15 13:48:29 +01:00
|
|
|
function addADSchema()
|
|
|
|
{
|
|
|
|
/usr/share/eole/sbin/cadoles_add_schema.sh
|
|
|
|
return ${?}
|
|
|
|
}
|
|
|
|
|
|
|
|
function main()
|
|
|
|
{
|
|
|
|
MODE=${1}
|
|
|
|
result=0
|
2018-12-18 09:39:17 +01:00
|
|
|
|
|
|
|
|
2020-12-15 13:48:29 +01:00
|
|
|
if [[ ${MODE} == "instance" ]]
|
|
|
|
then
|
|
|
|
if [[ $(CreoleGet eole_module) == "seth" ]]
|
|
|
|
then
|
|
|
|
addADSchema
|
|
|
|
return ${?}
|
|
|
|
else
|
|
|
|
addLDAPschema
|
|
|
|
return ${?}
|
|
|
|
fi
|
|
|
|
fi
|
2018-12-18 09:39:17 +01:00
|
|
|
}
|
|
|
|
|
2021-01-20 15:57:08 +01:00
|
|
|
if [[ $(CreoleGet eole_module eolebase) == "seth" ]]
|
|
|
|
then
|
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
|
2020-03-13 11:54:51 +01:00
|
|
|
if [[ $(CreoleGet activer_cadolesldap non) == "oui" ]]
|
|
|
|
then
|
|
|
|
main $@
|
|
|
|
exit ${?}
|
|
|
|
else
|
|
|
|
exit 0
|
|
|
|
fi
|