|
| 1 | +#!/bin/bash |
| 2 | + |
| 3 | +# |
| 4 | +# Copyright (C) 2024 Nethesis S.r.l. |
| 5 | +# SPDX-License-Identifier: GPL-3.0-or-later |
| 6 | +# |
| 7 | + |
| 8 | +# Retrieving environment variables |
| 9 | +LDAP_DOMAIN=${LDAP_DOMAIN} |
| 10 | +LDAP_PORT=${LDAP_PORT} |
| 11 | +LDAP_USER=${LDAP_USER} |
| 12 | +LDAP_HOST=${LDAP_HOST} |
| 13 | +LDAP_PASS=${LDAP_PASS} |
| 14 | +LDAP_SCHEMA=${LDAP_SCHEMA} |
| 15 | +LDAP_BASE=${LDAP_BASE} |
| 16 | + |
| 17 | +mkdir -vp dokuwiki-config |
| 18 | +cat <<EOF > dokuwiki-config/local.protected.php |
| 19 | +<?php |
| 20 | +/** |
| 21 | + * this is file is generated by the dokuwki container automatically |
| 22 | + * do not edit it manually |
| 23 | + */ |
| 24 | +EOF |
| 25 | +# Check the value of $LDAP_DOMAIN |
| 26 | +if [[ "$LDAP_DOMAIN" == "" ]]; then |
| 27 | + cat <<EOF >> dokuwiki-config/local.protected.php |
| 28 | +\$conf['authtype'] = 'authplain'; |
| 29 | +EOF |
| 30 | + |
| 31 | +elif [[ "$LDAP_DOMAIN" != "" ]]; then |
| 32 | + if [[ "$LDAP_SCHEMA" == "rfc2307" ]]; then |
| 33 | + cat <<EOF >> dokuwiki-config/local.protected.php |
| 34 | +\$conf['authtype'] = 'authldap'; |
| 35 | +\$conf['plugin'][\$conf['authtype']]['server'] = "ldap://accountprovider:${LDAP_PORT}"; |
| 36 | +\$conf['plugin'][\$conf['authtype']]['version'] = '3'; |
| 37 | +\$conf['plugin'][\$conf['authtype']]['usertree'] = "ou=People,${LDAP_BASE}"; |
| 38 | +\$conf['plugin'][\$conf['authtype']]['grouptree'] = "ou=Groups,${LDAP_BASE}"; |
| 39 | +\$conf['plugin'][\$conf['authtype']]['userfilter'] = '(|(uid=%{user})(mail=%{user}))'; |
| 40 | +\$conf['plugin']['authldap']['groupfilter'] = '(memberUid=%{uid})'; |
| 41 | +\$conf['plugin'][\$conf['authtype']]['groupkey'] = 'cn'; |
| 42 | +\$conf['plugin']['authldap']['binddn'] = "${LDAP_USER}"; |
| 43 | +\$conf['plugin']['authldap']['bindpw'] = "${LDAP_PASS}"; |
| 44 | +\$conf['plugin']['authldap']['starttls'] = 0; |
| 45 | +\$conf['plugin']['authldap']['modPass'] = 0; |
| 46 | +EOF |
| 47 | + elif [[ "$LDAP_SCHEMA" == "ad" ]]; then |
| 48 | + cat <<EOF >> dokuwiki-config/local.protected.php |
| 49 | +\$conf['authtype'] = 'authad'; |
| 50 | +\$conf['plugin']['authad']['account_suffix'] = '@${LDAP_DOMAIN}'; |
| 51 | +\$conf['plugin']['authad']['base_dn'] = '${LDAP_BASE}'; |
| 52 | +\$conf['plugin']['authad']['domain_controllers'] = 'ldap://accountprovider:${LDAP_PORT}'; //multiple can be given |
| 53 | +\$conf['plugin']['authad']['use_tls'] = 0; |
| 54 | +EOF |
| 55 | + |
| 56 | + fi |
| 57 | +fi |
| 58 | +cat <<EOF >> dokuwiki-config/local.protected.php |
| 59 | +\$conf['useacl'] = 1; |
| 60 | +\$conf['superuser'] = 'admin,admin@${LDAP_DOMAIN},administrator,administrator@${LDAP_DOMAIN}'; |
| 61 | +EOF |
| 62 | + |
| 63 | +echo "Configuration written to dokuwiki-config/local.protected.php" |
| 64 | + |
| 65 | +cat <<EOF > dokuwiki-config/plugins.local.php |
| 66 | +<?php |
| 67 | +/* |
| 68 | + * Local plugin enable/disable settings |
| 69 | + * |
| 70 | + * Auto-generated by install s |
| 71 | + */ |
| 72 | +
|
| 73 | +\$plugins['authad'] = 1; |
| 74 | +\$plugins['authldap'] = 1; |
| 75 | +\$plugins['authmysql'] = 0; |
| 76 | +\$plugins['authpgsql'] = 0; |
| 77 | +EOF |
| 78 | +echo "Configuration written to dokuwiki-config/plugins.local.php" |
0 commit comments