# stop script on error set -e # Check to see if root CA file exists, download if not if [ ! -f ./root-CA.crt ]; then printf "\nNO ROOT CERTIFICATE\n" curl https://www.amazontrust.com/repository/AmazonRootCA1.pem > root-CA.crt fi if [ ! -f ./rootCA.pem ]; then printf "\nNO HPIoT ROOT CERTIFICATE\n" fi if [ ! -f ./deviceCert.pem ]; then openssl genrsa -out deviceCert.key 2048 openssl req -config server.conf -new -key deviceCert.key -out deviceCert.pem openssl x509 -req -in deviceCert.pem -CA rootCA.pem -CAkey rootCA.key -CAcreateserial -out deviceCert.pem -days 365 -sha256 fi # install AWS Device SDK for Python if not already installed if [ ! -d ./aws-iot-device-sdk-python ]; then printf "\nInstalling AWS SDK...\n" git clone https://github.com/aws/aws-iot-device-sdk-python.git pushd aws-iot-device-sdk-python python setup.py install popd fi if [ ! -f ./deviceCertAndCACert.pem ]; then cat deviceCert.pem rootCA.pem > deviceCertAndCACert.pem fi # run pub/sub sample app using certificates downloaded in package printf "\nRunning pub/sub sample application...\n" python aws-iot-device-sdk-python/samples/basicPubSub/basicPubSub.py -e a3641et952pm28-ats.iot.us-east-1.amazonaws.com -r root-CA.crt -c deviceCertAndCACert.pem -k deviceCert.key