Added phpLDAPadmin autoinstallation

This commit is contained in:
Marisa 2025-12-08 10:09:49 -03:00
parent 26e78904ac
commit 30504afd6c

View File

@ -202,6 +202,7 @@ update-ca-certificates --fresh >/dev/null 2>&1 || true
echo "--> Starting Apache + PHP (background)"
/usr/sbin/apache2ctl -D FOREGROUND &
APACHE_PID=$!
sleep 5
# HTTPS setup — using the real LDAP certificates
echo "--> Configuring Apache for HTTPS with real certificates"
@ -222,6 +223,50 @@ sed -i -E "s|^\s*SSLCertificateKeyFile\s+.*|SSLCertificateKeyFile ${APACHE_KEY_F
# Reload Apache gracefully (updates config without killing)
apache2ctl graceful >/dev/null 2>&1
sleep 5
# ──────────────────────────────
# phpLDAPadmin — auto-installed, no rebuild, works forever
# ──────────────────────────────
echo "--> Installing phpLDAPadmin"
# Only install once — use a flag file
if [ ! -f "/var/www/html/phpldapadmin-installed" ]; then
cd /var/www/html
# Download and extract (direct tarball, no git needed)
wget -q -O phpldapadmin.tgz \
https://github.com/leenooks/phpLDAPadmin/archive/refs/tags/1.2.6.7.tar.gz
tar xzf phpldapadmin.tgz
mv phpLDAPadmin-1.2.6.7 phpldapadmin
rm phpldapadmin.tgz
# Copy config and apply minimal working settings
cp phpldapadmin/config/config.php.example phpldapadmin/config/config.php
cat > phpldapadmin/config/config.php <<EOF
<?php
\$servers = new Datastore();
\$servers->newServer('ldap_pla');
\$servers->setValue('server','name','Local OpenLDAP');
\$servers->setValue('server','host','127.0.0.1');
\$servers->setValue('server','port',389);
\$servers->setValue('server','base',array('${LDAP_BASE_DN}'));
\$servers->setValue('server','tls',true);
\$servers->setValue('login','auth_type','session');
\$servers->setValue('login','bind_id','cn=admin,${LDAP_BASE_DN}');
\$servers->setValue('login','bind_pass','admin');
?>
EOF
# Mark as installed
touch /var/www/html/phpldapadmin-installed
echo "--> phpLDAPadmin installed → https://localhost/phpldapadmin"
else
echo "--> phpLDAPadmin already installed"
fi
# Victory message
echo "--> ldapdock ready — OpenLDAP + Apache + PHP running"