Hass.io installation on Fedora Atomic

Hass.io is basically a supervisor for your Home Assistant project. It’s responsible for bringing up the Home Assistant container and all its add-ons.

It also offers the ability to update Home Assistant via the GUI with a single click.

HassOS, on the other hand, is an operating system built on top of the Buildroot framework. This is the simplest way for someone to get a Home Assistant instance up and running in no time with no fuss involved. More information here:
https://www.home-assistant.io/blog/2018/07/11/hassio-images/

My first setup involved using a Raspberry PI 3 on which I’ve installed Hass.io (back then was built on top of resinOS). Over the last year I’ve added multiple features to it, including a deCONZ module for ZigBee. Now it’s time to move all of this a new box, a Lenovo Tiny M400.

The setup I had in mine was:

  1. Fedora Atomic as a Host OS on my Lenovo ThinkCentre M600
  2. portainer.io for Container Management
  3. Hass.io

The developers from Hass.io recommend using an ubuntu-like OS so that we can benefit from the AppArmor profiles they’ve built.

AppArmor is optional so we can install Hass.io on Fedora as well.

Their installation process can be found here:
https://github.com/home-assistant/hassio-installer and we will make it work for Fedora Atomic as well.

First things we gotta do is install jq and the avahi-daemon on Atomic:

rpm-ostree install jq avahi

Reboot the system. Now we have all the needed prerequisites.

By analyzing their installation script(I’ve worked on this revision) I immediately saw that they will use /usr/share/hassio as a default installation directory. That won’t work for me, Atomic has only two partitions which give persistence to data and are writable:

  • /var
  • /etc

We will use /var/hassio instead of /usr/share/hassio

If I want the container addons to be able to read files from the disk I must configure SELinux to allow that. I will ensure that all files created in /var/hassio will inherit the svirt_sandbox_file_t type.

semanage fcontext --add --type svirt_sandbox_file_t "/var/hassio(/.*)?"

Moving further I’ve noticed that the hassio-supervisor script is going to be installed into /usr/sbin.

Since /usr is not writable on Atomic, I’ll use /var/usrlocal/sbin. I will configure SELinux to assign the bin_t type to any files inside /var/usrlocal/sbin directory.

semanage fcontext --add --type bin_t "/var/usrlocal/sbin(/.*)?"

Let’s update their installation script so that the hassio-supervisor script gets installed in the correct location:

sed -i 's/\/usr\/sbin\/hassio-supervisor/\/var\/usrlocal\/sbin\/hassio-supervisor/g' hassio_install.sh

Let’s disable the automatic start of the hassio-supervisor daemon. We need to make some changes if we want it to start correctly.

sed -i '/systemctl start hassio-supervisor.service/d' hassio_install.sh

It’s now safe to run their script, but with /var/hassio as an installation directory:

hassio_install.sh -d /var/hassio

It’s best to set the correct SELinux context to the systemd unit file installed by the hassio_install.sh script.

restorecon -Fv /etc/systemd/system/hassio-supervisor.service

Let’s update the path of the hassio-supervisor script inside the systemd unit file as well:

sed -i 's/\/usr\/sbin\/hassio-supervisor/\/var\/usrlocal\/sbin\/hassio-supervisor/g' /etc/systemd/system/hassio-supervisor.service

Start the daemon:

systemctl start hassio-supervisor

Check for logs with:

journalctl --unit=hassio-supervisor --follow

Enjoy.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.