From 72be4e6c62002cc363e72a98201a92acd5c35ae4 Mon Sep 17 00:00:00 2001 From: Mrityunjay Date: Mon, 15 Jun 2020 19:50:55 +0530 Subject: [PATCH] Parameter extraction path cleanup --- shared/web/interface.php | 7 +++---- shared/web/scripts/gatewayupdate.sh | 8 -------- shared/web/scripts/parameters.sh | 15 +++++++++++++++ 3 files changed, 18 insertions(+), 12 deletions(-) create mode 100644 shared/web/scripts/parameters.sh diff --git a/shared/web/interface.php b/shared/web/interface.php index 0efa343..7236634 100644 --- a/shared/web/interface.php +++ b/shared/web/interface.php @@ -15,6 +15,7 @@ $stopScript = $scriptsBase . DIRECTORY_SEPARATOR . 'gatewaystop.sh' ; $updateScript = $scriptsBase . DIRECTORY_SEPARATOR . 'gatewayupdate.sh' ; $isRunning = $scriptsBase . DIRECTORY_SEPARATOR . 'isRunning.sh' ; + $parameters = $scriptsBase . DIRECTORY_SEPARATOR . 'parameters.sh' ; $dockerConfigFile = 'gateway/config.yaml'; logMessage("------------------------------------------------------------------------------"); logMessage("Platform Base($platformBase), ModuleBase($moduleBase) scriptBase($scriptsBase)"); @@ -167,7 +168,7 @@ function restartGateway() { function configureGateway($port,$satellite,$apiKey,$passphrase){ global $file; global $output; - global $configureScript, $moduleBase; + global $configureScript, $moduleBase, $parameters; $jsonString = file_get_contents($file); $data = json_decode($jsonString, true); @@ -191,9 +192,7 @@ function configureGateway($port,$satellite,$apiKey,$passphrase){ $secretkey = ""; header('Content-Type: text/plain'); - - //$contents = shell_exec('export PATH=$PATH:/share/CACHEDEV1_DATA/.qpkg/container-station/bin ; docker run --rm -v $(pwd)/gateway:/root/.local/share/storj/gateway --entrypoint /bin/cat storjlabs/gateway:latest /root/.local/share/storj/gateway/config.yaml 2>&1 '); - + $contents = shell_exec("/bin/bash $parameters 2>&1 "); $pattern = preg_quote($searchaccesskey, '/'); $pattern = "/^\s*${pattern}\s*:.*\$/m"; diff --git a/shared/web/scripts/gatewayupdate.sh b/shared/web/scripts/gatewayupdate.sh index 49037d7..9739215 100644 --- a/shared/web/scripts/gatewayupdate.sh +++ b/shared/web/scripts/gatewayupdate.sh @@ -11,14 +11,6 @@ setupEnv LOG=$LOGFILE -if [[ $# -lt 1 ]] -then - msg="Not enough parameters to run gateway" - echo $msg - echo $msg >> $LOG - exit 1 -fi - echo $(date) $PKGNAME " docker container updater script running " >> $LOG export PATH=$PATH:${SYS_QPKG_INSTALL_PATH}/container-station/bin diff --git a/shared/web/scripts/parameters.sh b/shared/web/scripts/parameters.sh new file mode 100644 index 0000000..75786e9 --- /dev/null +++ b/shared/web/scripts/parameters.sh @@ -0,0 +1,15 @@ +#!/bin/bash +# This script extracts the secret key and access key of the gateway +function setupEnv() { + dirpath=$(dirname $0) + export PATH=$PATH:$dirpath + . common.sh +} +setupEnv + +LOG=$LOGFILE +echo $(date) "Gateway parameter extraction" >> $LOG +export PATH=$PATH:${SYS_QPKG_INSTALL_PATH}/container-station/bin +moduleBase=${WEB_PATH}/${PKGNAME} +docker run --rm -v ${moduleBase}/gateway:/root/.local/share/storj/gateway --entrypoint /bin/cat storjlabs/gateway:latest /root/.local/share/storj/gateway/config.yaml +