Clean up local variable usage - LDAP
Change-Id: I9545884eeabcd6c41f3cc5f091a71e726dc44e87
This commit is contained in:
parent
d3121f649d
commit
ef66a77a67
30
lib/ldap
30
lib/ldap
@ -79,7 +79,7 @@ function cleanup_ldap {
|
|||||||
function init_ldap {
|
function init_ldap {
|
||||||
local keystone_ldif
|
local keystone_ldif
|
||||||
|
|
||||||
TMP_LDAP_DIR=$(mktemp -d -t ldap.$$.XXXXXXXXXX)
|
local tmp_ldap_dir=$(mktemp -d -t ldap.$$.XXXXXXXXXX)
|
||||||
|
|
||||||
# Remove data but not schemas
|
# Remove data but not schemas
|
||||||
clear_ldap_state
|
clear_ldap_state
|
||||||
@ -91,17 +91,17 @@ function init_ldap {
|
|||||||
printf "Configuring LDAP for $LDAP_BASE_DC\n"
|
printf "Configuring LDAP for $LDAP_BASE_DC\n"
|
||||||
# If BASE_DN is changed, the user may override the default file
|
# If BASE_DN is changed, the user may override the default file
|
||||||
if [[ -r $FILES/ldap/${LDAP_BASE_DC}.ldif.in ]]; then
|
if [[ -r $FILES/ldap/${LDAP_BASE_DC}.ldif.in ]]; then
|
||||||
keystone_ldif=${LDAP_BASE_DC}.ldif
|
local keystone_ldif=${LDAP_BASE_DC}.ldif
|
||||||
else
|
else
|
||||||
keystone_ldif=keystone.ldif
|
local keystone_ldif=keystone.ldif
|
||||||
fi
|
fi
|
||||||
_ldap_varsubst $FILES/ldap/${keystone_ldif}.in >$TMP_LDAP_DIR/${keystone_ldif}
|
_ldap_varsubst $FILES/ldap/${keystone_ldif}.in >$tmp_ldap_dir/${keystone_ldif}
|
||||||
if [[ -r $TMP_LDAP_DIR/${keystone_ldif} ]]; then
|
if [[ -r $tmp_ldap_dir/${keystone_ldif} ]]; then
|
||||||
ldapadd -x -w $LDAP_PASSWORD -D "$LDAP_MANAGER_DN" -H $LDAP_URL -c -f $TMP_LDAP_DIR/${keystone_ldif}
|
ldapadd -x -w $LDAP_PASSWORD -D "$LDAP_MANAGER_DN" -H $LDAP_URL -c -f $tmp_ldap_dir/${keystone_ldif}
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf TMP_LDAP_DIR
|
rm -rf $tmp_ldap_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
# install_ldap
|
# install_ldap
|
||||||
@ -110,7 +110,7 @@ function install_ldap {
|
|||||||
echo "Installing LDAP inside function"
|
echo "Installing LDAP inside function"
|
||||||
echo "os_VENDOR is $os_VENDOR"
|
echo "os_VENDOR is $os_VENDOR"
|
||||||
|
|
||||||
TMP_LDAP_DIR=$(mktemp -d -t ldap.$$.XXXXXXXXXX)
|
local tmp_ldap_dir=$(mktemp -d -t ldap.$$.XXXXXXXXXX)
|
||||||
|
|
||||||
printf "installing OpenLDAP"
|
printf "installing OpenLDAP"
|
||||||
if is_ubuntu; then
|
if is_ubuntu; then
|
||||||
@ -119,19 +119,19 @@ function install_ldap {
|
|||||||
elif is_fedora; then
|
elif is_fedora; then
|
||||||
start_ldap
|
start_ldap
|
||||||
elif is_suse; then
|
elif is_suse; then
|
||||||
_ldap_varsubst $FILES/ldap/suse-base-config.ldif.in >$TMP_LDAP_DIR/suse-base-config.ldif
|
_ldap_varsubst $FILES/ldap/suse-base-config.ldif.in >$tmp_ldap_dir/suse-base-config.ldif
|
||||||
sudo slapadd -F /etc/openldap/slapd.d/ -bcn=config -l $TMP_LDAP_DIR/suse-base-config.ldif
|
sudo slapadd -F /etc/openldap/slapd.d/ -bcn=config -l $tmp_ldap_dir/suse-base-config.ldif
|
||||||
sudo sed -i '/^OPENLDAP_START_LDAPI=/s/"no"/"yes"/g' /etc/sysconfig/openldap
|
sudo sed -i '/^OPENLDAP_START_LDAPI=/s/"no"/"yes"/g' /etc/sysconfig/openldap
|
||||||
start_ldap
|
start_ldap
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "LDAP_PASSWORD is $LDAP_PASSWORD"
|
echo "LDAP_PASSWORD is $LDAP_PASSWORD"
|
||||||
SLAPPASS=$(slappasswd -s $LDAP_PASSWORD)
|
local slappass=$(slappasswd -s $LDAP_PASSWORD)
|
||||||
printf "LDAP secret is $SLAPPASS\n"
|
printf "LDAP secret is $slappass\n"
|
||||||
|
|
||||||
# Create manager.ldif and add to olcdb
|
# Create manager.ldif and add to olcdb
|
||||||
_ldap_varsubst $FILES/ldap/manager.ldif.in >$TMP_LDAP_DIR/manager.ldif
|
_ldap_varsubst $FILES/ldap/manager.ldif.in >$tmp_ldap_dir/manager.ldif
|
||||||
sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f $TMP_LDAP_DIR/manager.ldif
|
sudo ldapmodify -Y EXTERNAL -H ldapi:/// -f $tmp_ldap_dir/manager.ldif
|
||||||
|
|
||||||
# On fedora we need to manually add cosine and inetorgperson schemas
|
# On fedora we need to manually add cosine and inetorgperson schemas
|
||||||
if is_fedora; then
|
if is_fedora; then
|
||||||
@ -139,7 +139,7 @@ function install_ldap {
|
|||||||
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif
|
sudo ldapadd -Y EXTERNAL -H ldapi:/// -f /etc/openldap/schema/inetorgperson.ldif
|
||||||
fi
|
fi
|
||||||
|
|
||||||
rm -rf TMP_LDAP_DIR
|
rm -rf $tmp_ldap_dir
|
||||||
}
|
}
|
||||||
|
|
||||||
# start_ldap() - Start LDAP
|
# start_ldap() - Start LDAP
|
||||||
|
Loading…
x
Reference in New Issue
Block a user