-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Convert license tools to use unified cli entrypoint (#85919)
The license tools exists separate from the normal cli tools since they are not part of the Elasticsearch distribution. However, they still utilize the Elasticsearch cli infrastructure. This commit adds a common cli base script that calls the cli launcher and converts each of the license tools to use it. relates #85758
- Loading branch information
Showing
12 changed files
with
123 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,3 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
# or more contributor license agreements. Licensed under the Elastic License | ||
# 2.0; you may not use this file except in compliance with the Elastic License | ||
# 2.0. | ||
|
||
CDPATH="" | ||
SCRIPT="$0" | ||
|
||
# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path. | ||
while [ -h "$SCRIPT" ] ; do | ||
ls=`ls -ld "$SCRIPT"` | ||
# Drop everything prior to -> | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
SCRIPT="$link" | ||
else | ||
SCRIPT=`dirname "$SCRIPT"`/"$link" | ||
fi | ||
done | ||
|
||
# determine license home | ||
LICENSE_HOME=`dirname "$SCRIPT"`/.. | ||
|
||
# make LICENSE_HOME absolute | ||
LICENSE_HOME=`cd "$LICENSE_HOME"; pwd` | ||
|
||
# setup classpath | ||
LICENSE_CLASSPATH=$LICENSE_CLASSPATH:$LICENSE_HOME/lib/* | ||
|
||
if [ -x "$JAVA_HOME/bin/java" ]; then | ||
JAVA=$JAVA_HOME/bin/java | ||
else | ||
JAVA=`which java` | ||
fi | ||
|
||
exec "$JAVA" $JAVA_OPTS -Xmx64m -Xms16m -cp "$LICENSE_CLASSPATH" -Des.path.home="`pwd`" org.elasticsearch.license.licensor.tools.KeyPairGeneratorTool "$@" | ||
|
||
source "`dirname "$0"`"/license-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
# or more contributor license agreements. Licensed under the Elastic License | ||
# 2.0; you may not use this file except in compliance with the Elastic License | ||
# 2.0. | ||
|
||
CDPATH="" | ||
SCRIPT="$0" | ||
|
||
# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path. | ||
while [ -h "$SCRIPT" ] ; do | ||
ls=`ls -ld "$SCRIPT"` | ||
# Drop everything prior to -> | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
SCRIPT="$link" | ||
else | ||
SCRIPT=`dirname "$SCRIPT"`/"$link" | ||
fi | ||
done | ||
|
||
# determine license home | ||
LICENSE_HOME=`dirname "$SCRIPT"`/.. | ||
# make LICENSE_HOME absolute | ||
LICENSE_HOME=`cd "$LICENSE_HOME"; pwd` | ||
|
||
# setup classpath | ||
LICENSE_CLASSPATH=$LICENSE_CLASSPATH:$LICENSE_HOME/lib/* | ||
|
||
if [ -x "$JAVA_HOME/bin/java" ]; then | ||
JAVA=$JAVA_HOME/bin/java | ||
else | ||
JAVA=`which java` | ||
fi | ||
|
||
JAVA_OPTS="$JAVA_OPTS -Xmx64m -Xms16m" | ||
CLI_NAME=$(basename $0) | ||
|
||
exec \ | ||
"$JAVA" \ | ||
$JAVA_OPTS \ | ||
-Dcli.name="$CLI_NAME" \ | ||
-Des.path.home="`pwd`" \ | ||
-cp "$LICENSE_CLASSPATH" \ | ||
org.elasticsearch.launcher.CliToolLauncher \ | ||
"$@" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,38 +1,3 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
# or more contributor license agreements. Licensed under the Elastic License | ||
# 2.0; you may not use this file except in compliance with the Elastic License | ||
# 2.0. | ||
|
||
CDPATH="" | ||
SCRIPT="$0" | ||
|
||
# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path. | ||
while [ -h "$SCRIPT" ] ; do | ||
ls=`ls -ld "$SCRIPT"` | ||
# Drop everything prior to -> | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
SCRIPT="$link" | ||
else | ||
SCRIPT=`dirname "$SCRIPT"`/"$link" | ||
fi | ||
done | ||
|
||
# determine license home | ||
LICENSE_HOME=`dirname "$SCRIPT"`/.. | ||
|
||
# make LICENSE_HOME absolute | ||
LICENSE_HOME=`cd "$LICENSE_HOME"; pwd` | ||
|
||
# setup classpath | ||
LICENSE_CLASSPATH=$LICENSE_CLASSPATH:$LICENSE_HOME/lib/* | ||
|
||
if [ -x "$JAVA_HOME/bin/java" ]; then | ||
JAVA=$JAVA_HOME/bin/java | ||
else | ||
JAVA=`which java` | ||
fi | ||
|
||
exec "$JAVA" $JAVA_OPTS -Xmx64m -Xms16m -cp "$LICENSE_CLASSPATH" -Des.path.home="`pwd`" org.elasticsearch.license.licensor.tools.LicenseGeneratorTool "$@" | ||
source "`dirname "$0"`"/license-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,3 @@ | ||
#!/bin/bash | ||
|
||
# Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
# or more contributor license agreements. Licensed under the Elastic License | ||
# 2.0; you may not use this file except in compliance with the Elastic License | ||
# 2.0. | ||
|
||
CDPATH="" | ||
SCRIPT="$0" | ||
|
||
# SCRIPT may be an arbitrarily deep series of symlinks. Loop until we have the concrete path. | ||
while [ -h "$SCRIPT" ] ; do | ||
ls=`ls -ld "$SCRIPT"` | ||
# Drop everything prior to -> | ||
link=`expr "$ls" : '.*-> \(.*\)$'` | ||
if expr "$link" : '/.*' > /dev/null; then | ||
SCRIPT="$link" | ||
else | ||
SCRIPT=`dirname "$SCRIPT"`/"$link" | ||
fi | ||
done | ||
|
||
# determine license home | ||
LICENSE_HOME=`dirname "$SCRIPT"`/.. | ||
|
||
# make LICENSE_HOME absolute | ||
LICENSE_HOME=`cd "$LICENSE_HOME"; pwd` | ||
|
||
# setup classpath | ||
LICENSE_CLASSPATH=$LICENSE_CLASSPATH:$LICENSE_HOME/lib/* | ||
|
||
if [ -x "$JAVA_HOME/bin/java" ]; then | ||
JAVA=$JAVA_HOME/bin/java | ||
else | ||
JAVA=`which java` | ||
fi | ||
|
||
exec "$JAVA" $JAVA_OPTS -Xmx64m -Xms16m -cp "$LICENSE_CLASSPATH" -Des.path.home="`pwd`" org.elasticsearch.license.licensor.tools.LicenseVerificationTool "$@" | ||
|
||
source "`dirname "$0"`"/license-cli |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../src/main/java/org/elasticsearch/license/licensor/tools/KeyPairGeneratorToolProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.license.licensor.tools; | ||
|
||
import org.elasticsearch.cli.CliToolProvider; | ||
import org.elasticsearch.cli.Command; | ||
|
||
public class KeyPairGeneratorToolProvider implements CliToolProvider { | ||
@Override | ||
public String name() { | ||
return "key-pair-generator"; | ||
} | ||
|
||
@Override | ||
public Command create() { | ||
return new KeyPairGeneratorTool(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
.../src/main/java/org/elasticsearch/license/licensor/tools/LicenseGeneratorToolProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.license.licensor.tools; | ||
|
||
import org.elasticsearch.cli.CliToolProvider; | ||
import org.elasticsearch.cli.Command; | ||
|
||
public class LicenseGeneratorToolProvider implements CliToolProvider { | ||
@Override | ||
public String name() { | ||
return "license-generator"; | ||
} | ||
|
||
@Override | ||
public Command create() { | ||
return new LicenseGeneratorTool(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...c/main/java/org/elasticsearch/license/licensor/tools/LicenseVerificationToolProvider.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
package org.elasticsearch.license.licensor.tools; | ||
|
||
import org.elasticsearch.cli.CliToolProvider; | ||
import org.elasticsearch.cli.Command; | ||
|
||
public class LicenseVerificationToolProvider implements CliToolProvider { | ||
@Override | ||
public String name() { | ||
return "verify-license"; | ||
} | ||
|
||
@Override | ||
public Command create() { | ||
return new LicenseVerificationTool(); | ||
} | ||
} |
3 changes: 3 additions & 0 deletions
3
.../license-tools/src/main/resources/META-INF/services/org.elasticsearch.cli.CliToolProvider
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
org.elasticsearch.license.licensor.tools.LicenseGeneratorToolProvider | ||
org.elasticsearch.license.licensor.tools.LicenseVerificationToolProvider | ||
org.elasticsearch.license.licensor.tools.KeyPairGeneratorToolProvider |