Set an explicit name for the functions

This commit is contained in:
Jeremy Gardais 2019-05-28 14:10:47 +02:00
parent c1e7d54ad1
commit d89625df6f
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 8 additions and 8 deletions

View File

@ -36,21 +36,21 @@ is_backup_user() ## [[[
exit "${ERROR}" exit "${ERROR}"
} }
## ]]] ## ]]]
is_sudoers_line() ## [[[ is_backup_sudoers_line() ## [[[
{ {
line_to_check="${1}" line_to_check="${1}"
if grep -Rq -- "${line_to_check}" /etc/sudoers.d/ if grep -Rq -- "${line_to_check}" /etc/sudoers.d/
then then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Function is_sudoers_line() — ${line_to_check} line is available in sudo configuration." [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Function is_backup_sudoers_line() — ${line_to_check} line is available in sudo configuration."
return "${SUCCESS}" return "${SUCCESS}"
else else
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Function is_sudoers_line() — ${line_to_check} was not found in sudo configuration." [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Function is_backup_sudoers_line() — ${line_to_check} was not found in sudo configuration."
return "${ERROR}" return "${ERROR}"
fi fi
} }
## ]]] ## ]]]
add_sudoers_conf() ## [[[ add_backup_sudoers_conf() ## [[[
{ {
sudoers_conf="${1}" sudoers_conf="${1}"
sudoers_file="${2}" sudoers_file="${2}"
@ -66,7 +66,7 @@ add_sudoers_conf() ## [[[
${sudoers_conf} ${sudoers_conf}
EOF EOF
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Function add_sudoers_conf() — ${sudoers_file} was modified." [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Function add_backup_sudoers_conf() — ${sudoers_file} was modified."
} }
## ]]] ## ]]]
# ]]] # ]]]
@ -83,14 +83,14 @@ fi
is_backup_user "${BACKUP_USER_LIST}" is_backup_user "${BACKUP_USER_LIST}"
# Test if sudoers conf is already set # Test if sudoers conf is already set
if ! is_sudoers_line "${BACKUP_SUDOERS_LINE_REGEXP}" if ! is_backup_sudoers_line "${BACKUP_SUDOERS_LINE_REGEXP}"
then then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: First try — ${BACKUP_SUDOERS_LINE_REGEXP} was not found in sudo configuration." [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: First try — ${BACKUP_SUDOERS_LINE_REGEXP} was not found in sudo configuration."
## Add sudoers configuration ## Add sudoers configuration
add_sudoers_conf "${BACKUP_SUDOERS_LINE}" "${BACKUP_SUDOERS_FILE}" add_backup_sudoers_conf "${BACKUP_SUDOERS_LINE}" "${BACKUP_SUDOERS_FILE}"
## Test if sudoers conf was successfully modified ## Test if sudoers conf was successfully modified
if ! is_sudoers_line "${BACKUP_SUDOERS_LINE_REGEXP}" if ! is_backup_sudoers_line "${BACKUP_SUDOERS_LINE_REGEXP}"
then then
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Second try — ${BACKUP_SUDOERS_LINE_REGEXP} was not found in sudo configuration." [ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG: Second try — ${BACKUP_SUDOERS_LINE_REGEXP} was not found in sudo configuration."
printf '\e[1;31m%-6s\e[m\n' "ERROR: The sudo configuration was not successfully modified." printf '\e[1;31m%-6s\e[m\n' "ERROR: The sudo configuration was not successfully modified."