Added reset-adminpassword
This commit is contained in:
parent
8bcaa40153
commit
f99f43b02f
37
bin/reset-adminpassword
Normal file
37
bin/reset-adminpassword
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
#
|
||||||
|
# Resets the LDAP admin@domain.com password
|
||||||
|
|
||||||
|
. /etc/federated
|
||||||
|
. /federated/lib/functions.sh
|
||||||
|
|
||||||
|
usage() {
|
||||||
|
cat << EOF
|
||||||
|
Reset the LDAP admin@domain.com password
|
||||||
|
Usage: $0 password
|
||||||
|
Arguments:
|
||||||
|
password - the password to set the admin@domain.com account to
|
||||||
|
|
||||||
|
EOF
|
||||||
|
exit 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
[ $# -ne 1 ] && usage
|
||||||
|
PASSWORD=$1
|
||||||
|
|
||||||
|
get_ldapdomain
|
||||||
|
[ ! -d "/federated/apps/ldap" ] && echo "* ldap is not installed." && exit 2
|
||||||
|
LDAP_BIND_PASSWORD=$(cat /federated/apps/ldap/.ldap.secret)
|
||||||
|
|
||||||
|
|
||||||
|
if [[ $LDAP_DOMIAN_MIDDLE ]]; then
|
||||||
|
echo -ne "* Resetting the LDAP admin@$LDAP_DOMAIN_FIRST.$LDAP_DOMAIN_MIDDLE.$LDAP_DOMAIN_LAST password.."
|
||||||
|
docker exec ldap ldappasswd -H ldap://localhost -D "cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST" -x -w $LDAP_BIND_PASSWORD -s $PASSWORD uid=admin,ou=people,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_MIDDLE,dc=$LDAP_DOMAIN_LAST -Z
|
||||||
|
[ $? -ne 0 ] && failcheck "* Couldn't run ldappasswd inside ldap container"
|
||||||
|
echo -ne "done.\n"
|
||||||
|
else
|
||||||
|
echo -ne "* Resetting the LDAP admin@$LDAP_DOMAIN_FIRST.$LDAP_DOMAIN_LAST password.."
|
||||||
|
docker exec ldap ldappasswd -H ldap://localhost -D "cn=admin,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST" -x -w $LDAP_BIND_PASSWORD -s $PASSWORD uid=admin,ou=people,dc=$LDAP_DOMAIN_FIRST,dc=$LDAP_DOMAIN_LAST -Z
|
||||||
|
[ $? -ne 0 ] && failcheck "* Couldn't run ldappasswd inside ldap container"
|
||||||
|
echo -ne "done.\n"
|
||||||
|
fi
|
@ -1412,3 +1412,18 @@ get_appvars_old() {
|
|||||||
# Set SMTP user based on if fcore exists
|
# Set SMTP user based on if fcore exists
|
||||||
[[ $(docker exec ldap slapcat | grep fcore) ]] && SMTPUSER="fcore" || SMTPUSER="admin"
|
[[ $(docker exec ldap slapcat | grep fcore) ]] && SMTPUSER="fcore" || SMTPUSER="admin"
|
||||||
}
|
}
|
||||||
|
get_ldapdomain() {
|
||||||
|
# Get LDAP DOMAIN from ldap its self and setup variables for each part
|
||||||
|
LDAP_DOMAIN=$(docker exec ldap slapcat | grep "dn:" | head -1 | awk -F: '{ print $2 }')
|
||||||
|
|
||||||
|
# Setup LDAP_DOMAIN variable for domain or subdomain
|
||||||
|
LDAP_DOMAIN_ARRAY=(${LDAP_DOMAIN//,/ })
|
||||||
|
if [ "${#LDAP_DOMAIN_ARRAY[@]}" -eq "2" ]; then
|
||||||
|
LDAP_DOMAIN_FIRST=$(echo "${LDAP_DOMAIN_ARRAY[0]}" | awk -F= '{ print $2 }')
|
||||||
|
LDAP_DOMAIN_LAST=$(echo "${LDAP_DOMAIN_ARRAY[1]}" | awk -F= '{ print $2 }')
|
||||||
|
elif [ "${#LDAP_DOMAIN_ARRAY[@]}" -eq "3" ]; then
|
||||||
|
LDAP_DOMAIN_FIRST=$(echo "${LDAP_DOMAIN_ARRAY[0]}" | awk -F= '{ print $2 }')
|
||||||
|
LDAP_DOMAIN_MIDDLE=$(echo "${LDAP_DOMAIN_ARRAY[1]}" | awk -F= '{ print $2 }')
|
||||||
|
LDAP_DOMAIN_LAST=$(echo "${LDAP_DOMAIN_ARRAY[2]}" | awk -F= '{ print $2 }')
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user