Skip to content

Commit

Permalink
Fix retrieving DBPassword when it contains a "=" (#14)
Browse files Browse the repository at this point in the history
* Fix retrieving DBPassword when it contains a "="

If your DB password contains an equal sign "=", the current `awk` code failed to retrieve the full password. AFAIK, using grep and cut is simpler than awk for this task.
  • Loading branch information
mathieumd authored Aug 31, 2022
1 parent 2702211 commit 6639681
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion zabbix-dump
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ if [[ "${READ_ZBX_CONFIG}" == "yes" && -f "${ZBX_CONFIG}" && -r "${ZBX_CONFIG}"
DBNAME="$(/usr/bin/awk -F'=' '/^DBName/{ print $2 }' "${ZBX_CONFIG}")"
DBSCHEMA="$(/usr/bin/awk -F'=' '/^DBSchema/{ print $2 }' "${ZBX_CONFIG}")"
DBUSER="$(/usr/bin/awk -F'=' '/^DBUser/{ print $2 }' "${ZBX_CONFIG}")"
DBPASS="$(/usr/bin/awk -F'=' '/^DBPassword/{ print $2 }' "${ZBX_CONFIG}")"
DBPASS="$(/usr/bin/grep '^DBPassword=' "${ZBX_CONFIG}" | /usr/bin/cut -d= -f2-)"

# set non-existing variables to their Zabbix defaults (if they are non-empty string)
[ -z ${DBHOST+x} ] && DBHOST="localhost"
Expand Down

0 comments on commit 6639681

Please sign in to comment.