Files
aws-iot/Device/start.sh
2021-04-29 19:19:19 -04:00

39 lines
1.1 KiB
Bash

# stop script on error
set -e
#for M1 if no openssl then opkg update, opkg install openssl-util, opkg install coreutils-sha256sum, opkg install curl
if ! command -V curl > /dev/null 2>&1; then
printf "\nNo curl assuming no ssl tools, curl, or git\n"
opkg update
opkg install openssl-util
opkg install coreutils-sha256sum
opkg install curl
opkg install git
opkg upgrade libopenssl
fi
#for RPi
if ! command -V git > /dev/null 2>&1; then
apt-get update
apt-get install git
fi
# 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
# 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 git://github.com/aws/aws-iot-device-sdk-python.git
cd aws-iot-device-sdk-python
python setup.py install
cd ../
fi
python ./main.py -e a3641et952pm28-ats.iot.us-east-1.amazonaws.com -r root-CA.crt -p 8883