Installing Home Assistant Supervised on CoreELEC

Tags: #<Tag:0x00007f3264c46d58>

Trying to get Supervised going on CoreELEC, which worked just fine with zwave+, zigbee using a modified version of @kanga_who -script; that is to say until the last update.

The story so far;

mkdir -p /storage/hassio/etc
mkdir -p /storage/hassio/sbin
mkdir -p /storage/hassio/bin

Do a ./hassio-install.sh -m odroid-n2 with the modified script:

#!/usr/bin/env bash
set -e

function error { echo -e "[Error] $*"; exit 1; }
function warn  { echo -e "[Warning] $*"; }

warn ""
warn "If you want more control over your own system, run"
warn "Home Assistant as a VM or run Home Assistant Core"
warn "via a Docker container."
warn ""

ARCH=$(uname -m)
DOCKER_BINARY=/storage/.kodi/addons/service.system.docker/bin/docker #/usr/bin/docker
DOCKER_REPO=homeassistant
DOCKER_SERVICE=docker.service
URL_VERSION="https://version.home-assistant.io/stable.json"
URL_HA="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/ha"
URL_BIN_HASSIO="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-supervisor"
#URL_BIN_APPARMOR="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-apparmor"
URL_SERVICE_HASSIO="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-supervisor.service"
#URL_SERVICE_APPARMOR="https://raw.githubusercontent.com/home-assistant/supervised-installer/master/files/hassio-apparmor.service"
#URL_APPARMOR_PROFILE="https://version.home-assistant.io/apparmor.txt"

# Check env
command -v systemctl > /dev/null 2>&1 || error "Only systemd is supported!"
command -v docker > /dev/null 2>&1 || error "Please install docker first"
command -v jq > /dev/null 2>&1 || error "Please install jq first"
command -v curl > /dev/null 2>&1 || error "Please install curl first"
command -v avahi-daemon > /dev/null 2>&1 || error "Please install avahi first"
command -v dbus-daemon > /dev/null 2>&1 || error "Please install dbus first"
#command -v nmcli > /dev/null 2>&1 || error "No NetworkManager support on host."
#command -v apparmor_parser > /dev/null 2>&1 || error "No AppArmor support on host."


# Check if Modem Manager is enabled
if systemctl list-unit-files ModemManager.service | grep enabled; then
    warn "ModemManager service is enabled. This might cause issue when using serial devices."
fi

# Detect if running on snapped docker
#if snap list docker >/dev/null 2>&1; then
#    DOCKER_BINARY=/snap/bin/docker
#    DATA_SHARE=/root/snap/docker/common/hassio
#    CONFIG=$DATA_SHARE/hassio.json
#    DOCKER_SERVICE="snap.docker.dockerd.service"
#fi

# Parse command line parameters
while [[ $# -gt 0 ]]; do
    arg="$1"

    case $arg in
        -m|--machine)
            MACHINE=$2
            shift
            ;;
        -d|--data-share)
            DATA_SHARE=$2
            shift
            ;;
        -p|--prefix)
            PREFIX=$2
            shift
            ;;
        -s|--sysconfdir)
            SYSCONFDIR=$2
            shift
            ;;
        *)
            error "Unrecognized option $1"
            ;;
    esac
    shift
done

PREFIX=${PREFIX:-/storage/hassio}
SYSCONFDIR=${SYSCONFDIR:-/storage/hassio/etc}
DATA_SHARE=${DATA_SHARE:-$PREFIX/share/hassio}
CONFIG=$SYSCONFDIR/hassio.json

# Generate hardware options
case $ARCH in
    "i386" | "i686")
        MACHINE=${MACHINE:=qemux86}
        HASSIO_DOCKER="$DOCKER_REPO/i386-hassio-supervisor"
    ;;
    "x86_64")
        MACHINE=${MACHINE:=qemux86-64}
        HASSIO_DOCKER="$DOCKER_REPO/amd64-hassio-supervisor"
    ;;
    "arm" |"armv6l")
        if [ -z $MACHINE ]; then
            error "Please set machine for $ARCH"
        fi
        HASSIO_DOCKER="$DOCKER_REPO/armhf-hassio-supervisor"
    ;;
    "armv7l")
        if [ -z $MACHINE ]; then
            error "Please set machine for $ARCH"
        fi
        HASSIO_DOCKER="$DOCKER_REPO/armv7-hassio-supervisor"
    ;;
    "aarch64")
        if [ -z $MACHINE ]; then
            error "Please set machine for $ARCH"
        fi
        HASSIO_DOCKER="$DOCKER_REPO/aarch64-hassio-supervisor"
    ;;
    *)
        error "$ARCH unknown!"
    ;;
esac

if [[ ! "intel-nuc odroid-c2 odroid-n2 odroid-xu qemuarm qemuarm-64 qemux86 qemux86-64 raspberrypi raspberrypi2 raspberrypi3 raspberrypi4 raspberrypi3-64 raspberrypi4-64 tinker" = *"${MACHINE}"* ]]; then
    error "Unknown machine type ${MACHINE}!"
fi

### Main

# Init folders
if [ ! -d "$DATA_SHARE" ]; then
    mkdir -p "$DATA_SHARE"
fi

# Read infos from web
HASSIO_VERSION=$(curl -s $URL_VERSION | jq -e -r '.supervisor')

##
# Write configuration
cat > "$CONFIG" <<- EOF
{
    "supervisor": "${HASSIO_DOCKER}",
    "machine": "${MACHINE}",
    "data": "${DATA_SHARE}"
}
EOF

##
# Pull supervisor image
echo "[Info] Install supervisor Docker container"
docker pull "$HASSIO_DOCKER:$HASSIO_VERSION" > /dev/null
docker tag "$HASSIO_DOCKER:$HASSIO_VERSION" "$HASSIO_DOCKER:latest" > /dev/null

##
# Install Hass.io Supervisor
echo "[Info] Install supervisor startup scripts"
curl -sL ${URL_BIN_HASSIO} > "${PREFIX}/sbin/hassio-supervisor"
curl -sL ${URL_SERVICE_HASSIO} > "/storage/.config/system.d/hassio-supervisor.service"

sed -i "s,%%HASSIO_CONFIG%%,${CONFIG},g" "${PREFIX}"/sbin/hassio-supervisor
sed -i -e "s,%%DOCKER_BINARY%%,${DOCKER_BINARY},g" \
       -e "s,%%DOCKER_SERVICE%%,${DOCKER_SERVICE},g" \
       -e "s,%%HASSIO_BINARY%%,${PREFIX}/sbin/hassio-supervisor,g" \
       "/storage/.config/system.d/hassio-supervisor.service"

chmod a+x "${PREFIX}/sbin/hassio-supervisor"
systemctl enable hassio-supervisor.service

#
# Install Hass.io AppArmor
#if command -v apparmor_parser > /dev/null 2>&1; then
#    echo "[Info] Install AppArmor scripts"
#    mkdir -p "${DATA_SHARE}/apparmor"
#    curl -sL ${URL_BIN_APPARMOR} > "${PREFIX}/sbin/hassio-apparmor"
#    curl -sL ${URL_SERVICE_APPARMOR} > "${SYSCONFDIR}/systemd/system/hassio-apparmor.service"
#    curl -sL ${URL_APPARMOR_PROFILE} > "${DATA_SHARE}/apparmor/hassio-supervisor"
#
#    sed -i "s,%%HASSIO_CONFIG%%,${CONFIG},g" "${PREFIX}/sbin/hassio-apparmor"
#    sed -i -e "s,%%DOCKER_SERVICE%%,${DOCKER_SERVICE},g" \
#	   -e "s,%%HASSIO_APPARMOR_BINARY%%,${PREFIX}/sbin/hassio-apparmor,g" \
#	   "${SYSCONFDIR}/systemd/system/hassio-apparmor.service"
#
#    chmod a+x "${PREFIX}/sbin/hassio-apparmor"
#    systemctl enable hassio-apparmor.service
#    systemctl start hassio-apparmor.service
#fi

##
# Init system
echo "[Info] Run Home Assistant Supervised"
systemctl start hassio-supervisor.service

##
# Setup CLI
echo "[Info] Install cli 'ha'"
curl -sL ${URL_HA} > "${PREFIX}/bin/ha"
chmod a+x "${PREFIX}/bin/ha"

Which gives output:

[Warning]
[Warning] If you want more control over your own system, run
[Warning] Home Assistant as a VM or run Home Assistant Core
[Warning] via a Docker container.
[Warning]
[Info] Install supervisor Docker container
[Info] Install supervisor startup scripts
[Info] Run Home Assistant Supervised
[Info] Install cli 'ha'

systemctl status hassio-supervisor.service
Output:

● hassio-supervisor.service - Hass.io supervisor
   Loaded: loaded (/storage/.config/system.d/hassio-supervisor.service; enabled; vendor preset: disabled)
   Active: activating (auto-restart) (Result: exit-code) since Sat 2020-08-15 16:42:38 CEST; 4s ago
  Process: 28964 ExecStartPre=/storage/.kodi/addons/service.system.docker/bin/docker stop hassio_supervisor (code=exited,
  Process: 28997 ExecStart=/storage/hassio/sbin/hassio-supervisor (code=exited, status=127)
 Main PID: 28997 (code=exited, status=127)

/storage/hassio/sbin/hassio-supervisor
Says:


[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] udev.sh: executing...
[14:44:29] INFO: Update udev information
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

docker start --attach hassio_supervisor || runSupervisor
Says:

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] udev.sh: executing...
[14:46:13] INFO: Update udev information
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[cont-init.d] udev.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
s6-svscanctl: fatal: unable to control /var/run/s6/services: supervisor not listening
s6-svscanctl: fatal: unable to control /var/run/s6/services: supervisor not listening
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

