Skip to content

Commit

Permalink
Merge branch 'hotfix-0.6.2' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
BertrandGouny committed Aug 21, 2015
2 parents 3154079 + 4cd5f5d commit 6e05f51
Show file tree
Hide file tree
Showing 8 changed files with 47 additions and 35 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
# Changelog

## 0.6.2
- Better way to add custom config

## 0.6.1
- Upgrade baseimage: osixia/web-baseimage:0.1.1
- Rename environment variables
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
NAME = osixia/phpldapadmin
VERSION = 0.6.1
VERSION = 0.6.2

.PHONY: all build test tag_latest release

Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Example script:
LDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $LDAP_CID)

# Run phpLDAPadmin and set ldap host to ldap ip
PHPLDAP_CID=$(docker run -h phpldapadmin.example.org -e PHPLDAPADMIN_LDAP_HOSTS=$LDAP_IP -d osixia/phpldapadmin:0.6.1)
PHPLDAP_CID=$(docker run -h phpldapadmin.example.org -e PHPLDAPADMIN_LDAP_HOSTS=$LDAP_IP -d osixia/phpldapadmin:0.6.2)

# We get phpLDAPadmin container ip
PHPLDAP_IP=$(docker inspect -f "{{ .NetworkSettings.IPAddress }}" $PHPLDAP_CID)
Expand Down Expand Up @@ -99,16 +99,16 @@ Environement variables defaults are set in **image/env.yaml**. You can modify en
To convert yaml to python online :
http://yaml-online-parser.appspot.com/

Apache config :
Apache :
- **PHPLDAPADMIN_SERVER_ADMIN**: Server admin email. Defaults to `webmaster@example.org`

PHPLDAPADMIN_HTTPS options :
HTTPS :
- **PHPLDAPADMIN_HTTPS**: Use apache ssl config. Defaults to `true`
- **PHPLDAPADMIN_HTTPS_CRT_FILENAME**: Apache ssl certificate filename. Defaults to `phpldapadmin.crt`
- **PHPLDAPADMIN_HTTPS_KEY_FILENAME**: Apache ssl certificate private key filename. Defaults to `phpldapadmin.key`
- **PHPLDAPADMIN_HTTPS_CA_CRT_FILENAME**: Apache ssl CA certificate filename. Defaults to `ca.crt`

Ldap client TLS/LDAPS options :
Ldap client TLS/LDAPS :

- **PHPLDAPADMIN_LDAP_CLIENT_TLS**: Enable ldap client tls config, ldap serveur certificate check and set client certificate. Defaults to `true`
- **PHPLDAPADMIN_LDAP_CLIENT_TLS_REQCERT**: Set ldap.conf TLS_REQCERT. Defaults to `demand`
Expand Down Expand Up @@ -140,7 +140,7 @@ Clone this project :
Adapt Makefile, set your image NAME and VERSION, for example :

NAME = osixia/phpldapadmin
VERSION = 0.6.0
VERSION = 0.6.2

becomes :
NAME = billy-the-king/phpldapadmin
Expand Down
2 changes: 1 addition & 1 deletion image/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM osixia/web-baseimage:0.1.1
FROM osixia/web-baseimage:0.1.2
MAINTAINER Bertrand Gouny <bertrand.gouny@osixia.net>

# phpLDAPadmin version
Expand Down
1 change: 1 addition & 0 deletions image/service/phpldapadmin/assets/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add your custom config.php file here or mount one at docker run to /container/service/phpldapadmin/assets/config.php
5 changes: 3 additions & 2 deletions image/service/phpldapadmin/assets/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
/*
* Autogenerated value will be automatically added by phpldapadmin/container-start.sh
*/
$config->custom->session['blowfish'] = '{{ PHPMYADMIN_CONFIG_BLOWFISH }}';
$config->custom->session['blowfish'] = '{{ PHPLDAPADMIN_CONFIG_BLOWFISH }}';


