Test is_sudoers_line result
This commit is contained in:
parent
8bc6853b6c
commit
e21864990d
|
@ -21,10 +21,10 @@ is_user() ## [[[
|
|||
user_to_check="${1}"
|
||||
|
||||
if [ "$(id -- "${user_to_check}" 2> /dev/null)" ] ; then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${user_to_check} user is available."
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Function — ${user_to_check} user is available."
|
||||
return "${SUCCESS}"
|
||||
else
|
||||
printf '\e[1;31m%-6s\e[m\n' "ERROR : ${user_to_check} user is unavailable."
|
||||
printf '\e[1;31m%-6s\e[m\n' "ERROR : Function — ${user_to_check} user is unavailable."
|
||||
exit "${ERROR}"
|
||||
fi
|
||||
}
|
||||
|
@ -35,10 +35,10 @@ is_sudoers_line() ## [[[
|
|||
|
||||
if grep -Rq -- "${line_to_check}" /etc/sudoers.d/
|
||||
then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${line_to_check} line is available in sudo configuration."
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Function — ${line_to_check} line is available in sudo configuration."
|
||||
return "${SUCCESS}"
|
||||
else
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${line_to_check} was not found in sudo configuration."
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : Function — ${line_to_check} was not found in sudo configuration."
|
||||
return "${ERROR}"
|
||||
fi
|
||||
}
|
||||
|
@ -55,7 +55,14 @@ fi
|
|||
|
||||
is_user "${BACKUP_USER_LOGIN}"
|
||||
|
||||
is_sudoers_line "${SUDOERS_LINE_REGEXP}"
|
||||
if is_sudoers_line "${SUDOERS_LINE_REGEXP}"
|
||||
then
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : ${SUDOERS_LINE_REGEXP} is already set in sudo configuration."
|
||||
printf '%b\n' "Your configuration is set up."
|
||||
exit 0
|
||||
else
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : First try — ${SUDOERS_LINE_REGEXP} was not found in sudo configuration."
|
||||
fi
|
||||
|
||||
[ "${DEBUG}" -eq "0" ] && printf '\e[1;35m%-6s\e[m\n' "DEBUG : End"
|
||||
|
||||
|
|
Loading…
Reference in New Issue