]> arthur.barton.de Git - MkMySqlDump.git/commitdiff
mkmysqldump: Make sure "HOME" is set correctly master github/master
authorAlexander Barton <alex@barton.de>
Thu, 28 Dec 2017 16:55:08 +0000 (17:55 +0100)
committerAlexander Barton <alex@barton.de>
Thu, 28 Dec 2017 16:55:13 +0000 (17:55 +0100)
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

index 54b8c95ac801c755c3fde298fa98cfbea4348cba..e5b8c64ecba6433df422e52c875d8ba4657c8859 100755 (executable)
@@ -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!"