Skip to content

Commit

Permalink
[script] added helper script to avoid code duplication; removed unnee…
Browse files Browse the repository at this point in the history
…ded scripts.
  • Loading branch information
EskoDijk committed Jun 27, 2024
1 parent fb5a047 commit 9d64169
Show file tree
Hide file tree
Showing 17 changed files with 95 additions and 210 deletions.
8 changes: 0 additions & 8 deletions script/build-docker-image.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,8 @@

set -e

## This is not a public repository, make sure you have the access!
readonly TRI_REPO=git@bitbucket.org:threadgroup/tce-registrar-java.git

readonly IMAGE_NAME=ot-registrar

if [ ! -d tri ]; then
echo "cloning 'tce-registrar-java' into 'tri'..."
git clone $TRI_REPO tri
fi

# Enable ipv6
if [ ! -f /etc/docker/daemon.json ]; then
echo "enabling ipv6 for docker ..."
Expand Down
2 changes: 1 addition & 1 deletion script/cose-validator.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,4 @@
# POSSIBILITY OF SUCH DAMAGE.
#

java -cp target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar com.google.openthread.tools.CoseValidator $1 $2
./script/helper-cp-run.sh com.google.openthread.tools.CoseValidator $@
31 changes: 29 additions & 2 deletions script/create-keystore-ietf-draft-constrained-brski.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,36 @@
#!/bin/bash
#
# Copyright (c) 2022, The OpenThread Registrar Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#
CREDS=./credentials/ietf-draft-constrained-brski
echo "Creating .p12 keystore file for credentials in $CREDS ..."
java -cp target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar com.google.openthread.tools.CredentialGenerator \
./script/helper-cp-run.sh com.google.openthread.tools.CredentialGenerator \
-c $CREDS/domain_ca.pem $CREDS/privkey_domain_ca.pem \
-r $CREDS/registrar.pem $CREDS/privkey_registrar.pem \
-m $CREDS/masa_ca.pem $CREDS/privkey_masa_ca.pem \
-p $CREDS/pledge.pem $CREDS/privkey_pledge.pem \
-o ./credentials/keystore_ietf-draft-constrained-brski.p12
-o ./credentials/keystore_ietf-draft-constrained-brski.p12
10 changes: 2 additions & 8 deletions script/create-pledge-credentials-p12-honeydukes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,8 @@

# This script is to run the Java Pledge with Honeydukes IDevID.
# The Honeydukes test vendor/MASA is located at: https://honeydukes.sandelman.ca/
readonly JAR_FILE=./target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar

readonly CREDENTIAL=./credentials/honeydukes/credentials.p12
readonly CRED_DIR=./credentials/honeydukes

# test if build JAR exists
if [ ! -f "${JAR_FILE}" ]; then
echo "Please build using 'mvn -DskipTests package' before running; and run this script from base directory of repo."
exit 1
fi

java -cp $JAR_FILE com.google.openthread.tools.CredentialGenerator -m $CRED_DIR/vendor.crt -p $CRED_DIR/device.crt $CRED_DIR/key.pem -o $CREDENTIAL
./script/helper-cp-run.sh com.google.openthread.tools.CredentialGenerator -m $CRED_DIR/vendor.crt -p $CRED_DIR/device.crt $CRED_DIR/key.pem -o $CREDENTIAL
9 changes: 1 addition & 8 deletions script/create-pledge-credentials-p12-iotconsultancy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -28,17 +28,10 @@
#

# This script is to run the Java Pledge with IoTconsultancy IDevID.
readonly JAR_FILE=./target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar
readonly CRED_DIR=./credentials/iotconsultancy-masa
readonly CREDENTIAL=${CRED_DIR}/credentials.p12

# test if build JAR exists
if [ ! -f "${JAR_FILE}" ]; then
echo "Please build using 'mvn -DskipTests package' before running; and run this script from base directory of repo."
exit 1
fi

java -cp $JAR_FILE com.google.openthread.tools.CredentialGenerator \
./script/helper-cp-run.sh com.google.openthread.tools.CredentialGenerator \
-ms $CRED_DIR/TestVendor_masa.pem $CRED_DIR/privkey_TestVendor_masa.pem \
-m $CRED_DIR/TestVendor_masa_ca.pem $CRED_DIR/privkey_TestVendor_masa_ca.pem \
-p $CRED_DIR/TestVendor_1.pem $CRED_DIR/privkey_TestVendor_1.pem \
Expand Down
9 changes: 1 addition & 8 deletions script/create-pledge-credentials-p12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,7 @@
# POSSIBILITY OF SUCH DAMAGE.
#

readonly JAR_FILE=./target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar
readonly CREDENTIAL=./credentials/pledge_credentials.p12
readonly CRED_DIR=./credentials/local-masa

