File: config

package info (click to toggle)
phpldapadmin 1.2.6.7-4
  • links: PTS, VCS
  • area: main
  • in suites: sid, trixie
  • size: 5,528 kB
  • sloc: php: 17,684; javascript: 5,299; xml: 1,498; sh: 379; python: 148; makefile: 23
file content (125 lines) | stat: -rw-r--r-- 3,764 bytes parent folder | download | duplicates (2)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/sh -e

CONFFILE="/etc/phpldapadmin/config.php"

. /usr/share/debconf/confmodule
db_version 2.0 || [ $? -lt 30 ]

# Autoconfiguration for phpldapadmin
# sha1sum is provided by the essential package: coreutils
# This hash is the content of default config file when it is unchanged
# Hash updated for phpldapadmin 1.2.6.6
if [ ! -f $CONFFILE ] || [ `sha1sum $CONFFILE | awk '{print $1}'` = "83a9e5f986c083fc13d4b2b75286c37dab60274e" ]; then

	# Let's try to read default from slapd.conf, libnss-ldap.conf or libpam_ldap.conf
	if [ -f /etc/ldap/slapd.conf ]; then
		ldapserver="localhost"
		if grep "^TLS" /etc/ldap/slapd.conf > /dev/null 2>&1; then
			tls="true"
		else
			tls="false"
		fi
		basedn=`grep ^suffix /etc/ldap/slapd.conf | awk '{print $2}' | sed -e s/\"//g`
		binddn=`sed --silent --expression '/^ *by dn=.* write/s/^.*\(dn=[^ ]*\).*$/\1/p' /etc/ldap/slapd.conf | head -n1`
	elif [ -f /etc/libnss-ldap.conf ]; then
		if grep "^host" /etc/libnss-ldap.conf > /dev/null 2>&1; then
			ldapserver=`grep ^host /etc/libnss-ldap.conf | awk '{print $2}'`
		elif grep "^uri" /etc/libnss-ldap.conf > /dev/null 2>&1; then
			ldapserver=`grep ^uri /etc/libnss-ldap.conf | sed -e s@/@@g | awk -F : '{print $2}'`
		fi
		if grep "^TLS" /etc/libnss-ldap.conf > /dev/null 2>&1; then
			tls="true"
		else
			tls="false"
		fi
		basedn=`grep -e "^base" /etc/libnss-ldap.conf | awk '{print $2}' | sed -e s/\"//g`
		binddn=`grep -e "^rootbinddn" /etc/libnss-ldap.conf | awk '{print $2}'`
	elif [ -f /etc/pam_ldap.conf ]; then
		if grep "^host" /etc/pam_ldap.conf > /dev/null 2>&1; then
			ldapserver=`grep ^host /etc/pam_ldap.conf | awk '{print $2}'`
		elif grep "^uri" /etc/pam_ldap.conf > /dev/null 2>&1; then
			ldapserver=`grep ^uri /etc/pam_ldap.conf | sed -e s@/@@g | awk -F : '{print $2}'`
		fi
		if grep "^TLS" /etc/pam_ldap.conf > /dev/null 2>&1; then
			tls="true"
		else
			tls="false"
		fi
		basedn=`grep -e "^base" /etc/pam_ldap.conf | awk '{print $2}' | sed -e s/\"//g`
		binddn=`grep -e "^rootbinddn" /etc/pam_ldap.conf | head -n1 | awk '{print $2}'`
	fi

	if [ -f /etc/ldap.secret ]; then
		bindpw=`head -n1 /etc/ldap.secret`
	fi

	if [ "$ldapserver" = "" ]; then
		db_input medium phpldapadmin/ldap-server || true
		db_go || true
		db_get phpldapadmin/ldap-server || true
		ldapserver="$RET"
	else
		db_set phpldapadmin/ldap-server $ldapserver || true
	fi

	if [ "$tls" = "" ]; then
		db_input medium phpldapadmin/ldap-tls || true
		db_go || true
		db_get phpldapadmin/ldap-tls || true
		tls="$RET"
	else
		db_set phpldapadmin/ldap-tls $tls || true
	fi

	if [ "$tls" = "true" ]; then
		ldapserver="ldaps:\\/\\/$ldapserver"
		db_set phpldapadmin/ldap-server $ldapserver || true
	fi

	if [ "$basedn" = "" ]; then
		db_input medium phpldapadmin/ldap-basedn || true
		db_go || true
		db_get phpldapadmin/ldap-basedn || true
		basedn="$RET"
	else
		db_set phpldapadmin/ldap-basedn $basedn || true
	fi
	
	db_input medium phpldapadmin/ldap-authtype || true
	db_go || true
	db_get phpldapadmin/ldap-authtype || true
	authtype="$RET"

	if [ "$binddn" = "" ]; then
		db_set phpldapadmin/ldap-binddn "cn=admin,$basedn"
		db_input medium phpldapadmin/ldap-binddn || true
		db_go || true
	else
		db_set phpldapadmin/ldap-binddn $binddn || true
	fi

	if [ "$authtype" = "config" ]; then
		if [ "$bindpw" = "" ]; then
			db_input medium phpldapadmin/ldap-bindpw || true
			db_go || true
		else
			db_set phpldapadmin/ldap-bindpw $bindpw || true
		fi
	fi

	# Apache* autoconfiguration
	db_input medium phpldapadmin/reconfigure-webserver || true
	db_go || true
	db_get phpldapadmin/reconfigure-webserver || true
	webservers="$RET"
	
	if [ ! "$webservers" = "" ]; then
		db_input medium phpldapadmin/restart-webserver || true
		db_go || true
	fi

fi

#DEBHELPER#

exit 0