Skip to content

Commit

Permalink
Release 7.0.3 - See CHANGELOG.md
Browse files Browse the repository at this point in the history
  • Loading branch information
tiredofit committed Jul 26, 2020
1 parent 70b2e10 commit b8dbdef
Show file tree
Hide file tree
Showing 2 changed files with 64 additions and 0 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## 7.0.3 2020-07-26 <dave at tiredofit dot ca>

### Added
- Add change-password shell script for quickly changing config/schema passwords


## 7.0.2 2020-06-25 <dave at tiredofit dot ca>

### Added
Expand Down
58 changes: 58 additions & 0 deletions install/usr/local/bin/change-password
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#!/bin/bash

question_change_choice() {
echo "What password do you want to change? "
read -p "(C)onfig or (S)chema: " change_choice

case "$change_choice" in
"CONFIG" | "config" | "C" | "c")
change_choice="config"
;;
"SCHEMA" | "schema" | "S" | "s")
change_choice="schema"
;;
*)
echo "Unknown Selection - Exiting.."
exit 1
;;
esac
}

create_password() {
read -p "Enter Password: " password
encrypted_password=$(slappasswd -s ${password})
}

generate_ldif() {
temp_ldif=$(mktemp -q)

if [ "${change_choice}" = "config" ]; then
cat <<EOF >$temp_ldif
dn: cn=config
changeType: modify
dn: olcDatabase={0}config,cn=config
replace: olcRootPW
olcRootPW: ${encrypted_password}
EOF

else
admin_dn=$(slapcat -n 0 -a '(objectClass=olcDatabaseConfig)' | grep -E 'RootDN' | awk '/RootDN/{i++}i==2' | awk '{print $2}')
cat <<EOF >$temp_ldif
dn: olcDatabase={1}mdb,cn=config
changetype: modify
replace: olcRootPW
olcRootPW: ${encrypted_password}
EOF
fi
}

apply_ldif() {
ldapmodify -Y EXTERNAL -H ldapi:/// -f ${temp_ldif}
rm -rf ${temp_ldif}
}

question_change_choice
create_password
generate_ldif
apply_ldif

0 comments on commit b8dbdef

Please sign in to comment.