Test if ldapsearch is available

This commit is contained in:
Jeremy Gardais 2021-11-19 15:05:03 +01:00
parent 29e64cc35d
commit 1781803123
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 27 additions and 0 deletions

View File

@ -183,10 +183,37 @@ is_var_empty_silent() { # {{{
return "${return_var_empty_silent}"
}
# }}}
is_command_available() { # {{{
local_command_available_cmd="${1}"
## Return False by default
return_command_available="1"
if [ "$(command -v ${local_command_available_cmd})" ]; then
debug_message "is_command_available \
${RED}${local_command_available_cmd}${COLOR_DEBUG} seems present on this host."
return_command_available="0"
else
debug_message "is_command_available \
${RED}${local_command_available_cmd}${COLOR_DEBUG} is not available on this host."
return_command_available="1"
fi
return "${return_command_available}"
}
# }}}
main() { # {{{
## If ldapsearch command is not available {{{
### exit with message and error
is_command_available "ldapsearch" \
|| error_message "ldapsearch command doesn't seems to be available. Please install ldap-utils package." "3"
## }}}
## Define all vars
define_vars