/*********************************************
Expand Down Expand Up @@ -63,5 +63,6 @@
$servers = new Datastore();

/*
* Autogenerated servers will come here
* Autogenerated servers variables will come here
*/
{{ PHPLDAPADMIN_SERVERS }}
56 changes: 33 additions & 23 deletions image/service/phpldapadmin/container-start.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,21 @@ if [ ! -e "$FIRST_START_DONE" ]; then
cp -R /var/www/phpldapadmin_bootstrap/* /var/www/phpldapadmin
rm -rf /var/www/phpldapadmin_bootstrap

echo "link /container/service/phpldapadmin/assets/config.php to /var/www/phpldapadmin/config/config.php"
ln -s /container/service/phpldapadmin/assets/config.php /var/www/phpldapadmin/config/config.php

get_salt() {
salt=$(</dev/urandom tr -dc '1324567890#<>,()*.^@$% =-_~;:/{}[]+!`azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN' | head -c64 | tr -d '\\')
}

# phpLDAPadmin cookie secret
get_salt
sed -i "s|{{ PHPMYADMIN_CONFIG_BLOWFISH }}|${salt}|g" /var/www/phpldapadmin/config/config.php
sed -i "s|{{ PHPLDAPADMIN_CONFIG_BLOWFISH }}|${salt}|g" /var/www/phpldapadmin/config/config.php

append_to_servers() {
TO_APPEND=$1
sed -i "s|{{ PHPLDAPADMIN_SERVERS }}|${TO_APPEND}\n{{ PHPLDAPADMIN_SERVERS }}|g" /var/www/phpldapadmin/config/config.php
}

print_by_php_type() {

Expand Down Expand Up @@ -81,12 +89,12 @@ if [ ! -e "$FIRST_START_DONE" ]; then
# the value contain a not empty variable
elif [ -n "${!value}" ]; then
local php_value=$(print_by_php_type ${!value})
echo "\$servers->setValue($to_print'$key',$php_value);" >> /var/www/phpldapadmin/config/config.php
append_to_servers "\$servers->setValue($to_print'$key',$php_value);"

# it's just a not empty value
elif [ -n "$value" ]; then
local php_value=$(print_by_php_type $value)
echo "\$servers->setValue($to_print'$key',$php_value);" >> /var/www/phpldapadmin/config/config.php
append_to_servers "\$servers->setValue($to_print'$key',$php_value);"
fi
}

Expand All @@ -98,46 +106,48 @@ if [ ! -e "$FIRST_START_DONE" ]; then
# host var contain a variable name, we access to the variable value and cast it to a table
infos=(${!host})

echo "\$servers->newServer('ldap_pla');" >> /var/www/phpldapadmin/config/config.php
append_to_servers "\$servers->newServer('ldap_pla');"

# it's a table of infos
if [ "${#infos[@]}" -gt "1" ]; then
echo "\$servers->setValue('server','name','${!infos[0]}');" >> /var/www/phpldapadmin/config/config.php
echo "\$servers->setValue('server','host','${!infos[0]}');" >> /var/www/phpldapadmin/config/config.php
append_to_servers "\$servers->setValue('server','name','${!infos[0]}');"
append_to_servers "\$servers->setValue('server','host','${!infos[0]}');"
host_infos "" ${infos[1]}

# it's just a host name
# stored in a variable
elif [ -n "${!host}" ]; then
echo "\$servers->setValue('server','name','${!host}');" >> /var/www/phpldapadmin/config/config.php
echo "\$servers->setValue('server','host','${!host}');" >> /var/www/phpldapadmin/config/config.php
append_to_servers "\$servers->setValue('server','name','${!host}');"
append_to_servers "\$servers->setValue('server','host','${!host}');"

# directly
else
echo "\$servers->setValue('server','name','${host}');" >> /var/www/phpldapadmin/config/config.php
echo "\$servers->setValue('server','host','${host}');" >> /var/www/phpldapadmin/config/config.php
append_to_servers "\$servers->setValue('server','name','${host}');"
append_to_servers "\$servers->setValue('server','host','${host}');"
fi
done

if [ "${PHPLDAPADMIN_LDAP_CLIENT_TLS,,}" == "true" ]; then
sed -i "/{{ PHPLDAPADMIN_SERVERS }}/d" /var/www/phpldapadmin/config/config.php

# check certificat and key or create it
/sbin/ssl-helper "/container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_CRT_FILENAME}" "/container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_KEY_FILENAME}" --ca-crt=/container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_CA_CRT_FILENAME} --gnutls
fi

# ldap client config
sed -i "s,TLS_CACERT.*,TLS_CACERT /container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_CA_CRT_FILENAME},g" /etc/ldap/ldap.conf
echo "TLS_REQCERT $PHPLDAPADMIN_LDAP_CLIENT_TLS_REQCERT" >> /etc/ldap/ldap.conf
if [ "${PHPLDAPADMIN_LDAP_CLIENT_TLS,,}" == "true" ]; then

www_data_homedir=$( getent passwd "www-data" | cut -d: -f6 )
# check certificat and key or create it
/sbin/ssl-helper "/container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_CRT_FILENAME}" "/container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_KEY_FILENAME}" --ca-crt=/container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_CA_CRT_FILENAME} --gnutls

[[ -f "$www_data_homedir/.ldaprc" ]] && rm -f $www_data_homedir/.ldaprc
touch $www_data_homedir/.ldaprc
echo "TLS_CERT /container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_CRT_FILENAME}" >> $www_data_homedir/.ldaprc
echo "TLS_KEY /container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_KEY_FILENAME}" >> $www_data_homedir/.ldaprc
# ldap client config
sed -i "s,TLS_CACERT.*,TLS_CACERT /container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_CA_CRT_FILENAME},g" /etc/ldap/ldap.conf
echo "TLS_REQCERT $PHPLDAPADMIN_LDAP_CLIENT_TLS_REQCERT" >> /etc/ldap/ldap.conf

chown www-data:www-data -R /container/service/phpldapadmin/assets/ldap-client/certs/
fi
www_data_homedir=$( getent passwd "www-data" | cut -d: -f6 )

[[ -f "$www_data_homedir/.ldaprc" ]] && rm -f $www_data_homedir/.ldaprc
touch $www_data_homedir/.ldaprc
echo "TLS_CERT /container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_CRT_FILENAME}" >> $www_data_homedir/.ldaprc
echo "TLS_KEY /container/service/phpldapadmin/assets/ldap-client/certs/${PHPLDAPADMIN_LDAP_CLIENT_TLS_KEY_FILENAME}" >> $www_data_homedir/.ldaprc

chown www-data:www-data -R /container/service/phpldapadmin/assets/ldap-client/certs/
fi

# fix file permission
Expand Down
3 changes: 0 additions & 3 deletions image/service/phpldapadmin/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,6 @@
ln -s /container/service/phpldapadmin/assets/apache2/phpldapadmin.conf /etc/apache2/sites-available/phpldapadmin.conf
ln -s /container/service/phpldapadmin/assets/apache2/phpldapadmin-ssl.conf /etc/apache2/sites-available/phpldapadmin-ssl.conf

cp /container/service/phpldapadmin/assets/config.php /var/www/phpldapadmin_bootstrap/config/config.php
rm /container/service/phpldapadmin/assets/config.php

cat /container/service/phpldapadmin/assets/php5-fpm/pool.conf >> /etc/php5/fpm/pool.d/www.conf
rm /container/service/phpldapadmin/assets/php5-fpm/pool.conf

Expand Down

0 comments on commit 6e05f51

Please sign in to comment.