And of course: /storage/hassio/bin/ha
Goes: Error: No such container: hassio_cli

If we edit out a bit of the apparmor in: /storage/hassio/sbin/hassio-supervisor
As follows:

#!/usr/bin/env bash
set -e

# Load configs
CONFIG_FILE=/storage/hassio/etc/hassio.json

SUPERVISOR="$(jq --raw-output '.supervisor' ${CONFIG_FILE})"
MACHINE="$(jq --raw-output '.machine' ${CONFIG_FILE})"
DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})"

# AppArmor Support
#if command -v apparmor_parser > /dev/null 2>&1 && grep hassio-supervisor /sys/kernel/security/apparmor/profiles > /dev/null 2>&1; then
#    APPARMOR="--security-opt apparmor=hassio-supervisor"
#else
#    APPARMOR="--security-opt apparmor:unconfined"
#fi

# Init supervisor
HASSIO_DATA=${DATA}
HASSIO_IMAGE_ID=$(docker inspect --format='{{.Id}}' "${SUPERVISOR}")
HASSIO_CONTAINER_ID=$(docker inspect --format='{{.Image}}' hassio_supervisor || echo "")

runSupervisor() {
    docker rm --force hassio_supervisor || true

    # shellcheck disable=SC2086
    docker run --name hassio_supervisor \
        --privileged \
 #       $APPARMOR \
 #       --security-opt seccomp=unconfined \
        -v /run/docker.sock:/run/docker.sock \
        -v /run/dbus:/run/dbus \
        -v /etc/machine-id:/etc/machine-id:ro \
        -v "${HASSIO_DATA}":/data:rw \
        -e SUPERVISOR_SHARE="${HASSIO_DATA}" \
        -e SUPERVISOR_NAME=hassio_supervisor \
        -e SUPERVISOR_MACHINE="${MACHINE}" \
        "${SUPERVISOR}"
}

# Run supervisor
mkdir -p "${HASSIO_DATA}"
([ "${HASSIO_IMAGE_ID}" = "${HASSIO_CONTAINER_ID}" ] && docker start --attach hassio_supervisor) || runSupervisor

/storage/hassio/sbin/hassio-supervisor


[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] udev.sh: executing...
[14:50:26] INFO: Update udev information
[cont-init.d] udev.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[services.d] done.
20-08-15 14:50:28 INFO (MainThread) [__main__] Initialize Supervisor setup
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Initialize Supervisor Sentry
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Home Assistant configuration folder /data/homeassistant
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor SSL/TLS folder /data/ssl
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor Add-on data folder /data/addons/data
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor Add-on local repository folder /data/addons/local
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor Add-on git repositories folder /data/addons/git
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor temp folder /data/tmp
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor backup folder /data/backup
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor share folder /data/share
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor Apparmor folder /data/apparmor
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor DNS folder /data/dns
20-08-15 14:50:28 INFO (MainThread) [supervisor.bootstrap] Create Supervisor audio folder /data/audio
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
[s6-finish] waiting for services.
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

docker start --attach hassio_supervisor || runSupervisor

[s6-init] making user provided files available at /var/run/s6/etc...exited 0.
[s6-init] ensuring user provided files have correct perms...exited 0.
[fix-attrs.d] applying ownership & permissions fixes...
[fix-attrs.d] done.
[cont-init.d] executing container initialization scripts...
[cont-init.d] udev.sh: executing...
[14:54:08] INFO: Update udev information
[cont-init.d] udev.sh: exited 0.
[cont-init.d] done.
[services.d] starting services
[cont-finish.d] executing container finish scripts...
[cont-finish.d] done.
s6-svscanctl: fatal: unable to control /var/run/s6/services: supervisor not listening
[s6-finish] waiting for services.
s6-svscanctl: fatal: unable to control /var/run/s6/services: supervisor not listening
s6-svwait: fatal: unable to subscribe to events for /var/run/s6/services/supervisor: No such file or directory
[s6-finish] sending all processes the TERM signal.
[s6-finish] sending all processes the KILL signal and exiting.

Any ideas how I can go about this next, besides the good old “colin robinson answer of officially not supported”?

Thanks in advance for any answers other than the above not very helpful or inspiring answer.