Skip to content

Commit

Permalink
Adding support for ADMIN_SECRET_FILE. Fixes Digital-Identity-Labs#22
Browse files Browse the repository at this point in the history
  • Loading branch information
Sam Jones committed Jul 24, 2023
1 parent d75ff7d commit 2b94674
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion optfs/eduldap/lib/common
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
#fi

0 comments on commit 2b94674

Please sign in to comment.