Put main sudoers conf in a variable
This commit is contained in:
		
							parent
							
								
									606e534f77
								
							
						
					
					
						commit
						be943b232c
					
				|  | @ -13,6 +13,7 @@ USER_ID=$(id -u) | ||||||
| BACKUP_USER_LIST="backup backuppc" | BACKUP_USER_LIST="backup backuppc" | ||||||
| 
 | 
 | ||||||
| SUDOERS_D_INCLUDE_LINE="#includedir /etc/sudoers.d" | 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_REGEXP="backuppc.*ALL.*=.*(ALL:ALL).*NOEXEC:NOPASSWD:.*/usr/bin/rsync" | ||||||
| BACKUP_SUDOERS_LINE="backup 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}" | 	line_to_check="${1}" | ||||||
| 
 | 
 | ||||||
| 	if grep -q -- "${line_to_check}" /etc/sudoers | 	if grep -q -- "${line_to_check}" "${SUDOERS_MAIN_CONF}" | ||||||
| 	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_sudoers_line() — ${line_to_check} line is available in sudo configuration." | ||||||
| 		return "${SUCCESS}" | 		return "${SUCCESS}" | ||||||
|  | @ -73,15 +74,14 @@ is_backup_sudoers_line() | ||||||
| add_sudoers_conf() | add_sudoers_conf() | ||||||
| { | { | ||||||
| 	sudoers_conf="${1}" | 	sudoers_conf="${1}" | ||||||
| 	sudoers_file="/etc/sudoers" |  | ||||||
| 
 | 
 | ||||||
| 	## Set sudoers configuration for BackupPC | 	## Set sudoers configuration for BackupPC | ||||||
| 	cat << EOF >> "${sudoers_file}" | 	cat << EOF >> "${SUDOERS_MAIN_CONF}" | ||||||
| # Added by a script | # Added by a script | ||||||
| ${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_sudoers_conf() — ${SUDOERS_MAIN_CONF} was modified." | ||||||
| } | } | ||||||
| ## ]]] | ## ]]] | ||||||
| ## Add some configuration to a specific file under sudoers.d/  [[[ | ## Add some configuration to a specific file under sudoers.d/  [[[ | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue