82 lines
4.7 KiB
YAML
82 lines
4.7 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:install user_ldap" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ app:update user_ldap" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ app:enable user_ldap" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:create-empty-config" www-data
|
|
|
|
## test if backend ldap is activated and create empty config if not
|
|
#
|
|
#touch /tmp/nxt-ldap.txt
|
|
#su -s /bin/sh -c "/var/www/html/occ ldap:show-config s01 > /tmp/nxt-ldap.txt" www-data
|
|
#if grep -q "Invalid configID" /tmp/nxt-ldap.txt; then
|
|
# su -s /bin/sh -c "/var/www/html/occ ldap:create-empty-config" www-data
|
|
# #sudo -u www-data php /var/www/html/nextcloud/occ ldap:create-empty-config -q
|
|
#fi
|
|
|
|
# Configurez LDAP (configuration minimale)
|
|
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldap_host '${NEXTCLOUD_LDAP_HOST}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldap_base '${NEXTCLOUD_LDAP_BASE}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldap_dn '${NEXTCLOUD_LDAP_DN}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldap_agent_password '${NEXTCLOUD_LDAP_PASSWD}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapBaseGroups '${NEXTCLOUD_LDAP_BASE_GROUPS}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapBaseUsers '${NEXTCLOUD_LDAP_BASE_USERS}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapConfigurationActive '${NEXTCLOUD_LDAP_ACTIVE_CONF}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapExperiencedAdmin '${NEXTCLOUD_LDAP_ADMIN_EXP}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapExpertUUIDUserAttr '${NEXTCLOUD_LDAP_EXP_UUID}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapLoginFilter '${NEXTCLOUD_LDAP_LOGIN_FILTER}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapLoginFilterAttributes '${NEXTCLOUD_LDAP_LOGIN_FILTER_ATTR}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapPort '${NEXTCLOUD_LDAP_PORT}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapUserFilter '${NEXTCLOUD_LDAP_USR_FILTR}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapUserFilterObjectclass '${NEXTCLOUD_LDAP_OBJ_FILTR}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapEmailAttribute '${NEXTCLOUD_LDAP_MAIL_ATTR}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapUserDisplayName '${NEXTCLOUD_LDAP_USER_DISP}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapGroupFilter '${NEXTCLOUD_LDAP_GROUP_FILTR}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapGroupFilterObjectclass '${NEXTCLOUD_LDAP_GROUP_FILTR_OBJCLASS}'" www-data
|
|
su -s /bin/sh -c "/var/www/html/occ ldap:set-config s01 ldapGroupMemberAssocAttr '${NEXTCLOUD_LDAP_GROUP_MEMBR_ASSO}'" www-data
|
|
|
|
#sudo -u www-data php /var/www/html/nextcloud/occ ldap:set-config s01 ldapGroupFilter "${ldapGroupFilter}"
|
|
#sudo -u www-data php /var/www/html/nextcloud/occ ldap:set-config s01 ldapGroupFilterObjectclass "${ldapGroupFilterObjectclass}"
|
|
#sudo -u www-data php /var/www/html/nextcloud/occ ldap:set-config s01 ldapGroupMemberAssocAttr "${ldapGroupMemberAssocAttr}"
|
|
|
|
|
|
# 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 !
|
|
|
|
#liste config : su -s /bin/sh -c "/var/www/html/occ config:list" www-data
|