-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhassio-supervisor
37 lines (31 loc) · 1.22 KB
/
hassio-supervisor
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/usr/bin/env sh
set -e
# Load configs
CONFIG_FILE=/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})"
# 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