BASE_DIR=$( readlink -f . )
LDAP_USR="cn=admin"
-# LDAP_URL="ldaps://dev-ldap2.pixelpark.com"
-LDAP_URL="ldaps://prd-ds.pixelpark.com"
-# LDAP_PWD_FILE="${HOME}/.private/dirsrv-dev-dpx-admin-pwd-wonl.txt"
-LDAP_PWD_FILE="${HOME}/.private/dirsrv-prd-dpx-admin-pwd-wonl.txt"
LDAP_BASE="o=isp"
GLOBAL_SEARCH_BASE="o=isp"
DPX_SEARCH_BASE="o=Pixelpark,o=isp"
DPX_PEOPLE_SEARCH_BASE="ou=People,${DPX_SEARCH_BASE}"
SERVICE_SP_SEARCH_BASE="ou=service_sp,ou=Applications,${DPX_SEARCH_BASE}"
+ENVIRONMENT="prd"
+
+declare -A LDAP_URIS=()
+LDAP_URIS['prd']="ldaps://prd-ds.pixelpark.com"
+LDAP_URIS['test']="ldaps://test-ds.pixelpark.com"
+LDAP_URIS['dev']="ldaps://dev-ldap2.pixelpark.com"
+
+LDAP_URL="${LDAP_URIS['prd']}"
+
+declare -A LDAP_PWD_FILES=()
+LDAP_PWD_FILES['prd']="${HOME}/.private/dirsrv-prd-dpx-admin-pwd-wonl.txt"
+LDAP_PWD_FILES['test']="${HOME}/.private/dirsrv-test-dpx-admin-pwd-wonl.txt"
+LDAP_PWD_FILES['dev']="${HOME}/.private/dirsrv-dev-dpx-admin-pwd-wonl.txt"
+
+LDAP_PWD_FILE="${LDAP_PWD_FILES['prd']}"
+
OLD_IMAP_SERVER='mail-brln-store02.pixelpark.com'
-# NEW_IMAP_SERVER='dev-imap01.pixelpark.com'
-NEW_IMAP_SERVER='prd-imap01.pixelpark.com'
+
+declare -A NEW_IMAP_SERVERS=()
+NEW_IMAP_SERVERS['prd']="prd-imap01.pixelpark.com"
+NEW_IMAP_SERVERS['test']="prd-imap01.pixelpark.com"
+NEW_IMAP_SERVERS['dev']="idev-imap01.pixelpark.com"
+
+NEW_IMAP_SERVER="${NEW_IMAP_SERVERS['prd']}"
LDIF_FILE=
#------------------------------------------------------------------------------
description() {
cat <<-EOF
- Updates in NLAP the Password of Frank Brehm and moves the mailHost
- from '${OLD_IMAP_SERVER}' to '${NEW_IMAP_SERVER}'.
+
+ Updates in LDAP the passwords of the members of the department 'Betrieb',
+ adds the public SSH keys of them, adds some additional LDAP objects like groups,
+ adds standard ACIs and moves the mailHost from '${CYAN}${OLD_IMAP_SERVER}${NORMAL}' to the new one.
EOF
usage() {
cat <<-EOF
- Usage: ${BASENAME} [-s|--simulate] [-d|--debug] [[-v|--verbose] | [-q|--quiet]] [--nocolor]
+ Usage: ${BASENAME} [-E|--env ENVIRONMENT] [-s|--simulate] [-d|--debug] [[-v|--verbose] | [-q|--quiet]] [--nocolor]
${BASENAME} [-h|--help]
${BASENAME} [-V|--version]
Options:
+ -E|--env|--environment ENVIRONMENT
+ The LDAP environment to use as the target of this script.
+ Must be one of '${CYAN}prd${NORMAL}', '${CYAN}test${NORMAL}' or '${CYAN}dev${NORMAL}'. Default: '${CYAN}prod${NORMAL}'."
-s|--simulate Simulation mode, nothing is really done.
-d|--debug Debug output (bash -x).
-v|--verbose Set verbosity on.
get_options() {
local tmp=
- local short_options="sdvqhV"
- local long_options="simulate,debug,verbose,quiet,help,version"
+ local short_options="E:sdvqhV"
+ local long_options="env:,environment:,simulate,debug,verbose,quiet,help,version"
local py_version=
local py_found="n"
local ret=
ret="$?"
if [[ "${ret}" != 0 ]] ; then
echo "" >&2
- usage >&2
+ echo -e "$( usage )" >&2
exit 1
fi
set -e
while true ; do
case "$1" in
+ -E|--env|--environment)
+ ENVIRONMENT="$2"
+ shift
+ shift
+ ;;
-s|--simulate)
SIMULATE="y"
shift
shift
;;
-h|--help)
- description
+ echo -e "$( description )"
echo
- usage
+ echo -e "$( usage )"
exit 0
;;
-V|--version)
if [[ "${VERBOSE}" == "y" && "${QUIET}" == "y" ]] ; then
error "Options '${RED}--verbose${NORMAL}' and '${RED}--quiet${NORMAL}' are mutually exclusive."
echo >&2
- usage >&2
+ echo -e "$( usage )" >&2
+ exit 1
+ fi
+
+ if [[ "${ENVIRONMENT}" != 'prd' && "${ENVIRONMENT}" != 'test' && "${ENVIRONMENT}" != 'dev' ]] ; then
+ error "Wrong environment '${RED}${ENVIRONMENT}${NORMAL}' given."
+ echo >&2
+ echo -e "$( usage )" >&2
exit 1
fi
+ LDAP_URL="${LDAP_URIS[${ENVIRONMENT}]}"
+ LDAP_PWD_FILE="${LDAP_PWD_FILES[${ENVIRONMENT}]}"
+ NEW_IMAP_SERVER="${NEW_IMAP_SERVERS[${ENVIRONMENT}]}"
+
+ local msg="Environment '${CYAN}${ENVIRONMENT}${NORMAL}':\n"
+ msg+=" ${CYAN}*${NORMAL} LDAP URL: '${CYAN}${LDAP_URL}${NORMAL}'\n"
+ msg+=" ${CYAN}*${NORMAL} Password file: '${CYAN}${LDAP_PWD_FILE}${NORMAL}'\n"
+ msg+=" ${CYAN}*${NORMAL} New IMAP server: '${CYAN}${NEW_IMAP_SERVER}${NORMAL}'\n"
+
+ info "${msg}"
if [[ ! -f "${LDAP_PWD_FILE}" ]] ; then
error "Password file '${RED}${LDAP_PWD_FILE}${NORMAL}' not found" >&2
max_uid=$(( ${max_uid} + 1 ))
debug "uidNumber of pool: ${CYAN}${max_uid}${NORMAL}."
- cn=$( echo "${dn}" | sed -e 's/,.*//' | awk -F= '{ print $2 }'
+ cn=$( echo "${dn}" | sed -e 's/,.*//' | awk -F= '{ print $2 }' )
debug "Common name of pool: '${CYAN}${cn}${NORMAL}'."
cat > "${LDIF_FILE}" <<-EOF
max_gid=$(( ${max_gid} + 1 ))
debug "gidNumber of pool: ${CYAN}${max_gid}${NORMAL}."
- cn=$( echo "${dn}" | sed -e 's/,.*//' | awk -F= '{ print $2 }'
+ cn=$( echo "${dn}" | sed -e 's/,.*//' | awk -F= '{ print $2 }' )
debug "Common name of pool: '${CYAN}${cn}${NORMAL}'."
cat > "${LDIF_FILE}" <<-EOF