hassio-supervised-installer/homeassistant-supervised/usr/sbin/hassio-supervisor
Matheson Steplock 6003c366f9
Converting the supervised installer to a deb file (#154)
* laying the groundwork

* moving more stuff

* move files into place

* add control

* postinst script

* preinst

* added more to postinst and preinst

* I think this works

* fix gitignore and control

* fixes

* Delete homeassistant-supervised.deb

* Check network connection

* first test of build deb

* test 2

* create changelog

* switch to lowercase for github action

* test without args

* fix typo in example changelog

* Resolve errors

* Space out control

* added files to gitignore

* update gitignore

* putting everything in place

* revert actions changes

* Test action

* test workflow

* new action

* get rid of push

* set version number to match os agent format

* added machine type select

* move bin

* postrm undo dpkg-divert
2021-10-26 10:22:03 +02:00

37 lines
1.2 KiB
Bash

#!/usr/bin/env bash
set -e
# Load configs
CONFIG_FILE=%%HASSIO_CONFIG%%
SUPERVISOR="$(jq --raw-output '.supervisor' ${CONFIG_FILE})"
MACHINE="$(jq --raw-output '.machine' ${CONFIG_FILE})"
DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})"
# 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 \
--security-opt apparmor=hassio-supervisor \
--security-opt seccomp=unconfined \
-v /run/docker.sock:/run/docker.sock:rw \
-v /run/dbus:/run/dbus:ro \
-v /run/udev:/run/udev:ro \
-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