Last active
October 9, 2024 20:29
-
-
Save bartfastiel/7dd5c8cb0ed250df9560122e1c3dcbba to your computer and use it in GitHub Desktop.
Setup pi for IoT controller
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/bash | |
#################################################### | |
# curl -sSL https://bit.ly/bartfastiel-ylive | bash | |
#################################################### | |
set -e | |
sudo apt-get update && sudo apt-get upgrade -y --no-install-recommends | |
echo "Enabling I2C, SPI, and PWM..." | |
sudo raspi-config nonint do_i2c 0 | |
sudo raspi-config nonint do_spi 0 | |
echo "dtoverlay=pwm-2chan,pin=18,func=2" | sudo tee -a /boot/firmware/config.txt | |
# docker | |
curl -fsSL https://get.docker.com -o get-docker.sh | |
sudo sh get-docker.sh | |
sudo usermod -aG docker $USER | |
newgrp docker | |
sudo systemctl enable docker | |
docker network create ylive-network | |
sudo mkdir -p /ylive/config | |
sudo chown $(id -u):$(id -g) /ylive /ylive/config | |
docker login | |
docker run \ | |
--rm \ | |
--name ylive-provisioning \ | |
--network host \ | |
-it \ | |
--pull=always \ | |
--volume /ylive/config:/ylive/config \ | |
bartfastiel/ylive-provisioning:raspberry | |
docker run \ | |
--detach \ | |
--name mqtt-broker \ | |
--publish 1883:1883 \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
bartfastiel/ylive-mqtt-broker:raspberry | |
docker run \ | |
--detach \ | |
--name ylive-communication-gateway-easywave \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
--device=/dev/ttyUSB0 \ | |
--env EASYWAVE_PORT=/dev/ttyUSB0 \ | |
--env MQTT_BROKER=mqtt-broker \ | |
--env MQTT_PORT=1883 \ | |
--env MQTT_PUBLISH_TOPIC_PREFIX=device/eldat \ | |
bartfastiel/ylive-communication-gateway-easywave:raspberry | |
docker run \ | |
--detach \ | |
--name ylive-peripheral-mapper \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
--mount type=bind,source=/ylive/config,target=/ylive/config \ | |
--env MQTT_BROKER=mqtt-broker \ | |
--env MQTT_PORT=1883 \ | |
--env INCOMING_TOPIC_PREFIX=device/ \ | |
--env OUTGOING_TOPIC_PREFIX=peripheral/ \ | |
--env OUTGOING_TOPIC_NEW_DEVICE=new_peripheral \ | |
--env SYSTEM_JSON_PATH=/ylive/config/system.json \ | |
bartfastiel/ylive-peripheral-mapper:raspberry | |
docker run \ | |
--detach \ | |
--name ylive-controller-led \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--privileged \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
--device /dev/gpiomem \ | |
--env LED_PIN=18 \ | |
--env LED_COUNT=24 \ | |
--env MQTT_BROKER=mqtt-broker \ | |
--env MQTT_PORT=1883 \ | |
--env MQTT_TOPIC=device/led \ | |
bartfastiel/ylive-controller-led:raspberry | |
docker run \ | |
--detach \ | |
--name ylive-logic-core \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
--env EASYWAVE_PORT=/dev/ttyUSB0 \ | |
--env MQTT_BROKER=mqtt-broker \ | |
--env MQTT_PORT=1883 \ | |
--env MQTT_LISTEN_TOPIC=peripheral/living_room/button \ | |
--env MQTT_PUBLISH_TOPIC=device/led \ | |
--env ABSENCE_FOR_MINUTES_DELAY_SECONDS=300 \ | |
--env ABSENCE_FOR_HOURS_DELAY_SECONDS=7200 \ | |
--env ABSENCE_FROM_BED_MAX_EXPECTED_SECONDS=1200 \ | |
--env MINIMUM_EXPECTED_SLEEP_SECONDS=21600 \ | |
--env NIGHT_TIME_START=18:00 \ | |
--env NIGHT_TIME_END=06:00 \ | |
bartfastiel/ylive-logic-core:raspberry | |
docker run \ | |
--detach \ | |
--name pl-db \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
bartfastiel/ylive-pl-db:raspberry | |
docker run \ | |
--detach \ | |
--name pl-mqtt \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
bartfastiel/ylive-pl-mqtt:raspberry | |
docker run \ | |
--detach \ | |
--name pl-cl \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
bartfastiel/ylive-pl-cl:raspberry | |
docker run \ | |
--detach \ | |
--name mqtt-log \ | |
--network ylive-network \ | |
--restart=always \ | |
--pull=always \ | |
--cpus="0.4" \ | |
--log-opt max-size=40m \ | |
--log-opt max-file=3 \ | |
bartfastiel/ylive-mqtt-log:raspberry | |
docker run \ | |
--rm \ | |
--network ylive-network \ | |
eclipse-mosquitto mosquitto_pub \ | |
--host mqtt-broker \ | |
--topic device/led \ | |
--message '{ | |
"color": "red", | |
"brightness": 0.5, | |
"mode": "shine", | |
"split": false | |
}' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment