Skip to content

Instantly share code, notes, and snippets.

@pettazz
Created November 15, 2020 18:55
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pettazz/646628176e365a897cd368907308de1b to your computer and use it in GitHub Desktop.
Save pettazz/646628176e365a897cd368907308de1b to your computer and use it in GitHub Desktop.
home-assistant systemd unit
[Unit]
Description=Home Assistant service
Requires=docker.service
After=docker.service
[Service]
Restart=always
User=hassio
Group=hassio
WorkingDirectory=/opt/home-assistant
ExecStartPre=/usr/bin/docker-compose down
ExecStart=/usr/bin/docker-compose up
ExecStop=/usr/bin/docker-compose down
[Install]
WantedBy=multi-user.target
@pettazz
Copy link
Author

pettazz commented Nov 15, 2020

Add a user named hassio:

  • sudo useradd -r hassio
    Give it docker privileges:
  • sudo gpasswd -a hassio docker
    Make it owner of the home-assistant dir:
  • sudo chown -R hassio:hassio /opt/home-assistant

Put this in /etc/systemd/system/, run a systemctl daemon-reload, and you should be able to sudo service start home-assistant start

Run systemctl enable home-assistant to enable it automatically starting on every boot

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment