modernize multiple seqs and fix deprecated use of endCheckEmpty

This commit is contained in:
2022-12-12 16:42:25 +01:00
parent dbb8cac539
commit 7391de1ddd
18 changed files with 199 additions and 232 deletions

View File

@@ -1,29 +1,29 @@
#!/bin/bash
toolName="ldap"
toolDaemon="slapd"
toolDeps="$toolDaemon ldap-utils"
toolUser="openldap"
readonly toolName="ldap"
readonly toolDaemon="slapd"
readonly toolDeps="$toolDaemon ldap-utils"
readonly toolUser="openldap"
# Get script working directory
# (when called from a different directory)
WDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >>/dev/null 2>&1 && pwd )"
CONFIG=0
CONFIG_FILE_NAME="${toolName}.cfg"
CONFIG_FILE_TEMPLATE="$WDIR/${CONFIG_FILE_NAME}.example"
sq_aptOpt=
seq_config() {
initSeqConfig "$CONFIG_FILE_NAME" "$CONFIG_FILE_TEMPLATE"
if [ $? -eq 0 ] ; then
CONFIG=1
if ! initSeqConfig "${seq_configName:?}" "${seq_configTemplate:?}" ; then
# End if no configuration file exists
dry || return 1
fi
## Apt cmdline option to suppress user interaction
interactive || sq_aptOpt="-y"
return 0
}
step_1_info() { echo "$toolName installation"; }
step_1_alias() { echo "install"; }
step_1() {
exe apt update
exe apt install $toolDeps
exe apt install $toolDeps ${sq_aptOpt}
}
step_2_info() { echo "Configuration of $toolName"; }
@@ -161,7 +161,8 @@ E0F
NOTES_EOF
}
step_100_info() { echo "Add group <GROUP NAME> <USER ID>"; }
step_100_info() { echo "Add group"; }
step_100_options() { echo "<GROUP NAME> <USER ID>"; }
step_100_alias() { echo "addgroup"; }
step_100() {
shift
@@ -177,7 +178,8 @@ description: Created by $0
member: \${memberDn}
"
step_102_info() { echo "Add user <USER ID> <USER NAME> <USER LASTNAME> <UIDNUMBER> <USER EMAIL> [USER GID]"; }
step_102_info() { echo "Add user"; }
step_102_options() { echo "<USER ID> <USER NAME> <USER LASTNAME> <UIDNUMBER> <USER EMAIL> [USER GID]"; }
step_102_alias() { echo "adduser"; }
step_102() {
shift
@@ -214,7 +216,8 @@ objectClass: person
loginShell: /bin/bash
"
step_103_info() { echo "(re)Set passwort for <USER>"; }
step_103_info() { echo "(re)Set passwort for user"; }
step_103_options() { echo "<USER>"; }
step_103_alias() { echo "passwd"; }
step_103() {
shift
@@ -230,7 +233,8 @@ step_103() {
exe ldappasswd -H ldapi:/// -x -D "cn=admin,$LDAP_DC" -W -S "uid=$userId,$LDAP_OU_USERS,$LDAP_DC"
}
step_105_info() { echo "Adding <USER ID> to existing group <GROUP NAME>"; }
step_105_info() { echo "Adding user to existing group"; }
step_105_options() { echo "<USER ID> <GROUP NAME>"; }
step_105_alias() { echo "user2group"; }
step_105() {
shift
@@ -265,7 +269,8 @@ delete: member
member:
"
step_107_info() { echo "Removing <USER ID> from existing group <GROUP NAME>"; }
step_107_info() { echo "Removing user from existing group"; }
step_107_options() { echo "<USER ID> <GROUP NAME>"; }
step_107_alias() { echo "rmusergroup"; }
step_107() {
shift
@@ -299,7 +304,8 @@ delete: member
member: uid=\$userId,\$LDAP_OU_USERS,\$LDAP_DC
"
step_110_info() { echo "Remove group <GROUP NAME>"; }
step_110_info() { echo "Remove group"; }
step_110_options() { echo "<GROUP NAME>"; }
step_110_alias() { echo "rmgroup"; }
step_110() {
shift
@@ -314,7 +320,8 @@ rmGroup="dn: cn=\${groupName},\${LDAP_OU_GROUPS},\${LDAP_DC}
changetype: delete
"
step_112_info() { echo "Remove user <USER ID>"; }
step_112_info() { echo "Remove user"; }
step_112_options() { echo "<USER ID>"; }
step_112_alias() { echo "rmuser"; }
step_112() {
shift
@@ -329,7 +336,8 @@ rmUser="dn: uid=\${userName},\${LDAP_OU_USERS},\${LDAP_DC}
changetype: delete
"
step_200_info() { echo "List available groups <ADDITONAL ATTRIBUTES...>"; }
step_200_info() { echo "List available groups"; }
step_200_options() { echo "<ADDITONAL ATTRIBUTES...>"; }
step_200_alias() { echo "listgroups"; }
step_200() {
shift
@@ -337,7 +345,8 @@ step_200() {
exe ldapsearch -x -LLL -H ldap:/// -b ${LDAP_OU_GROUPS},${LDAP_DC} dn gidNumber $*
}
step_202_info() { echo "List available users <ADDITONAL ATTRIBUTES...>"; }
step_202_info() { echo "List available users"; }
step_200_options() { echo "<ADDITONAL ATTRIBUTES...>"; }
step_202_alias() { echo "listusers"; }
step_202() {
shift
@@ -364,5 +373,7 @@ variable2LdifEcho() {
echo "$tempLdif"
}
# shellcheck disable=SC2034 # Appears unused
readonly sqr_minVersion=16
# shellcheck disable=SC1091 # Don't follow this source
. /usr/local/bin/sequencer.sh