Last active
May 12, 2024 07:53
-
-
Save letsautomatenet/41731adc9c32da9365136d0401188c1a to your computer and use it in GitHub Desktop.
ESPHome Install - Ubuntu
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 | |
# If you're having difficulty running this file then ensure the file has execute permissions | |
# chmod 755 esphome_install.sh | |
# To run the script type: | |
# sudo ./esphome_install.sh | |
### START - Install Docker ### | |
# Remove any old docker files | |
for pkg in docker.io docker-doc docker-compose docker-compose-v2 podman-docker containerd runc; do sudo apt-get -y remove $pkg; done | |
# Add Docker's official GPG key: | |
sudo apt-get update -y | |
sudo apt-get install -y ca-certificates curl | |
sudo install -m 0755 -d /etc/apt/keyrings | |
sudo curl -fsSL https://download.docker.com/linux/ubuntu/gpg -o /etc/apt/keyrings/docker.asc | |
sudo chmod a+r /etc/apt/keyrings/docker.asc | |
# Add the repository to Apt sources: | |
echo \ | |
"deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.asc] https://download.docker.com/linux/ubuntu \ | |
$(. /etc/os-release && echo "$VERSION_CODENAME") stable" | \ | |
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null | |
sudo apt-get update -y | |
# Install Docker Engine | |
sudo apt-get install -y docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin | |
# Verify Docker is installed correctly | |
sudo docker run hello-world | |
### END - Install Docker ### | |
### START - ESPHome Install ### | |
# Download Docker image | |
sudo docker pull ghcr.io/esphome/esphome | |
cd $HOME | |
mkdir esphome | |
# Run ESPHome - Container won't start on boot | |
# sudo docker run -d --rm --net=host -v "${PWD}":/config -it ghcr.io/esphome/esphome | |
# Run ESPHome and restart container upon reboot or failure | |
sudo docker run -d --restart unless-stopped --net=host -v "${HOME}/esphome":/config -it ghcr.io/esphome/esphome | |
# This bit needs adding to the command above if attaching an ESP device directly to your Ubuntu machine | |
# You can do this but I would treat the ESPHome instance as stand-alone and use another machine | |
# to access the ESPHome Web UI and flash devices | |
# --device=/dev/ttyUSB0 | |
# ESPHome Web UI Accessible from port 6052 | |
# http://localhost:6052 | |
### END - ESPHome Install ### |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment