[ 
https://issues.apache.org/jira/browse/KNOX-3024?focusedWorklogId=910850&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-910850
 ]

ASF GitHub Bot logged work on KNOX-3024:
----------------------------------------

                Author: ASF GitHub Bot
            Created on: 21/Mar/24 10:43
            Start Date: 21/Mar/24 10:43
    Worklog Time Spent: 10m 
      Work Description: smolnar82 opened a new pull request, #891:
URL: https://github.com/apache/knox/pull/891

   ## What changes were proposed in this pull request?
   
   I updated the existing login in `knox-functions.sh` to successfully check 
Java executables under `/usr` if no `JAVA_HOME` is set or Java is not available 
on the path.
   In addition to fixing the issue, I added an option to display the Java with 
the `--verbose` option (when using KnoxCLI, `--verbose true` should be used.
   
   ## How was this patch tested?
   
   Checked the updated scripts on [shellcheck.net](https://www.shellcheck.net/) 
and tested them manually:
   - `gateway.sh`
   ```
   $ bin/gateway.sh restart --verbose
   Found Java at /usr/local/opt/openjdk@8/bin/java
   Stopping Gateway with PID 12173 succeeded.
   Starting Gateway succeeded with PID 12346.
   
   $ bin/gateway.sh restart
   Stopping Gateway with PID 12346 succeeded.
   Starting Gateway succeeded with PID 12419.
   ```
   - `knoxcli.sh`
   ```
   $ bin/knoxcli.sh export-cert --type JKS --verbose true
   Found Java at /usr/local/opt/openjdk@8/bin/java
   Certificate gateway-identity has been successfully exported to: 
/Users/sandormolnar/test/knoxGateway/data/security/keystores/gateway-client-trust.jks
   
   $ bin/knoxcli.sh export-cert --type JKS
   Certificate gateway-identity has been successfully exported to: 
/Users/sandormolnar/test/knoxGateway/data/security/keystores/gateway-client-trust.jks
   ```
   - `ldap.sh`
   ```
   $ bin/ldap.sh start --verbose
   Found Java at /usr/local/opt/openjdk@8/bin/java
   Starting LDAP succeeded with PID 12531.
   
   $ bin/ldap.sh stop
   Stopping LDAP with PID 12531 succeeded.
   
   $ bin/ldap.sh start
   Starting LDAP succeeded with PID 12573.
   ```




Issue Time Tracking
-------------------

            Worklog Id:     (was: 910850)
    Remaining Estimate: 0h
            Time Spent: 10m

> Fix findJava in knox-functions.sh
> ---------------------------------
>
>                 Key: KNOX-3024
>                 URL: https://issues.apache.org/jira/browse/KNOX-3024
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: Release
>    Affects Versions: 1.4.0, 1.5.0, 2.0.0, 1.6.0, 1.6.1, 1.6.2
>            Reporter: Sandor Molnar
>            Assignee: Sandor Molnar
>            Priority: Blocker
>             Fix For: 2.1.0
>
>          Time Spent: 10m
>  Remaining Estimate: 0h
>
> 5 years ago, when I added {{shellcheck}} support to our build in the scope of 
> KNOX-1816, I introduced a bug in the {{findJava}} function in 
> {{{}knox-functions.sh{}}}: when $JAVA_HOME is not set, and Java is not 
> available on the path, the function tries to find java executables under 
> {{{}/usr{}}}. However, the current implementation is wrong:
> {noformat}
> $ which java
> /usr/bin/which: no java in 
> (/usr/lib64/qt-3.3/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin)
> $ echo $JAVA_HOME
> $ bin/knoxcli.sh export-cert --type JKS
> Warning: JAVA is not set and could not be found.
> ...  {noformat}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to