forked from mystiq/dex
Improve script logging
Signed-off-by: Martin Heide <martin.heide@faro.com>
This commit is contained in:
parent
ce337661b9
commit
b4d22bf1b2
1 changed files with 35 additions and 29 deletions
|
@ -10,6 +10,11 @@
|
||||||
set -eu
|
set -eu
|
||||||
cd -- "$(dirname "$0")/.."
|
cd -- "$(dirname "$0")/.."
|
||||||
|
|
||||||
|
run_cmd() {
|
||||||
|
echo ">" "$@" >&2
|
||||||
|
"$@"
|
||||||
|
}
|
||||||
|
|
||||||
keep_running=
|
keep_running=
|
||||||
if [ $# -gt 0 ] && [ "$1" = "--keep" ]; then
|
if [ $# -gt 0 ] && [ "$1" = "--keep" ]; then
|
||||||
keep_running=1
|
keep_running=1
|
||||||
|
@ -18,10 +23,10 @@ fi
|
||||||
if [ -z "$keep_running" ] || [ "$(docker inspect --format="{{.State.Running}}" ldap 2> /dev/null)" != "true" ]; then
|
if [ -z "$keep_running" ] || [ "$(docker inspect --format="{{.State.Running}}" ldap 2> /dev/null)" != "true" ]; then
|
||||||
echo "LDAP container not running, or running and --keep not specified."
|
echo "LDAP container not running, or running and --keep not specified."
|
||||||
echo "Removing old LDAP container (if any)..."
|
echo "Removing old LDAP container (if any)..."
|
||||||
docker rm --force ldap || true
|
run_cmd docker rm --force ldap || true
|
||||||
echo "Starting LDAP container..."
|
echo "Starting LDAP container..."
|
||||||
# Currently the most popular OpenLDAP image on Docker Hub. Comes with the latest version OpenLDAP 2.4.50.
|
# Currently the most popular OpenLDAP image on Docker Hub. Comes with the latest version OpenLDAP 2.4.50.
|
||||||
docker run -p 389:389 -p 636:636 -v $PWD:$PWD --name ldap --detach osixia/openldap:1.4.0
|
run_cmd docker run -p 389:389 -p 636:636 -v $PWD:$PWD --name ldap --detach osixia/openldap:1.4.0
|
||||||
|
|
||||||
tries=1
|
tries=1
|
||||||
max_tries=10
|
max_tries=10
|
||||||
|
@ -41,10 +46,11 @@ if [ -z "$keep_running" ] || [ "$(docker inspect --format="{{.State.Running}}" l
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Adding example entries to directory..."
|
echo "Adding example entries to directory..."
|
||||||
set -x
|
run_cmd docker exec ldap ldapadd \
|
||||||
docker exec ldap ldapadd \
|
|
||||||
-x \
|
-x \
|
||||||
-D "cn=admin,dc=example,dc=org" \
|
-D "cn=admin,dc=example,dc=org" \
|
||||||
-w admin \
|
-w admin \
|
||||||
-H ldap://localhost:389/ \
|
-H ldap://localhost:389/ \
|
||||||
-f $PWD/examples/config-ldap.ldif
|
-f $PWD/examples/config-ldap.ldif
|
||||||
|
|
||||||
|
echo "OK."
|
||||||
|
|
Loading…
Reference in a new issue