QUIET='n'
SIMULATE='n'
-VERSION="2.3"
+VERSION="3.3"
# console colors:
RED=""
}
+#------------------------------------------------
+add_additional_group() {
+
+ local ldif_file="$1"
+ local dn=
+ local cmd=
+ local value=
+
+ empty_line
+
+ dn=$( cat "${ldif_file}" | grep -i "^dn:" | sed -e 's/^dn:[ ][ ]*//i' )
+ debug "Checking for group '${CYAN}${dn}${NORMAL}' ..."
+ cmd="ldapsearch -x -LLL -o ldif-wrap=no -H '${LDAP_URL}' "
+ cmd+="-b \"${dn}\" -x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\" "
+ cmd+="\"(objectClass=*)\" dn | grep -i '^dn:'"
+ # debug "Executing: ${cmd}"
+ value=$( eval ${cmd} || true )
+
+ if [[ -n "${value}" ]] ; then
+ info "Group '${CYAN}${dn}${NORMAL}' is already existing."
+ return 0
+ fi
+
+ info "Creating group '${CYAN}${dn}${NORMAL}' ..."
+
+ cmd="ldapadd -H \"${LDAP_URL}\" -x -D \"${LDAP_USR}\" -y \"${LDAP_PWD_FILE}\""
+ cmd+=" -f \"${ldif_file}\""
+ # debug "Executing: ${cmd}"
+ if [[ "${SIMULATE}" != "y" ]] ; then
+ eval $cmd
+ fi
+ debug "Done."
+
+}
+
+#------------------------------------------------
+adding_additional_groups() {
+
+ empty_line
+ draw_line
+ info "Adding additional groups ..."
+
+ local ldif_dir="etc/additional_groups"
+
+ if [[ ! -d "${ldif_dir}" ]] ; then
+ error "Directory for additional group definitions '${RED}${ldif_dir}${NORMAL}' not found."
+ exit 8
+ fi
+
+ local ldif_file=
+
+ for ldif_file in "${ldif_dir}"/*.ldif ; do
+ add_additional_group "${ldif_file}"
+ done
+
+}
+
#------------------------------------------------
main() {
update_passwords
update_all_mailhosts
update_all_public_sshkeys
+ adding_additional_groups
empty_line
info "Finished."