46 lines
1.8 KiB
YAML
46 lines
1.8 KiB
YAML
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: script-config-ldap
|
|
data:
|
|
poststart-ldap.sh: |
|
|
#!/bin/sh
|
|
|
|
NEXTCLOUD_READY=0
|
|
MAX_RETRIES=30
|
|
RETRY_INTERVAL=10
|
|
|
|
touch /etc/script/validator.txt
|
|
# Vérifiez si LDAP est déjà activé
|
|
# if ! su -s /bin/sh -c "/var/www/html/occ app:list --output=json" www-data | jq -e '.enabled | has("user_ldap")'; then
|
|
# Activez le module LDAP si ce n'est pas déjà fait
|
|
# su -s /bin/sh -c "/var/www/html/occ app:enable user_ldap" www-data
|
|
#fi
|
|
for i in $(seq 1 $MAX_RETRIES); do
|
|
if curl -fsS "http://localhost/status.php" > /dev/null; then
|
|
NEXTCLOUD_READY=1
|
|
break
|
|
else
|
|
echo "En attente de Nextcloud (tentative $i/$MAX_RETRIES)..." >> /etc/script/validator.txt
|
|
sleep $RETRY_INTERVAL
|
|
fi
|
|
done
|
|
|
|
if [ $NEXTCLOUD_READY -eq 0 ]; then
|
|
echo "Nextcloud n'est pas prêt après $MAX_RETRIES tentatives. Abandon de l'initialisation LDAP." >> /etc/script/validator.txt
|
|
exit 1
|
|
fi
|
|
|
|
su -s /bin/sh -c "/var/www/html/occ app:enable user_ldap" www-data
|
|
|
|
# Configurez LDAP (configuration minimale)
|
|
su -s /bin/sh -c "/var/www/html/occ config:app:set user_ldap ldapHost --value='ldap.example.com'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ config:app:set user_ldap ldapBase --value='dc=example,dc=com'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ config:app:set user_ldap ldapAgentName --value='cn=admin,dc=example,dc=com'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ config:app:set user_ldap ldapAgentPassword --value='your_password'" www-data
|
|
|
|
# Lancez le processus principal de Nextcloud normalement ça ne marche pas ça ! donc plutot poststart.
|
|
#exec /entrypoint.sh "$@"
|
|
|
|
# su -s /bin/sh -c "/var/www/html/occ app:enable user_ldap" www-data
|
|
# est fonctionnel dans le pods nextcloud ! |