#!/usr/bin/env bash # Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. # Permission is hereby granted, free of charge, to any person obtaining a copy of # this software and associated documentation files (the "Software"), to deal in # the Software without restriction, including without limitation the rights to # use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of # the Software, and to permit persons to whom the Software is furnished to do so. # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS # FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR # COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER # IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN # CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. # stop script on error set -e # 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 ]; then printf "\nCloning the AWS SDK...\n" git clone https://github.com/aws/aws-iot-device-sdk-python.git fi # Check to see if AWS Device SDK for Python is already installed, install if not if ! python -c "import AWSIoTPythonSDK" &> /dev/null; then printf "\nInstalling AWS SDK...\n" pushd aws-iot-device-sdk-python pip install AWSIoTPythonSDK result=$? popd 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 simulator.py -r root-CA.crt -c all_pumping_stations.cert.pem -k all_pumping_stations.private.key