forked from wealthworks/docker-phpLDAPAdmin
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontainer-start.sh
executable file
·63 lines (46 loc) · 2.13 KB
/
container-start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#!/bin/sh -e
FIRST_START_DONE="/etc/docker-first-start-done"
# /usr/share/phpldapadmin/config/config.php -> /etc/phpldapadmin/config.php
# container first start
if [ ! -e "$FIRST_START_DONE" ]; then
mkdir -p /var/log/php
chown nobody /var/log/php
sed -i "s|;error_log = php_errors.log|error_log = /var/log/php/errors.log|g" /etc/php/php.ini
mkdir -p /var/lib/nginx/tmp
chown -R nobody:nobody /var/lib/nginx
chmod 775 /var/lib/nginx /var/lib/nginx/tmp
CONFIG="/etc/phpldapadmin/config.php"
# $servers->newServer('ldap_pla');
# $servers->setValue('server','name','My LDAP Server');
# $servers->setValue('server','host','localhost');
# $servers->setValue('server','port',389);
# $servers->setValue('server','base',array('dc=example,dc=net'));
# $servers->setValue('login','auth_type','session');
if [ ! -e $CONFIG ]; then
echo "<?PHP" > $CONFIG
echo "" >> $CONFIG
echo "\$config->custom->session['blowfish'] = '';" >> $CONFIG
echo "" >> $CONFIG
echo "\$servers = new Datastore();" >> $CONFIG
echo "" >> $CONFIG
fi
get_salt() {
salt=$(</dev/urandom tr -dc '1324567890#<>,()*.^@$% =-_~;:|{}[]+!`azertyuiopqsdfghjklmwxcvbnAZERTYUIOPQSDFGHJKLMWXCVBN' | head -c64 | tr -d '\\')
}
# phpLDAPadmin cookie secret
get_salt
sed -i "s/blowfish'] = '/blowfish'] = '${salt}/g" $CONFIG
echo "\$servers->newServer('ldap_pla');" >> $CONFIG
echo "\$servers->setValue('login','auth_type','${LDAP_AUTH_TYPE:-session}');" >> $CONFIG
echo "\$servers->setValue('server','name','${LDAP_NAME:-My LDAP Server}');" >> $CONFIG
echo "\$servers->setValue('server','host','${LDAP_HOST:-localhost}');" >> $CONFIG
echo "\$servers->setValue('server','port', ${LDAP_PORT:-389} );" >> $CONFIG
[ ! -z $LDAP_BASE_DN] && echo "\$servers->setValue('server','base',array('${LDAP_BASE_DN}'));" >> $CONFIG
echo "" >> $CONFIG
if [ -n "$MAIL_DOMAIN" ]; then
sed -i "s|@example.org|@$MAIL_DOMAIN|g" /usr/share/webapps/phpldapadmin/templates/creation/customAccount.xml
fi
[ -d /var/lib/php5/sessions ] && chown nobody:nobody /var/lib/php5/sessions
touch $FIRST_START_DONE
fi
php-fpm && nginx