From 2b94674ec38d880dcb14a6e39f7e4608d09c2067 Mon Sep 17 00:00:00 2001 From: Sam Jones Date: Mon, 24 Jul 2023 16:06:56 +0100 Subject: [PATCH] Adding support for ADMIN_SECRET_FILE. Fixes #22 --- optfs/eduldap/lib/common | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/optfs/eduldap/lib/common b/optfs/eduldap/lib/common index b14a912..9bf1a3c 100644 --- a/optfs/eduldap/lib/common +++ b/optfs/eduldap/lib/common @@ -17,6 +17,12 @@ CONFIG_DIR=${OPENLDAP_ETC}/slapd.d DATABASE_FILE=${EDULDAP_HOME}/bootstrap/databases/${DATABASE}.ldif SEED_FILE=${EDULDAP_HOME}/bootstrap/seeds/${SEED}.ldif +ADMIN_SECRET_FILE=${ADMIN_SECRET_FILE:-"/dev/null"} + +if [[ -f $ADMIN_SECRET_FILE ]]; then + ADMIN_SECRET=`cat $ADMIN_SECRET_FILE | tr -d '\n'` +fi + ADMIN_SECRET=${ADMIN_SECRET:-`cat /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 32 | head -n 1`} DATABASE_SUFFIX=`grep olcSuffix $DATABASE_FILE | head -1 | cut -d':' -f 2 | sed 's/^ //'` ONA=$(dn_to_na $DATABASE_SUFFIX) @@ -31,4 +37,4 @@ NNA=$(dn_to_na $BASE_DN) #if [[ $EUID -ne 0 ]]; then # echo "This script must be run with root privileges (as root or via sudo)" 1>&2 # exit 1 -#fi \ No newline at end of file +#fi