New way to install/run supervisor + plugins (#620)
* Use new layout for CLI/Supervisor Signed-off-by: Pascal Vizeli <pvizeli@syshack.ch> * Fix install script * Fix config * Add docs * Fix shellcheck * Fix issue * rename package * Fix build * Fix apparmor
This commit is contained in:
16
buildroot-external/package/hassio/Config.in
Normal file
16
buildroot-external/package/hassio/Config.in
Normal file
@@ -0,0 +1,16 @@
|
||||
menuconfig BR2_PACKAGE_HASSIO
|
||||
bool "Supervisor App"
|
||||
help
|
||||
This is the Application layer they build the
|
||||
data partition with configurations.
|
||||
|
||||
https://github.com/home-assistant/supervisor
|
||||
|
||||
if BR2_PACKAGE_HASSIO
|
||||
|
||||
config BR2_PACKAGE_HASSIO_ARCH
|
||||
string "Supervisor Arch"
|
||||
help
|
||||
Supervisor architecture which should be pull.
|
||||
|
||||
endif
|
||||
@@ -8,12 +8,13 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
jq \
|
||||
gpg-agent \
|
||||
software-properties-common \
|
||||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add - \
|
||||
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
docker-ce=5:19.03.5~3-0~ubuntu-bionic \
|
||||
docker-ce docker-ce-cli containerd.io \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
|
||||
COPY hostapp.sh /usr/bin/
|
||||
88
buildroot-external/package/hassio/builder/hostapp.sh
Executable file
88
buildroot-external/package/hassio/builder/hostapp.sh
Executable file
@@ -0,0 +1,88 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
ARCH=
|
||||
DATA_IMG="/export/data.ext4"
|
||||
VERSION_URL="https://version.home-assistant.io/stable.json"
|
||||
APPARMOR_URL="https://version.home-assistant.io/apparmor.txt"
|
||||
|
||||
# Parse
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key=$1
|
||||
case $key in
|
||||
--arch)
|
||||
ARCH=$2
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
SUPERVISOR="homeassistant/${ARCH}-hassio-supervisor"
|
||||
DNS="homeassistant/${ARCH}-hassio-dns"
|
||||
AUDIO="homeassistant/${ARCH}-hassio-audio"
|
||||
CLI="homeassistant/${ARCH}-hassio-cli"
|
||||
MULTICAST="homeassistant/${ARCH}-hassio-multicast"
|
||||
|
||||
SUPERVISOR_VERSION=$(curl -s ${VERSION_URL} | jq -e -r '.supervisor')
|
||||
DNS_VERSION=$(curl -s ${VERSION_URL} | jq -e -r '.dns')
|
||||
CLI_VERSION=$(curl -s ${VERSION_URL} | jq -e -r '.cli')
|
||||
AUDIO_VERSION=$(curl -s ${VERSION_URL} | jq -e -r '.audio')
|
||||
MULTICAST_VERSION=$(curl -s ${VERSION_URL} | jq -e -r '.multicast')
|
||||
|
||||
# Make image
|
||||
dd if=/dev/zero of=${DATA_IMG} bs=1G count=1
|
||||
mkfs.ext4 -L "hassos-data" -E lazy_itable_init=0,lazy_journal_init=0 ${DATA_IMG}
|
||||
|
||||
# Setup local user
|
||||
if [ "${BUILDER_UID:0}" -ne 0 ] && [ "${BUILDER_GID:0}" -ne 0 ]; then
|
||||
groupadd -g "${BUILDER_GID}" builder
|
||||
useradd -m -u "${BUILDER_UID}" -g "${BUILDER_GID}" -G docker builder
|
||||
chown builder:builder ${DATA_IMG}
|
||||
fi
|
||||
|
||||
# Mount / init file structs
|
||||
mkdir -p /mnt/data/
|
||||
mount -o loop ${DATA_IMG} /mnt/data
|
||||
mkdir -p /mnt/data/docker
|
||||
|
||||
# Run dockerd
|
||||
dockerd -s overlay2 -g /mnt/data/docker &
|
||||
DOCKER_PID=$!
|
||||
|
||||
DOCKER_COUNT=0
|
||||
until docker info >/dev/null 2>&1; do
|
||||
if [ ${DOCKER_COUNT} -gt 30 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
DOCKER_COUNT=$((DOCKER_COUNT + 1))
|
||||
done
|
||||
|
||||
# Install supervisor
|
||||
docker pull "${SUPERVISOR}:${SUPERVISOR_VERSION}"
|
||||
docker tag "${SUPERVISOR}:${SUPERVISOR_VERSION}" "${SUPERVISOR}:latest"
|
||||
|
||||
# Install Plugins
|
||||
docker pull "${CLI}:${CLI_VERSION}"
|
||||
docker pull "${DNS}:${DNS_VERSION}"
|
||||
docker pull "${AUDIO}:${AUDIO_VERSION}"
|
||||
docker pull "${MULTICAST}:${MULTICAST_VERSION}"
|
||||
|
||||
# Setup AppArmor
|
||||
mkdir -p "/mnt/data/supervisor/apparmor"
|
||||
curl -sL -o "/mnt/data/supervisor/apparmor/hassio-supervisor" "${APPARMOR_URL}"
|
||||
|
||||
# Finish
|
||||
kill $DOCKER_PID && wait $DOCKER_PID
|
||||
|
||||
# Unmount resource
|
||||
if ! umount /mnt/data; then
|
||||
umount -f /mnt/data || echo "umount force fails!"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
25
buildroot-external/package/hassio/hassio.mk
Normal file
25
buildroot-external/package/hassio/hassio.mk
Normal file
@@ -0,0 +1,25 @@
|
||||
################################################################################
|
||||
#
|
||||
# HassOS
|
||||
#
|
||||
################################################################################
|
||||
|
||||
HASSIO_VERSION = 1.0.0
|
||||
HASSIO_LICENSE = Apache License 2.0
|
||||
HASSIO_LICENSE_FILES = $(BR2_EXTERNAL_HASSOS_PATH)/../LICENSE
|
||||
HASSIO_SITE = $(BR2_EXTERNAL_HASSOS_PATH)/package/hassio
|
||||
HASSIO_SITE_METHOD = local
|
||||
|
||||
define HASSIO_BUILD_CMDS
|
||||
docker build --tag hassos-hostapps $(@D)/builder
|
||||
endef
|
||||
|
||||
define HASSIO_INSTALL_TARGET_CMDS
|
||||
docker run --rm --privileged \
|
||||
-e BUILDER_UID="$(shell id -u)" -e BUILDER_GID="$(shell id -g)" \
|
||||
-v $(BINARIES_DIR):/export \
|
||||
hassos-hostapps \
|
||||
--arch $(BR2_PACKAGE_HASSIO_ARCH)
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
@@ -1,66 +0,0 @@
|
||||
menuconfig BR2_PACKAGE_HASSOS
|
||||
bool "hassos-app"
|
||||
help
|
||||
This is the Application layer they build the
|
||||
data partition with configurations.
|
||||
|
||||
https://github.com/home-assistant/hassos
|
||||
|
||||
if BR2_PACKAGE_HASSOS
|
||||
|
||||
config BR2_PACKAGE_HASSOS_SUPERVISOR
|
||||
string "supervisor docker image"
|
||||
help
|
||||
Name of supervisor docker image they will be build in.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_SUPERVISOR_VERSION
|
||||
string "supervisor docker image version"
|
||||
help
|
||||
Version of supervisor docker image they will be build in.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_SUPERVISOR_ARGS
|
||||
string "supervisor docker arguments"
|
||||
help
|
||||
Extended docker arguments to run the supervisor.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_SUPERVISOR_PROFILE
|
||||
string "AppArmor supervisor profile"
|
||||
help
|
||||
AppArmor profile for supervisor.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_SUPERVISOR_PROFILE_URL
|
||||
string "AppArmor supervisor profile URL"
|
||||
help
|
||||
AppArmor profile for supervisor url.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_CLI
|
||||
string "cli docker image"
|
||||
help
|
||||
Name of cli docker image they will be build in.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_CLI_VERSION
|
||||
string "cli docker image version"
|
||||
help
|
||||
Version of cli docker image they will be build in.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_CLI_ARGS
|
||||
string "cli docker arguments"
|
||||
help
|
||||
Extended docker arguments to run the cli.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_CLI_PROFILE
|
||||
string "AppArmor cli profile"
|
||||
help
|
||||
AppArmor profile for cli.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_CLI_PROFILE_URL
|
||||
string "AppArmor cli profile url"
|
||||
help
|
||||
AppArmor profile for cli url.
|
||||
|
||||
config BR2_PACKAGE_HASSOS_APPARMOR_DIR
|
||||
string "AppArmor profiles folder"
|
||||
help
|
||||
AppArmor profiles folder for HassOS.
|
||||
|
||||
endif
|
||||
@@ -1,146 +0,0 @@
|
||||
#!/bin/bash
|
||||
set -e
|
||||
|
||||
SUPERVISOR=""
|
||||
SUPERVISOR_VERSION=""
|
||||
SUPERVISOR_ARGS=""
|
||||
SUPERVISOR_PROFILE=""
|
||||
SUPERVISOR_PROFILE_URL=""
|
||||
CLI=""
|
||||
CLI_VERSION=""
|
||||
CLI_ARGS=""
|
||||
CLI_PROFILE=""
|
||||
CLI_PROFILE_URL=""
|
||||
APPARMOR=""
|
||||
DATA_IMG="/export/data.ext4"
|
||||
|
||||
# Parse
|
||||
while [[ $# -gt 0 ]]; do
|
||||
key=$1
|
||||
case $key in
|
||||
--supervisor)
|
||||
SUPERVISOR=$2
|
||||
shift
|
||||
;;
|
||||
--supervisor-version)
|
||||
SUPERVISOR_VERSION=$2
|
||||
shift
|
||||
;;
|
||||
--supervisor-args)
|
||||
SUPERVISOR_ARGS=$2
|
||||
shift
|
||||
;;
|
||||
--supervisor-profile)
|
||||
SUPERVISOR_PROFILE=$2
|
||||
shift
|
||||
;;
|
||||
--supervisor-profile-url)
|
||||
SUPERVISOR_PROFILE_URL=$2
|
||||
shift
|
||||
;;
|
||||
--cli)
|
||||
CLI=$2
|
||||
shift
|
||||
;;
|
||||
--cli-version)
|
||||
CLI_VERSION=$2
|
||||
shift
|
||||
;;
|
||||
--cli-args)
|
||||
CLI_ARGS=$2
|
||||
shift
|
||||
;;
|
||||
--cli-profile)
|
||||
CLI_PROFILE=$2
|
||||
shift
|
||||
;;
|
||||
--cli-profile-url)
|
||||
CLI_PROFILE_URL=$2
|
||||
shift
|
||||
;;
|
||||
--apparmor)
|
||||
APPARMOR=$2
|
||||
shift
|
||||
;;
|
||||
*)
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
shift
|
||||
done
|
||||
|
||||
# Make image
|
||||
dd if=/dev/zero of=${DATA_IMG} bs=1G count=1
|
||||
mkfs.ext4 -L "hassos-data" -E lazy_itable_init=0,lazy_journal_init=0 ${DATA_IMG}
|
||||
|
||||
# Setup local user
|
||||
if [ "${BUILDER_UID:0}" -ne 0 ] && [ "${BUILDER_GID:0}" -ne 0 ]; then
|
||||
groupadd -g "${BUILDER_GID}" builder
|
||||
useradd -m -u "${BUILDER_UID}" -g "${BUILDER_GID}" -G docker builder
|
||||
chown builder:builder ${DATA_IMG}
|
||||
fi
|
||||
|
||||
# Mount / init file structs
|
||||
mkdir -p /mnt/data/
|
||||
mount -o loop ${DATA_IMG} /mnt/data
|
||||
mkdir -p /mnt/data/docker
|
||||
|
||||
# Run dockerd
|
||||
dockerd -s overlay2 -g /mnt/data/docker &
|
||||
DOCKER_PID=$!
|
||||
|
||||
DOCKER_COUNT=0
|
||||
until docker info >/dev/null 2>&1; do
|
||||
if [ ${DOCKER_COUNT} -gt 30 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
sleep 1
|
||||
DOCKER_COUNT=$((DOCKER_COUNT + 1))
|
||||
done
|
||||
|
||||
# Install supervisor
|
||||
docker pull "${SUPERVISOR}:${SUPERVISOR_VERSION}"
|
||||
docker tag "${SUPERVISOR}:${SUPERVISOR_VERSION}" "${SUPERVISOR}:latest"
|
||||
|
||||
# Install cli
|
||||
docker pull "${CLI}:${CLI_VERSION}"
|
||||
docker tag "${CLI}:${CLI_VERSION}" "${CLI}:latest"
|
||||
|
||||
# Write config
|
||||
cat > /mnt/data/hassos.json <<- EOF
|
||||
{
|
||||
"supervisor": "${SUPERVISOR}",
|
||||
"supervisor_args": "${SUPERVISOR_ARGS}",
|
||||
"supervisor_apparmor": "${SUPERVISOR_PROFILE}",
|
||||
"cli": "${CLI}",
|
||||
"cli_args": "${CLI_ARGS}",
|
||||
"cli_apparmor": "${CLI_PROFILE}",
|
||||
"apparmor": "${APPARMOR}"
|
||||
}
|
||||
EOF
|
||||
|
||||
# Setup AppArmor
|
||||
if [ -n "${APPARMOR}" ]; then
|
||||
mkdir -p "/mnt/data/${APPARMOR}"
|
||||
|
||||
# Supervisor
|
||||
if [ -n "${SUPERVISOR_PROFILE_URL}" ]; then
|
||||
curl -sL -o "/mnt/data/${APPARMOR}/${SUPERVISOR_PROFILE}" "${SUPERVISOR_PROFILE_URL}"
|
||||
fi
|
||||
|
||||
# CLI
|
||||
if [ -n "${CLI_PROFILE_URL}" ]; then
|
||||
curl -sL -o "/mnt/data/${APPARMOR}/${CLI_PROFILE}" "${CLI_PROFILE_URL}"
|
||||
fi
|
||||
fi
|
||||
|
||||
# Finish
|
||||
kill $DOCKER_PID && wait $DOCKER_PID
|
||||
|
||||
# Unmount resource
|
||||
if ! umount /mnt/data; then
|
||||
umount -f /mnt/data || echo "umount force fails!"
|
||||
fi
|
||||
|
||||
exit 0
|
||||
@@ -1,35 +0,0 @@
|
||||
################################################################################
|
||||
#
|
||||
# HassOS
|
||||
#
|
||||
################################################################################
|
||||
|
||||
HASSOS_VERSION = 1.0.0
|
||||
HASSOS_LICENSE = Apache License 2.0
|
||||
HASSOS_LICENSE_FILES = $(BR2_EXTERNAL_HASSOS_PATH)/../LICENSE
|
||||
HASSOS_SITE = $(BR2_EXTERNAL_HASSOS_PATH)/package/hassos
|
||||
HASSOS_SITE_METHOD = local
|
||||
|
||||
define HASSOS_BUILD_CMDS
|
||||
docker build --tag hassos-hostapps $(@D)/builder
|
||||
endef
|
||||
|
||||
define HASSOS_INSTALL_TARGET_CMDS
|
||||
docker run --rm --privileged \
|
||||
-e BUILDER_UID="$(shell id -u)" -e BUILDER_GID="$(shell id -g)" \
|
||||
-v $(BINARIES_DIR):/export \
|
||||
hassos-hostapps \
|
||||
--supervisor $(BR2_PACKAGE_HASSOS_SUPERVISOR) \
|
||||
--supervisor-version $(BR2_PACKAGE_HASSOS_SUPERVISOR_VERSION) \
|
||||
--supervisor-args $(BR2_PACKAGE_HASSOS_SUPERVISOR_ARGS) \
|
||||
--supervisor-profile $(BR2_PACKAGE_HASSOS_SUPERVISOR_PROFILE) \
|
||||
--supervisor-profile-url $(BR2_PACKAGE_HASSOS_SUPERVISOR_PROFILE_URL) \
|
||||
--cli $(BR2_PACKAGE_HASSOS_CLI) \
|
||||
--cli-version $(BR2_PACKAGE_HASSOS_CLI_VERSION) \
|
||||
--cli-args $(BR2_PACKAGE_HASSOS_CLI_ARGS) \
|
||||
--cli-profile $(BR2_PACKAGE_HASSOS_CLI_PROFILE) \
|
||||
--cli-profile-url $(BR2_PACKAGE_HASSOS_CLI_PROFILE_URL) \
|
||||
--apparmor $(BR2_PACKAGE_HASSOS_APPARMOR_DIR)
|
||||
endef
|
||||
|
||||
$(eval $(generic-package))
|
||||
Reference in New Issue
Block a user