From ace2cd93a77eecc0b03e51d5356d4d9dde305a6c Mon Sep 17 00:00:00 2001 From: Sebastian Meyer Date: Thu, 21 Dec 2017 19:00:41 +0100 Subject: [PATCH] Make update script executable from anywhere --- update.php | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/update.php b/update.php index e3dde2a..725b411 100644 --- a/update.php +++ b/update.php @@ -59,7 +59,6 @@ if (empty($argc) || $argc != 3) { echo "\n"; echo "Example:\n"; echo " php update.php /tmp/import oai_dc\n"; - echo "\n"; exit; @@ -87,9 +86,16 @@ if (!is_dir($sourceDir) || !is_readable($sourceDir)) { $sourceDir = rtrim($sourceDir, '/').'/'; -// Check dataDir permissions +// Prepend script's path if dataDir is not an absolute path $dataDir = rtrim($config['dataDirectory'], '/').'/'.$metadataPrefix.'/'; +if (strpos($dataDir, '/') !== 0) { + + $dataDir = dirname(__FILE__).'/'.$dataDir; + +} + +// Check dataDir permissions if (!is_dir($dataDir) || !is_writable($dataDir)) { echo "Error: $dataDir not writable\n";