Page tree

Welcome to FreeSoftwareServers Confluence Wiki

Skip to end of metadata
Go to start of metadata

You will be able to reach your installation at http://localhost:8123

https://github.com/home-assistant/supervised-installer

https://github.com/postlund/hassio-compose

https://github.com/MonolithProjects/hassio_docker-compose/blob/master/docker-compose.yml

This will be a custom "docker-compose" that I created to run HA in docker. I don't like the complicated setup via the official method, as it just "does a bunch of things for you" (that you want right?, How do you even know!). I want more granular control.

Notes:

  • After setup, just wait, and hassio_supervisor will launch a bunch of containers including home-assistant, which took another few minutes to load my config dir
add-apt-repository universe
apt-get update
apt-get install -y apparmor-utils apt-transport-https avahi-daemon ca-certificates curl dbus jq network-manager socat software-properties-common bluez bluetooth libbluetooth-dev 
systemctl disable ModemManager
apt-get purge -y modemmanager

AppArmor:

WD=/opt/hassio
mkdir -p $WD/setup
cd $WD/setup
cat << 'FNE' >/opt/hassio/setup/apparmour_setup.sh
cat << 'EOF' >/opt/hassio/setup/hassio.json
{
    "supervisor": "homeassistant/amd64-hassio-supervisor",
    "machine": "qemux86-64",
    "data": "/opt/hassio"
}
EOF

cat << 'FOE' >/usr/sbin/hassio-apparomor
#!/usr/bin/env bash
set -e

# Load configs
CONFIG_FILE=/opt/hassio/setup/hassio.json

# Read configs
DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})"
PROFILES_DIR="${DATA}/apparmor"
CACHE_DIR="${PROFILES_DIR}/cache"
REMOVE_DIR="${PROFILES_DIR}/remove"

# Exists AppArmor
if ! command -v apparmor_parser > /dev/null 2>&1; then
    echo "[Warning]: No apparmor_parser on host system!"
    exit 0
fi

# Check folder structure
mkdir -p "${PROFILES_DIR}"
mkdir -p "${CACHE_DIR}"
mkdir -p "${REMOVE_DIR}"

# Load/Update exists/new profiles
for profile in "${PROFILES_DIR}"/*; do
    if [ ! -f "${profile}" ]; then
        continue
    fi

    # Load Profile
    if ! apparmor_parser -r -W -L "${CACHE_DIR}" "${profile}"; then
        echo "[Error]: Can't load profile ${profile}"
    fi
done

# Cleanup old profiles
for profile in "${REMOVE_DIR}"/*; do
    if [ ! -f "${profile}" ]; then
        continue
    fi

    # Unload Profile
    if apparmor_parser -R -W -L "${CACHE_DIR}" "${profile}"; then
        if rm -f "${profile}"; then
            continue
        fi
    fi
    echo "[Error]: Can't remove profile ${profile}"
done
FOE
chmod +x /usr/sbin/hassio-apparomor
#repeated on purpose
/usr/sbin/hassio-apparomor
/usr/sbin/hassio-apparomor
FNE
chmod +x /opt/hassio/setup/apparmour_setup.sh
/usr/sbin/hassio-apparomor
/usr/sbin/hassio-apparomor

Docker-Compose:

WD=/opt/hassio
mkdir -p $WD/setup
cd $WD/setup
cat << 'EOF' >docker-compose.yaml
version: '3.7'
services:
  hassio_supervisor:
    container_name: hassio_supervisor
    image: "homeassistant/amd64-hassio-supervisor"
    privileged: true

    volumes:
      - type: bind
        source: /opt/hassio
        target: /data
      - type: bind
        source: /etc/machine-id
        target: /etc/machine-id
      - type: bind
        source: /etc/localtime
        target: /etc/localtime
      - type: bind
        source: /run/docker.sock
        target: /run/docker.sock
      - type: bind
        source: /run/dbus
        target: /run/dbus
      - type: bind
        source: /dev/bus/usb
        target: /dev/bus/usb

    security_opt:
      - seccomp:unconfined
      - apparmor:hassio-supervisor

    environment:
      - SUPERVISOR_SHARE=/opt/hassio
      - SUPERVISOR_NAME=hassio_supervisor
      - HOMEASSISTANT_REPOSITORY=homeassistant/qemux86-homeassistant
      - DBUS_SYSTEM_BUS_ADDRESS=unix:path=/var/run/dbus/system_bus_socket
EOF
chmod +x docker-compose.yaml

SystemD:

WD=/opt/hassio/setup
cat << EOF >$WD/hassio-supervisor.service.setup.sh
cat << EOL >/lib/systemd/system/hassio-supervisor.service
[Unit]
Description=hassio-supervisor_Docker
Requires=docker.service network-online.target

[Service]

Restart=on-abnormal
ExecStart=/usr/bin/docker-compose --project-name hassio --project-directory $WD -f $WD/docker-compose.yaml up
ExecStop=/usr/bin/docker-compose --project-name hassio --project-directory $WD -f $WD/docker-compose.yaml stop

[Install]
WantedBy=multi-user.target
EOL
systemctl enable hassio-supervisor
systemctl restart hassio-supervisor
systemctl status hassio-supervisor
EOF
chmod +x $WD/hassio-supervisor.service.setup.sh
/usr/sbin/hassio-apparomor
$WD/hassio-supervisor.service.setup.sh
/usr/sbin/hassio-apparomor

Notes:

  • I had to re-run /usr/sbin/hassio-apparomor and restart hassio-supervisor once to get it to work.
  • Try using the "ExceStart" line for CLI debugging during setup, then let SystemD take over.
  • I also had to re-start the supervisor after it setup/installed. 
  • Checkout Portainer Install Portainer - A Docker WebUI - via Docker

BashRC:

echo 'alias hacli="docker exec -it homeassistant /bin/bash"' >> ~/.bashrc
source ~/.bashrc
  • No labels