2020-11-10 16:52:52 +00:00
|
|
|
#!/bin/bash
|
2020-11-13 10:15:17 +00:00
|
|
|
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
|
|
|
|
|
2021-08-31 13:47:06 +00:00
|
|
|
function usage {
|
|
|
|
echo "Usage: ./run.sh [--usage|--ldap-native|--ldap-docker]"
|
|
|
|
echo " --usage Prints this message"
|
|
|
|
echo " --ldap-native Use the system slapd binary"
|
|
|
|
echo " --ldap-docker Use ldap from a docker image"
|
|
|
|
echo
|
|
|
|
echo "If neither --ldap-native nor --ldap-docker is specified, native will be tried,"
|
|
|
|
echo "then docker".
|
|
|
|
}
|
2020-11-10 16:52:52 +00:00
|
|
|
|
2021-08-31 13:47:06 +00:00
|
|
|
function run {
|
2021-10-27 18:55:04 +00:00
|
|
|
if ! type python > /dev/null 2>&1 && ! type python3 > /dev/null 2>&1; then
|
2021-08-31 13:47:06 +00:00
|
|
|
echo "Cannot start the LDAP server. Please install python on your system."
|
|
|
|
return 1
|
|
|
|
fi
|
2020-11-10 16:52:52 +00:00
|
|
|
|
2022-05-13 14:47:48 +00:00
|
|
|
if ! type poetry > /dev/null 2>&1; then
|
2023-02-14 16:58:42 +00:00
|
|
|
echo "Cannot start the LDAP server. Please install poetry on your system."
|
2022-05-13 14:47:48 +00:00
|
|
|
echo "https://python-poetry.org/docs/#installation"
|
|
|
|
return 1
|
2021-08-31 13:47:06 +00:00
|
|
|
fi
|
2020-11-13 10:15:17 +00:00
|
|
|
|
2022-05-13 14:47:48 +00:00
|
|
|
poetry install
|
|
|
|
poetry run pip install honcho requests slapd
|
|
|
|
|
2021-08-31 13:47:06 +00:00
|
|
|
if [ "$1" == "--ldap-native" ]; then
|
2022-05-13 14:47:48 +00:00
|
|
|
env "SLAPD_BINARY=NATIVE" "PWD=$DIR" poetry run honcho start
|
2021-08-31 13:47:06 +00:00
|
|
|
|
|
|
|
elif [ "$1" == "--ldap-docker" ]; then
|
2022-05-13 14:47:48 +00:00
|
|
|
env "SLAPD_BINARY=DOCKER" "PWD=$DIR" poetry run honcho start
|
2020-11-10 16:52:52 +00:00
|
|
|
|
2021-08-31 13:47:06 +00:00
|
|
|
else
|
2022-05-13 14:47:48 +00:00
|
|
|
env "PWD=$DIR" poetry run honcho start
|
2021-08-31 13:47:06 +00:00
|
|
|
fi
|
|
|
|
}
|
|
|
|
|
|
|
|
if [ "$1" != "" ] && [ "$1" != "--ldap-native" ] && [ "$1" != "--ldap-docker" ]; then
|
|
|
|
usage
|
|
|
|
else
|
|
|
|
run "$@"
|
|
|
|
fi
|