github.com/mackerelio/mackerel-agent-plugins@v0.89.3/mackerel-plugin-openldap/test.sh (about)

     1  #!/bin/sh
     2  
     3  prog=$(basename $0)
     4  if ! [ -S /var/run/docker.sock ]
     5  then
     6  	echo "$prog: there are no running docker" >&2
     7  	exit 2
     8  fi
     9  
    10  cd $(dirname $0)
    11  PATH=$(pwd):$PATH
    12  plugin=$(basename $(pwd))
    13  if ! which $plugin >/dev/null
    14  then
    15  	echo "$prog: $plugin is not installed" >&2
    16  	exit 2
    17  fi
    18  
    19  # By default, LDAP_DOMAIN=example.org and LDAP_ORGANISATION=Example Inc
    20  docker run --name test-$plugin -p 389:389 -d \
    21  	-e 'LDAP_ADMIN_PASSWORD=passpass' \
    22  	-v $(pwd)/ldif:/container/service/slapd/assets/config/bootstrap/ldif/custom \
    23  	osixia/openldap --copy-service
    24  trap 'docker stop test-$plugin; docker rm test-$plugin; exit' EXIT
    25  sleep 10
    26  
    27  base_dn='dc=example,dc=org'
    28  exec $plugin -bind "cn=monitor,$base_dn" -pw passpass