Skip to content

Commit 81863cd

Browse files
committed
Improving scripts
1 parent 260cd4f commit 81863cd

File tree

5 files changed

+57
-10
lines changed

5 files changed

+57
-10
lines changed

test_collections/matter/scripts/OTBR/otbr_srp_restart.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@
1414
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
17+
ROOT_DIR=$(realpath $(dirname "$0")/../..)
18+
TH_SCRIPTS_DIR="$ROOT_DIR/scripts"
1719

20+
source "$TH_SCRIPTS_DIR/utils.sh"
21+
22+
print_start_of_script
23+
24+
print_script_step "Restarting OTBR service"
1825
sudo docker exec -t otbr-chip ot-ctl srp server disable
1926
sleep 2
20-
sudo docker exec -t otbr-chip ot-ctl srp server enable
27+
sudo docker exec -t otbr-chip ot-ctl srp server enable
28+
29+
print_end_of_script

test_collections/matter/scripts/OTBR/otbr_start.sh

+15-6
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
ROOT_DIR=$(realpath $(dirname "$0")/../..)
18+
TH_SCRIPTS_DIR="$ROOT_DIR/scripts"
1819

1920
DEFAULT_OTBR_INTERFACE="eth0"
2021
BR_INTERFACE=${1:-$DEAFULT_OTBR_INTERFACE}
@@ -24,21 +25,27 @@ BR_IMAGE_BASE="nrfconnect/otbr"
2425
BR_IMAGE_TAG="9185bda"
2526
BR_IMAGE=$BR_IMAGE_BASE":"$BR_IMAGE_TAG
2627

28+
source "$TH_SCRIPTS_DIR/utils.sh"
29+
30+
print_start_of_script
31+
32+
print_script_step "Removing 'otbr-chip' container"
2733
docker rm otbr-chip > /dev/null 2>&1
2834

2935
if docker images | grep $BR_IMAGE_BASE | grep $BR_IMAGE_TAG;
3036
then
3137
echo "otbr image "$BR_IMAGE" already installed"
3238
else
33-
echo "pulling otbr image "$BR_IMAGE
39+
print_script_step "Pulling $BR_IMAGE image"
3440
docker pull $BR_IMAGE || exit 1
3541
fi
42+
43+
print_script_step "Starting 'otbr-chip' container"
3644
AVAHI_PATH=$ROOT_DIR/backend/app/otbr_manager/avahi
3745
sudo modprobe ip6table_filter || exit 1
3846
sudo docker run --privileged -d --network host --name otbr-chip -e NAT64=1 -e DNS64=0 -e WEB_GUI=0 -v $AVAHI_PATH:/etc/avahi -v /dev/ttyACM0:/dev/radio $BR_IMAGE --radio-url spinel+hdlc+uart:///dev/radio?uart-baudrate=115200 -B $BR_INTERFACE || exit 1
3947

40-
echo "waiting 10 seconds to give the the docker container enough time to start up..."
41-
48+
print_script_step "waiting 10 seconds to give the the docker container enough time to start up..."
4249
sleep 10
4350

4451
BR_CHANNEL_HEX=$(printf '%02x' $BR_CHANNEL)
@@ -63,15 +70,17 @@ BR_PARAMS=(
6370
"dataset active -x"
6471
)
6572

73+
print_script_step "Setting up Thread Network"
74+
6675
for i in "${BR_PARAMS[@]}"
6776
do
68-
echo "Param: '"$i"'"
77+
printf "Param: '$i'"
6978
sudo docker exec -t otbr-chip ot-ctl $i || exit 1
7079
done
7180

7281
BR_SIMPLE_DATASET="00030000"${BR_CHANNEL_HEX}"0208"${BR_EXTPANID}"0510"${BR_NETWORKKEY}"0102"${BR_PANID}
7382
sudo echo ${BR_SIMPLE_DATASET} > /tmp/otbr_simple_dataset.txt
74-
echo "Simple Dataset: " ${BR_SIMPLE_DATASET}
83+
printf "Simple Dataset: $BR_SIMPLE_DATASET"
7584

76-
# Also make sure to restart the Raspi avahi to have it in a clean state
85+
print_script_step "Also make sure to restart the Raspi avahi to have it in a clean state"
7786
sudo service avahi-daemon restart

test_collections/matter/scripts/OTBR/otbr_stop.sh

+10-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,16 @@
1414
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
17+
ROOT_DIR=$(realpath $(dirname "$0")/../..)
18+
TH_SCRIPTS_DIR="$ROOT_DIR/scripts"
1719

