3
3
4
4
set -ex
5
5
6
- slapd_data_dir=$1
7
- tcp_port=$2
6
+ readonly slapd_data_dir=" $1 "
7
+ readonly tcp_port=" $2 "
8
8
9
- pidfile=" $slapd_data_dir /slapd.pid"
10
- uri=" ldap://localhost:$tcp_port "
9
+ readonly pidfile=" $slapd_data_dir /slapd.pid"
10
+ readonly uri=" ldap://localhost:$tcp_port "
11
11
12
- binddn=" cn=config"
13
- passwd=secret
12
+ readonly binddn=" cn=config"
13
+ readonly passwd=secret
14
14
15
15
case " $( uname -s) " in
16
16
Linux)
17
- slapd=/usr/sbin/slapd
18
- modulepath=/usr/lib/ldap
19
- schema_dir=/etc/ldap/schema
17
+ if [ -x /usr/bin/slapd ]
18
+ then
19
+ readonly slapd=/usr/bin/slapd
20
+ elif [ -x /usr/sbin/slapd ]
21
+ then
22
+ readonly slapd=/usr/sbin/slapd
23
+ fi
24
+
25
+ if [ -d /usr/lib/openldap ]
26
+ then
27
+ readonly modulepath=/usr/lib/openldap
28
+ elif [ -d /usr/lib/ldap ]
29
+ then
30
+ readonly modulepath=/usr/lib/ldap
31
+ fi
32
+
33
+ if [ -d /etc/openldap/schema ]
34
+ then
35
+ readonly schema_dir=/etc/openldap/schema
36
+ elif [ -d /etc/ldap/schema ]
37
+ then
38
+ readonly schema_dir=/etc/ldap/schema
39
+ fi
20
40
;;
21
41
FreeBSD)
22
- slapd=/usr/local/libexec/slapd
23
- modulepath=/usr/local/libexec/openldap
24
- schema_dir=/usr/local/etc/openldap/schema
42
+ readonly slapd=/usr/local/libexec/slapd
43
+ readonly modulepath=/usr/local/libexec/openldap
44
+ readonly schema_dir=/usr/local/etc/openldap/schema
25
45
;;
26
46
* )
27
47
exit 1
35
55
rm -rf " $slapd_data_dir "
36
56
mkdir -p " $slapd_data_dir "
37
57
38
- conf_file=$slapd_data_dir /slapd.conf
58
+ readonly conf_file=" $slapd_data_dir /slapd.conf"
39
59
cat << EOF > "$conf_file "
40
60
include $schema_dir /core.schema
41
61
include $schema_dir /cosine.schema
52
72
53
73
cat " $conf_file "
54
74
55
- conf_dir=$slapd_data_dir /slapd.d
75
+ readonly conf_dir=" $slapd_data_dir /slapd.d"
56
76
mkdir -p " $conf_dir "
57
77
58
78
# Start slapd(8).
@@ -61,10 +81,12 @@ mkdir -p "$conf_dir"
61
81
-F " $conf_dir " \
62
82
-h " $uri "
63
83
64
- auth=" -x -D $binddn -w $passwd "
84
+ readonly auth=" -x -D $binddn -w $passwd "
65
85
66
86
# We wait for the server to start.
87
+ # shellcheck disable=SC2034
67
88
for seconds in 1 2 3 4 5 6 7 8 9 10; do
89
+ # shellcheck disable=SC2086
68
90
ldapsearch $auth -H " $uri " -LLL -b cn=config dn && break ;
69
91
sleep 1
70
92
done
73
95
# Load the example LDIFs for the testsuite.
74
96
# --------------------------------------------------------------------
75
97
76
- script_dir=$( cd " $( dirname " $0 " ) " && pwd)
77
- example_ldif_dir=" $script_dir /../../example"
78
- example_data_dir=" $slapd_data_dir /example"
98
+ tmp=" $( cd " $( dirname " $0 " ) " && pwd) "
99
+ readonly script_dir=" $tmp "
100
+ readonly example_ldif_dir=" $script_dir /../../example"
101
+ readonly example_data_dir=" $slapd_data_dir /example"
79
102
mkdir -p " $example_data_dir "
80
103
81
104
# We update the hard-coded database directory with the one we computed
82
105
# here, so the data is located inside the test directory.
106
+ # shellcheck disable=SC2086
83
107
sed -E -e " s,^olcDbDirectory:.*,olcDbDirectory: $example_data_dir ," \
84
108
< " $example_ldif_dir /global.ldif" | \
85
109
ldapadd $auth -H " $uri "
86
110
87
111
# We remove the module path from the example LDIF as it was already
88
112
# configured.
113
+ # shellcheck disable=SC2086
89
114
sed -E -e " s,^olcModulePath:.*,olcModulePath: $modulepath ," \
90
115
< " $example_ldif_dir /memberof_init.ldif" | \
91
116
ldapadd $auth -H " $uri "
92
117
118
+ # shellcheck disable=SC2086
93
119
ldapmodify $auth -H " $uri " -f " $example_ldif_dir /refint_1.ldif"
120
+
121
+ # shellcheck disable=SC2086
94
122
ldapadd $auth -H " $uri " -f " $example_ldif_dir /refint_2.ldif"
95
123
124
+ # shellcheck disable=SC2086
96
125
ldapsearch $auth -H " $uri " -LLL -b cn=config dn
97
126
98
- echo SLAPD_PID=$( cat " $pidfile " )
127
+ echo SLAPD_PID=" $( cat " $pidfile " ) "
0 commit comments