From 6f7fb5e294c8b2d6ff1414c60c9346bb2546fa58 Mon Sep 17 00:00:00 2001 From: Alexander Barton Date: Thu, 28 Dec 2017 17:55:08 +0100 Subject: [PATCH] mkmysqldump: Make sure "HOME" is set correctly This is required for mysql(1) to find its user configuration files, for example, and is not the case when run by a systemd(8) unit. --- bin/mkmysqldump | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/bin/mkmysqldump b/bin/mkmysqldump index 54b8c95..e5b8c64 100755 --- a/bin/mkmysqldump +++ b/bin/mkmysqldump @@ -55,6 +55,11 @@ ErrorNotice() { echo } +# Make sure the environment is "sane", for example, mysql(1) depends on the +# HOME environment variable to be set. +[ -n "$HOME" ] || HOME=$( getent passwd "${LOGNAME:-root}" | cut -d: -f6 ) +export HOME + for cmd in mysql mysqldump; do if ! which "$cmd" >/dev/null 2>&1; then echo "$NAME: \"$cmd\" command not found!" -- 2.39.2