From 9d64169ec4c418f1b9bc722a4934a9c4cec8e926 Mon Sep 17 00:00:00 2001 From: Esko Dijk Date: Thu, 27 Jun 2024 12:46:34 +0200 Subject: [PATCH] [script] added helper script to avoid code duplication; removed unneeded scripts. --- script/build-docker-image.sh | 8 --- script/cose-validator.sh | 2 +- ...e-keystore-ietf-draft-constrained-brski.sh | 31 +++++++++++- ...reate-pledge-credentials-p12-honeydukes.sh | 10 +--- ...e-pledge-credentials-p12-iotconsultancy.sh | 9 +--- script/create-pledge-credentials-p12.sh | 9 +--- ...n-pledge-localhost.sh => helper-cp-run.sh} | 12 ++++- script/recreate-ot-registrar-cert.sh | 28 +++++++++++ script/recreate-test-credentials-p12.sh | 13 ++--- script/run | 2 +- script/run-masa-only.sh | 46 ----------------- script/run-pledge-honeydukes.sh | 3 +- script/run-pledge-iotconsultancy.sh | 2 +- script/run-pledge.sh | 31 ------------ script/run-registrar-only.sh | 47 ----------------- script/run-servers.sh | 50 +++++-------------- script/start-service.sh | 2 + 17 files changed, 95 insertions(+), 210 deletions(-) rename script/{run-pledge-localhost.sh => helper-cp-run.sh} (83%) delete mode 100755 script/run-masa-only.sh delete mode 100755 script/run-pledge.sh delete mode 100755 script/run-registrar-only.sh diff --git a/script/build-docker-image.sh b/script/build-docker-image.sh index 3feb656..944bb54 100755 --- a/script/build-docker-image.sh +++ b/script/build-docker-image.sh @@ -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 ..." diff --git a/script/cose-validator.sh b/script/cose-validator.sh index 0aa76db..0206874 100755 --- a/script/cose-validator.sh +++ b/script/cose-validator.sh @@ -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 $@ diff --git a/script/create-keystore-ietf-draft-constrained-brski.sh b/script/create-keystore-ietf-draft-constrained-brski.sh index ef4c9a8..b0f34c4 100644 --- a/script/create-keystore-ietf-draft-constrained-brski.sh +++ b/script/create-keystore-ietf-draft-constrained-brski.sh @@ -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 \ No newline at end of file + -o ./credentials/keystore_ietf-draft-constrained-brski.p12 diff --git a/script/create-pledge-credentials-p12-honeydukes.sh b/script/create-pledge-credentials-p12-honeydukes.sh index ef0ffd1..734dc1b 100755 --- a/script/create-pledge-credentials-p12-honeydukes.sh +++ b/script/create-pledge-credentials-p12-honeydukes.sh @@ -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 diff --git a/script/create-pledge-credentials-p12-iotconsultancy.sh b/script/create-pledge-credentials-p12-iotconsultancy.sh index 1e6905a..81ed1c2 100755 --- a/script/create-pledge-credentials-p12-iotconsultancy.sh +++ b/script/create-pledge-credentials-p12-iotconsultancy.sh @@ -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 \ diff --git a/script/create-pledge-credentials-p12.sh b/script/create-pledge-credentials-p12.sh index 4808acb..56eb897 100755 --- a/script/create-pledge-credentials-p12.sh +++ b/script/create-pledge-credentials-p12.sh @@ -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 diff --git a/script/run-pledge-localhost.sh b/script/helper-cp-run.sh similarity index 83% rename from script/run-pledge-localhost.sh rename to script/helper-cp-run.sh index 7c48016..60dd104 100755 --- a/script/run-pledge-localhost.sh +++ b/script/helper-cp-run.sh @@ -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 @@ -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 $@ diff --git a/script/recreate-ot-registrar-cert.sh b/script/recreate-ot-registrar-cert.sh index 8a2f157..5d3b86f 100755 --- a/script/recreate-ot-registrar-cert.sh +++ b/script/recreate-ot-registrar-cert.sh @@ -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 diff --git a/script/recreate-test-credentials-p12.sh b/script/recreate-test-credentials-p12.sh index a7b1667..1111a98 100755 --- a/script/recreate-test-credentials-p12.sh +++ b/script/recreate-test-credentials-p12.sh @@ -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 \ No newline at end of file +./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 diff --git a/script/run b/script/run index b6aa470..5002bec 100755 --- a/script/run +++ b/script/run @@ -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 diff --git a/script/run-masa-only.sh b/script/run-masa-only.sh deleted file mode 100755 index 7705cf7..0000000 --- a/script/run-masa-only.sh +++ /dev/null @@ -1,46 +0,0 @@ -#!/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. -# - -set -e - -readonly PORT=9443 -readonly JAR_FILE=./target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar -readonly CREDENTIAL=credentials/iotconsultancy-masa/credentials.p12 - -# test if Registrar JAR exists -if [ ! -f "${JAR_FILE}" ]; then - echo "Please build using 'mvn -DskipTests package' before running." - exit 1 -fi - -echo "starting MASA server, port=${PORT} ..." -java -cp $JAR_FILE \ - com.google.openthread.masa.MASAMain \ - -v -p $PORT -f $CREDENTIAL \ - "$@" diff --git a/script/run-pledge-honeydukes.sh b/script/run-pledge-honeydukes.sh index 416cf15..6a81c06 100755 --- a/script/run-pledge-honeydukes.sh +++ b/script/run-pledge-honeydukes.sh @@ -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 diff --git a/script/run-pledge-iotconsultancy.sh b/script/run-pledge-iotconsultancy.sh index ec5ff0c..06abdc3 100755 --- a/script/run-pledge-iotconsultancy.sh +++ b/script/run-pledge-iotconsultancy.sh @@ -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} diff --git a/script/run-pledge.sh b/script/run-pledge.sh deleted file mode 100755 index 5e23f33..0000000 --- a/script/run-pledge.sh +++ /dev/null @@ -1,31 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2019, 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. -# - -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://masa.iotconsultancy.nl -#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 diff --git a/script/run-registrar-only.sh b/script/run-registrar-only.sh deleted file mode 100755 index e01cd2d..0000000 --- a/script/run-registrar-only.sh +++ /dev/null @@ -1,47 +0,0 @@ -#!/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. -# - -set -e - -readonly DOMAIN_NAME=TestDomainTCE -readonly REGISTRAR_PORT=5684 -readonly JAR_FILE=./target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar -readonly CREDENTIAL=credentials/iotconsultancy-masa/credentials.p12 - -# test if Registrar JAR exists -if [ ! -f "${JAR_FILE}" ]; then - echo "Please build using 'mvn -DskipTests package' before running." - exit 1 -fi - -echo "starting registrar server, port=${REGISTRAR_PORT} ..." -java -cp $JAR_FILE \ - com.google.openthread.registrar.RegistrarMain \ - -v -d $DOMAIN_NAME -p $REGISTRAR_PORT -f $CREDENTIAL \ - "$@" diff --git a/script/run-servers.sh b/script/run-servers.sh index 66e67bd..9249f14 100755 --- a/script/run-servers.sh +++ b/script/run-servers.sh @@ -27,59 +27,33 @@ # POSSIBILITY OF SUCH DAMAGE. # +# This script starts an entire set of Registrar and MASA in the background. + set -e +# Select domain name readonly DOMAIN_NAME=TestDomainTCE +# Select credentials +#readonly CREDENTIAL=credentials/threadgroup-5f9d307c.p12 +#readonly CREDENTIAL=credentials/local-masa/test_credentials.p12 +readonly CREDENTIAL=credentials/iotconsultancy-masa/credentials.p12 + readonly TIMESTAMP=$(date "+%Y-%m-%d_%H.%M.%S") readonly LOGS=logs/${TIMESTAMP} -readonly TRI_LOG=${LOGS}/tri.log readonly REGISTRAR_LOG=${LOGS}/registrar.log readonly MASA_LOG=${LOGS}/masa.log -readonly TRI_PORT=5683 -readonly REGISTRAR_PORT=5684 -readonly MASA_PORT=9443 - -readonly JAR_FILE=./target/ot-registrar-0.1-SNAPSHOT-jar-with-dependencies.jar -# prebuilt TRI v1.2 server from the tce-registrar-java BitBucket repo needs to go here -readonly JAR_TRI=./script/TRIserver.jar - -#readonly CREDENTIAL=credentials/threadgroup-5f9d307c.p12 -#readonly CREDENTIAL=credentials/local-masa/test_credentials.p12 -readonly CREDENTIAL=credentials/iotconsultancy-masa/credentials.p12 - echo "Credentials file set to: ${CREDENTIAL}" - -# test if TRI exists -if [ ! -f "${JAR_TRI}" ]; then - echo "Please add TRI server JAR at ./script/TRIserver.jar" - exit 1 -fi - -# test if Registrar JAR exists -if [ ! -f "${JAR_FILE}" ]; then - echo "Please build using 'mvn -DskipTests package' before running." - exit 1 -fi - rm -rf $LOGS mkdir -p $LOGS -echo "starting TRI, port=${TRI_PORT}, log=${TRI_LOG}..." -java -jar $JAR_TRI [::1] $REGISTRAR_PORT -log $TRI_LOG \ - >> /dev/null 2>&1 & - -echo "starting registrar server, port=${REGISTRAR_PORT}, log=${REGISTRAR_LOG}..." -java -cp $JAR_FILE \ - com.google.openthread.registrar.RegistrarMain \ - -v -d $DOMAIN_NAME -p $REGISTRAR_PORT -f $CREDENTIAL \ +echo "starting Registrar server (CoAPS), log=${REGISTRAR_LOG}..." +./script/run -registrar -v -d $DOMAIN_NAME -f $CREDENTIAL \ >> $REGISTRAR_LOG 2>&1 & -echo "starting HTTPS masa server, port=${MASA_PORT}, log=${MASA_LOG}..." -java -cp $JAR_FILE \ - com.google.openthread.masa.MASAMain \ - -p $MASA_PORT -f $CREDENTIAL \ +echo "starting MASA server (HTTPS), log=${MASA_LOG}..." +./script/run -masa -v -f $CREDENTIAL \ >> $MASA_LOG 2>&1 & echo "Done" diff --git a/script/start-service.sh b/script/start-service.sh index eb69871..2a97354 100755 --- a/script/start-service.sh +++ b/script/start-service.sh @@ -27,6 +27,8 @@ # POSSIBILITY OF SUCH DAMAGE. # +# Start the OT Registrar service in a Docker container for testing. + readonly SUBNET=fdaa:bb::/64 readonly IP6_ADDR=fdaa:bb::de6 readonly NETWORK=network-openthread