Last active
July 9, 2018 21:51
-
-
Save veyalla/d6d9501b814361c0a0950d5307835c57 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
# https://stackoverflow.com/questions/5947742/how-to-change-the-output-color-of-echo-in-linux | |
# .---------- constant part! | |
# vvvv vvvv-- the code from above | |
GREEN='\033[0;32m' | |
NC='\033[0m' # No Color | |
die () { | |
echo >&2 "$@" | |
exit 1 | |
} | |
[ "$#" -eq 1 ] || die "Please provide IoT Hub device connection string as an (only) argument." | |
if [ ! -f /etc/apt/sources.list.d/microsoft-prod.list ]; then | |
echo -e "${GREEN}Add and trust MS repository${NC}" | |
curl https://packages.microsoft.com/config/ubuntu/16.04/prod.list > ./microsoft-prod.list | |
sudo cp ./microsoft-prod.list /etc/apt/sources.list.d/ | |
fi | |
if [ ! -f /etc/apt/trusted.gpg.d/microsoft.gpg ]; then | |
curl https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > microsoft.gpg | |
sudo cp ./microsoft.gpg /etc/apt/trusted.gpg.d/ | |
fi | |
sudo apt-get update | |
if !(systemctl is-active --quiet docker) then | |
echo -e "${GREEN}Installing Moby container runtime and CLI${NC}" | |
sudo apt-get install -y moby-engine | |
sudo apt-get install -y moby-cli | |
fi | |
echo -e "${GREEN}Installing the IoT Edge Security Daemon${NC}" | |
sudo apt-get install -y iotedge | |
echo -e "${GREEN}Setting connection string in config.yaml${NC}" | |
sudo sed -i -E "s|(.*device_connection_string:[[:space:]]\").*|\1$1\"|" /etc/iotedge/config.yaml | |
echo -e "${GREEN}Restarting iotedged${NC}" | |
sudo systemctl restart iotedge | |
echo -e "${GREEN}Following iotedged log (CTRL+C to cancel)....${NC}" | |
journalctl -u iotedge -f |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment