-
Notifications
You must be signed in to change notification settings - Fork 0
/
start.sh
36 lines (31 loc) · 1.29 KB
/
start.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#!/usr/bin/env bash
# stop script on error
set -e
# Check for python 3
if ! python3 --version &> /dev/null; then
printf "\nERROR: python3 must be installed.\n"
exit 1
fi
# Check to see if root CA file exists, download if not
if [ ! -f ./root-CA.crt ]; then
printf "\nDownloading AWS IoT Root CA certificate from AWS...\n"
curl https://www.amazontrust.com/repository/AmazonRootCA1.pem > root-CA.crt
fi
# Check to see if AWS Device SDK for Python exists, download if not
if [ ! -d ./aws-iot-device-sdk-python-v2 ]; then
printf "\nCloning the AWS SDK...\n"
git clone https://github.com/aws/aws-iot-device-sdk-python-v2.git --recursive
fi
# Check to see if AWS Device SDK for Python is already installed, install if not
if ! python3 -c "import awsiot" &> /dev/null; then
printf "\nInstalling AWS SDK...\n"
python3 -m pip install ./aws-iot-device-sdk-python-v2
result=$?
if [ $result -ne 0 ]; then
printf "\nERROR: Failed to install SDK.\n"
exit $result
fi
fi
# run pub/sub sample app using certificates downloaded in package
printf "\nRunning pub/sub sample application...\n"
python3 pubsub.py --endpoint ajui4xigywped-ats.iot.us-east-2.amazonaws.com --ca_file root-CA.crt --cert iot-device-1.cert.pem --key iot-device-1.private.key --client_id basicPubSub --topic sdk/test/python --count 0