Created
October 3, 2019 14:29
-
-
Save finity69x2/456466bc4fe092e2488df8504f6dce1c 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
Originally from "https://hastebin.com/sojasolite.sql" | |
1-Need to modify the host user priveleges to skip typing your password with sudo | |
sudo visudo | |
hostuser ALL=(ALL) NOPASSWD:ALL | |
2-Mount this volume in HA container to preserve the sshkey generated from the HA container and used to execute shell commands. Key will then persist through reboot or upgrades. | |
-v /home/hass/docker/sshkey/.ssh:/root/.ssh | |
"/home/hass/docker/sshkey/.ssh" needs to be your own path | |
i.e | |
run docker: | |
sudo docker run -tid --name="homeassistant" --restart=always -v /home/hass/docker/homeassistant:/config -v /etc/localtime:/etc/localtime:ro -v /etc/letsencrypt:/certs -v /home/hass/docker/sshkey/.ssh:/root/.ssh --net=host --privileged --device /dev/ttyACM0:/dev/ttyACM0 --device /dev/tty1:/dev/tty1 homeassistant/home-assistant | |
or docker-compose: | |
homeassistant: | |
container_name: homeassistant | |
image: homeassistant/home-assistant | |
restart: unless-stopped | |
network_mode: host | |
privileged: true | |
volumes: | |
- /home/hass/docker/homeassistant:/config | |
- /etc/localtime:/etc/localtime:ro | |
- /etc/letsencrypt:/certs | |
- /home/hass/docker/sshkey/.ssh:/root/.ssh | |
devices: | |
- /dev/ttyACM0:/dev/ttyACM0 | |
- /dev/tty1:/dev/tty1 | |
depends_on: | |
- mysql | |
- mqtt | |
- zoneminder | |
- configurator | |
- appdaemon | |
3-login to container via portainer or sudo docker exec -it <container_id> /bin/bash/ | |
4-generate sshkey. - https://www.digitalocean.com/community/tutorials/how-to-set-up-ssh-keys--2 | |
ssh-keygen -t rsa (press enter, enter, enter) | |
5-copy the sshkey to your host | |
ssh-copy-id [email protected] (type password when prompted) | |
6-upgrade script: | |
script: | |
update_home_assistant: | |
alias: Update Home Assistant | |
sequence: | |
- service: shell_command.update_hass | |
shell_command: | |
"if using run" | |
update_hass: ssh -l hostuser 192.168.x.x "sudo docker run -tid --name="homeassistant" --restart=always -v /home/hass/docker/homeassistant:/config -v /etc/localtime:/etc/localtime:ro -v /etc/letsencrypt:/certs -v /home/hass/docker/sshkey/.ssh:/root/.ssh --net=host --privileged --device /dev/ttyACM0:/dev/ttyACM0 --device /dev/tty1:/dev/tty1 homeassistant/home-assistant" | |
"if using docker-compose" | |
update_hass: ssh -l hostuser 192.168.x.x "sudo docker pull homeassistant/home-assistant:latest && cd ~/docker/homeassistant/templates && sudo docker-compose up -d" | |
"~/docker/homeassistant/templates -- this my directory for my docker-compose.yam" | |
THERE MAY BE A MORE EFFICIENT WAY TO WRITE THE SHELL COMMAND. BUT THESE DEFINITELY DO THE JOB. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment