3
# in_testenv.sh - script to check whether we are running in test environment
5
# Copyright (C) 2011 Arthur de Jong
7
# This library is free software; you can redistribute it and/or
8
# modify it under the terms of the GNU Lesser General Public
9
# License as published by the Free Software Foundation; either
10
# version 2.1 of the License, or (at your option) any later version.
12
# This library is distributed in the hope that it will be useful,
13
# but WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
# Lesser General Public License for more details.
17
# You should have received a copy of the GNU Lesser General Public
18
# License along with this library; if not, write to the Free Software
19
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
22
# This script expects to be run in an environment where nss-pam-ldapd
23
# is deployed with an LDAP server with the proper content (and nslcd running).
24
# It's probably best to run this in an environment without nscd (this breaks
25
# the services tests).
27
# check if LDAP is configured correctly
28
cfgfile="/etc/nslcd.conf"
33
echo "$0: $cfgfile: not found"
37
uri=`sed -n 's/^uri *//p' "$cfgfile" | head -n 1`
40
# try to fetch the base DN (fail with exit 77 to indicate problem)
41
ldapsearch -b "$base" -s base -x -H "$uri" > /dev/null 2>&1 || {
42
echo "$0: LDAP server $uri not available for $base"
46
# basic check to see if nslcd is running
47
if [ -S /var/run/nslcd/socket ] && \
48
[ -f /var/run/nslcd/nslcd.pid ] && \
49
kill -s 0 `cat /var/run/nslcd/nslcd.pid` > /dev/null 2>&1
53
echo "$0: nslcd not running"
57
# TODO: check if nscd is running
59
# TODO: check if /etc/nsswitch.conf is correct
61
echo "$0: using LDAP server $uri"