# test if build JAR exists
if [ ! -f "${JAR_FILE}" ]; then
echo "Please build using 'mvn -DskipTests package' before running; and run this script from base directory of repo."
exit 1
fi

java -cp $JAR_FILE com.google.openthread.tools.CredentialGenerator -m $CRED_DIR/masa_cert.pem $CRED_DIR/masa_private.pem -p $1 $2 -o $CREDENTIAL
./script/helper-cp-run.sh com.google.openthread.tools.CredentialGenerator -m $CRED_DIR/masa_cert.pem $CRED_DIR/masa_private.pem -p $1 $2 -o $CREDENTIAL
12 changes: 10 additions & 2 deletions script/run-pledge-localhost.sh → script/helper-cp-run.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/bash
#
# Copyright (c) 2019, The OpenThread Registrar Authors.
# Copyright (c) 2024, The OpenThread Registrar Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
Expand All @@ -27,4 +27,12 @@
# POSSIBILITY OF SUCH DAMAGE.
#

java -cp target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar com.google.openthread.pledge.PledgeMain -f ./credentials/local-masa/test_credentials.p12 -r coaps://localhost
readonly JAR_FILE=./target/ot-registrar-0.2-jar-with-dependencies.jar

# test if OT Registrar JAR exists
if [ ! -f "${JAR_FILE}" ]; then
echo "Please build using 'mvn -DskipTests package' before running."
exit 1
fi

java -cp $JAR_FILE $@
28 changes: 28 additions & 0 deletions script/recreate-ot-registrar-cert.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,32 @@
#!/bin/bash
#
# Copyright (c) 2021, The OpenThread Registrar Authors.
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the
# names of its contributors may be used to endorse or promote products
# derived from this software without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.
#

# Recreate the cert for: OT Registrar (RA)
# signed by root=domainCA

Expand Down
13 changes: 5 additions & 8 deletions script/recreate-test-credentials-p12.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,11 @@
# POSSIBILITY OF SUCH DAMAGE.
#

readonly JAR_FILE=./target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar
readonly CREDENTIAL=./credentials/local-masa/test_credentials.p12
readonly CRED_DIR=./credentials/local-masa

# test if build JAR exists
if [ ! -f "${JAR_FILE}" ]; then
echo "Please build using 'mvn -DskipTests package' before running; and run this script from base directory of repo."
exit 1
fi

java -cp $JAR_FILE com.google.openthread.tools.CredentialGenerator -c $CRED_DIR/domainca_cert.pem $CRED_DIR/domainca_private.pem -m $CRED_DIR/masa_cert.pem $CRED_DIR/masa_private.pem -r $CRED_DIR/registrar_cert.pem $CRED_DIR/registrar_private.pem -o $CREDENTIAL
./script/helper-cp-run.sh com.google.openthread.tools.CredentialGenerator \
-c $CRED_DIR/domainca_cert.pem $CRED_DIR/domainca_private.pem \
-m $CRED_DIR/masa_cert.pem $CRED_DIR/masa_private.pem \
-r $CRED_DIR/registrar_cert.pem $CRED_DIR/registrar_private.pem \
-o $CREDENTIAL
2 changes: 1 addition & 1 deletion script/run
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

readonly JAR_FILE=./target/ot-registrar-0.2-jar-with-dependencies.jar

# test if Registrar JAR exists
# test if OT Registrar JAR exists
if [ ! -f "${JAR_FILE}" ]; then
echo "Please build using 'mvn -DskipTests package' before running."
exit 1
Expand Down
46 changes: 0 additions & 46 deletions script/run-masa-only.sh

This file was deleted.

3 changes: 2 additions & 1 deletion script/run-pledge-honeydukes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,5 @@
# This runs a Pledge using Honeydukes IDevID, onboarding via cloud Registrar.
# The script create-pledge-credentials-p12-honeydukes.sh can be used to create
# or recreate the credentials file.
java -cp target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar com.google.openthread.pledge.PledgeMain -f ./credentials/honeydukes/credentials.p12 -r coaps://masa.iotconsultancy.nl

./script/run -pledge -f ./credentials/honeydukes/credentials.p12 -r coaps://masa.iotconsultancy.nl
2 changes: 1 addition & 1 deletion script/run-pledge-iotconsultancy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,4 @@ if [ "$#" -eq 1 ]; then
fi

echo "Pledge using IoTconsultancy credentials with Registrar: ${REGISTRAR}"
java -cp target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar com.google.openthread.pledge.PledgeMain -f ./credentials/iotconsultancy-masa/credentials.p12 -r ${REGISTRAR}
./script/run -pledge -f ./credentials/iotconsultancy-masa/credentials.p12 -r ${REGISTRAR}
31 changes: 0 additions & 31 deletions script/run-pledge.sh

This file was deleted.

47 changes: 0 additions & 47 deletions script/run-registrar-only.sh

This file was deleted.

Loading

0 comments on commit 9d64169

Please sign in to comment.