Put main sudoers conf in a variable

This commit is contained in:
Jeremy Gardais 2019-05-28 14:53:39 +02:00
parent 606e534f77
commit be943b232c
Signed by: jegardai
GPG Key ID: E759BAA22501AF32
1 changed files with 4 additions and 4 deletions

View File

@ -13,6 +13,7 @@ USER_ID=$(id -u)
BACKUP_USER_LIST="backup backuppc"
SUDOERS_D_INCLUDE_LINE="#includedir /etc/sudoers.d"
SUDOERS_MAIN_CONF="/etc/sudoers"
BACKUP_SUDOERS_LINE_REGEXP="backuppc.*ALL.*=.*(ALL:ALL).*NOEXEC:NOPASSWD:.*/usr/bin/rsync"
BACKUP_SUDOERS_LINE="backup ALL=(ALL:ALL) NOEXEC:NOPASSWD: /usr/bin/rsync
@ -44,7 +45,7 @@ is_sudoers_line()
{
line_to_check="${1}"
if grep -q -- "${line_to_check}" /etc/sudoers
if grep -q -- "${line_to_check}" "${SUDOERS_MAIN_CONF}"
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."
return "${SUCCESS}"
@ -73,15 +74,14 @@ is_backup_sudoers_line()
add_sudoers_conf()
{
sudoers_conf="${1}"
sudoers_file="/etc/sudoers"
## Set sudoers configuration for BackupPC
cat << EOF >> "${sudoers_file}"
cat << EOF >> "${SUDOERS_MAIN_CONF}"
# Added by a script
${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_sudoers_conf() — ${SUDOERS_MAIN_CONF} was modified."
}
## ]]]
## Add some configuration to a specific file under sudoers.d/ [[[