You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@knox.apache.org by "Kevin Risden (JIRA)" <ji...@apache.org> on 2019/03/22 21:15:00 UTC

[jira] [Commented] (KNOX-1833) Knox gateway couldn't come up when ran on Korn Shell

    [ https://issues.apache.org/jira/browse/KNOX-1833?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16799357#comment-16799357 ] 

Kevin Risden commented on KNOX-1833:
------------------------------------

The shebang at the top of the *.sh scripts is "#!/usr/bin/env bash" so that would show this is executed in bash. How are you executing this script that it is missing the shebang at the top of the script?

> Knox gateway couldn't come up when ran on Korn Shell 
> -----------------------------------------------------
>
>                 Key: KNOX-1833
>                 URL: https://issues.apache.org/jira/browse/KNOX-1833
>             Project: Apache Knox
>          Issue Type: Improvement
>          Components: KnoxShell
>    Affects Versions: 1.2.0, 1.3.0
>         Environment: Knox
> Korn Shell
>            Reporter: Sarah S
>            Priority: Minor
>
> {{APP_BIN_DIR="$( cd "$( dirname "$\{BASH_SOURCE[0]}" )" && pwd )"}}
> When the script is running in Korn shell, $\{BASH_SOURCE[0]} is always empty and this is because $\{BASH_SOURCE[0]} is valid only for Bash shell. Thus, the path is not constructed correctly. Later on when we have any other installation scripts running, it is unable to find gateway.sh since the Bash Source is not inclusive of Korn shell path to the gateway.sh.  
> However we did find a work around for it. A simple script has to be added into the gateway.sh script. It basically checks for two kinds of shells: either Bash or Korn and then adds the path according to whatever the type is. Here's what the code snippet looks like: 
>  
> {code:java}
> if [ $SHELL == '/bin/bash' ] || [ $SHELL == '/bin/sh' ] 
> then 
>   THIS_SCRIPT=${BASH_SOURCE[0]} 
>   echo $THIS_SCRIPT 
> elif [ $SHELL == '/bin/ksh' ] 
> then 
>   THIS_SCRIPT=${.sh.file} 
>   echo $THIS_SCRIPT 
> else echo NO MATCH. 
> fi 
> APP_BIN_DIR="$( cd "$( dirname ${THIS_SCRIPT} )" && pwd )"
> {code}



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)