canaille-globuzma/demo/run.sh

45 lines
1.3 KiB
Bash
Raw Normal View History

#!/bin/bash
2020-11-13 10:15:17 +00:00
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
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".
}
function run {
2021-10-27 18:55:04 +00:00
if ! type python > /dev/null 2>&1 && ! type python3 > /dev/null 2>&1; then
echo "Cannot start the LDAP server. Please install python on your system."
return 1
fi
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
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
if [ "$1" == "--ldap-native" ]; then
2022-05-13 14:47:48 +00:00
env "SLAPD_BINARY=NATIVE" "PWD=$DIR" poetry run honcho start
elif [ "$1" == "--ldap-docker" ]; then
2022-05-13 14:47:48 +00:00
env "SLAPD_BINARY=DOCKER" "PWD=$DIR" poetry run honcho start
else
2022-05-13 14:47:48 +00:00
env "PWD=$DIR" poetry run honcho start
fi
}
if [ "$1" != "" ] && [ "$1" != "--ldap-native" ] && [ "$1" != "--ldap-docker" ]; then
usage
else
run "$@"
fi