Set an explicit name for the functions
This commit is contained in:
parent
c1e7d54ad1
commit
d89625df6f
|
@ -36,21 +36,21 @@ is_backup_user() ## [[[
|
|||
exit "${ERROR}"
|
||||
}
|
||||
## ]]]
|
||||
is_sudoers_line() ## [[[
|
||||
is_backup_sudoers_line() ## [[[
|
||||
{
|
||||
line_to_check="${1}"
|
||||
|
||||
if grep -Rq -- "${line_to_check}" /etc/sudoers.d/
|
||||
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}"
|
||||
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}"
|
||||
fi
|
||||
}
|
||||
## ]]]
|
||||
add_sudoers_conf() ## [[[
|
||||
add_backup_sudoers_conf() ## [[[
|
||||
{
|
||||
sudoers_conf="${1}"
|
||||
sudoers_file="${2}"
|
||||
|
@ -66,7 +66,7 @@ add_sudoers_conf() ## [[[
|
|||
${sudoers_conf}
|
||||
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}"
|
||||
|
||||
# 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
|
||||
[ "${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_conf "${BACKUP_SUDOERS_LINE}" "${BACKUP_SUDOERS_FILE}"
|
||||
add_backup_sudoers_conf "${BACKUP_SUDOERS_LINE}" "${BACKUP_SUDOERS_FILE}"
|
||||
|
||||
## 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
|
||||
[ "${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."
|
||||
|
|
Loading…
Reference in New Issue