20+
source "$TH_SCRIPTS_DIR/utils.sh"
21+
22+
print_start_of_script
23+
24+
print_script_step "Stoping OTBR service"
1825
sudo docker exec -t otbr-chip ot-ctl srp server disable
1926
sleep 2
20-
sudo docker kill otbr-chip
27+
sudo docker kill otbr-chip
28+
29+
print_end_of_script

test_collections/matter/scripts/update-paa-certs.sh

+13-2
Original file line numberDiff line numberDiff line change
@@ -28,13 +28,18 @@ set -e
2828

2929
# Paths
3030
MATTER_PROGRAM_DIR=$(realpath $(dirname "$0")/..)
31+
TH_SCRIPTS_DIR="$MATTER_PROGRAM_DIR/../../../scripts"
3132
TMP_SDK_FOLDER="sdk-sparse"
3233
TMP_SDK_PATH="/tmp/$TMP_SDK_FOLDER"
3334
SDK_CERT_PATH="credentials/development/paa-root-certs"
3435
SDK_CERT_DEVELOPMENT_PATH="credentials/development"
3536
CERT_PATH="/var/paa-root-certs"
3637
DEVELOPMENT_PATH="/var/credentials/development"
3738

39+
source "$TH_SCRIPTS_DIR/utils.sh"
40+
41+
print_start_of_script
42+
3843
# If SDK path is not present, then do local checkout
3944
if [ -z "$SDK_PATH" ]
4045
then
@@ -46,7 +51,7 @@ then
4651
SDK_SHA=$(cat $MATTER_PROGRAM_DIR/config.py | grep SDK_SHA | cut -d'"' -f 2 | cut -d"'" -f 2)
4752
fi
4853

49-
# Checkout SDK sparsely
54+
print_script_step "Checkout SDK sparsely"
5055
rm -rf $TMP_SDK_PATH
5156
cd /tmp
5257
git clone --filter=blob:none --no-checkout --depth 1 --sparse https://github.com/project-chip/connectedhomeip.git $TMP_SDK_FOLDER
@@ -60,17 +65,23 @@ fi
6065
# Create folder if missing (owned by user)
6166
if [ ! -d "$CERT_PATH" ]
6267
then
68+
print_script_step "Creating certification folder $CERT_PATH"
6369
sudo mkdir -p $CERT_PATH
6470
sudo chown $USER:$USER $CERT_PATH
6571
fi
6672

6773
# Create folder if missing (owned by user)
6874
if [ ! -d "$DEVELOPMENT_PATH" ]
6975
then
76+
print_script_step "Creating developer certification folder $DEVELOPMENT_PATH"
7077
sudo mkdir -p $DEVELOPMENT_PATH
7178
sudo chown $USER:$USER $DEVELOPMENT_PATH
7279
fi
7380

74-
# Copy certs from SDK
81+
print_script_step "Copying Certificates from SDK"
7582
cp "$SDK_PATH/$SDK_CERT_PATH/"* $CERT_PATH/
83+
84+
print_script_step "Copying Developer Certificates from SDK"
7685
cp -R "$SDK_PATH/$SDK_CERT_DEVELOPMENT_PATH/"** $DEVELOPMENT_PATH/
86+
87+
print_end_of_script

test_collections/matter/scripts/update-sample-apps.sh

+9
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,21 @@
1515
# See the License for the specific language governing permissions and
1616
# limitations under the License.
1717
MATTER_PROGRAM_DIR=$(realpath $(dirname "$0")/..)
18+
TH_SCRIPTS_DIR="$MATTER_PROGRAM_DIR/../../../scripts"
1819

20+
source "$TH_SCRIPTS_DIR/utils.sh"
21+
22+
print_start_of_script
23+
24+
print_script_step "Pulling the SDK Docker image"
1925
# We are fetching SDK docker image and tag name from backend
2026
# This is done to minimize the places the SDK version is tracked.
2127
SDK_DOCKER_IMAGE=$(cat $MATTER_PROGRAM_DIR/config.py | grep SDK_DOCKER_IMAGE | cut -d'"' -f 2 | cut -d"'" -f 2)
2228
SDK_DOCKER_TAG=$(cat $MATTER_PROGRAM_DIR/config.py | grep SDK_DOCKER_TAG | cut -d'"' -f 2 | cut -d"'" -f 2)
2329
sudo docker pull $SDK_DOCKER_IMAGE:$SDK_DOCKER_TAG
2430

31+
print_script_step "Updating Sample APPs"
2532
sudo docker run -t -v ~/apps:/apps $SDK_DOCKER_IMAGE:$SDK_DOCKER_TAG bash -c "rm -v /apps/*; cp -v * /apps/;"
2633
sudo chown -R `whoami` ~/apps
34+
35+
print_end_of_script

0 commit comments

Comments
 (0)