|
11 | 11 | # Init supervisor |
12 | 12 | SUPERVISOR_DATA=/mnt/data/supervisor |
13 | 13 | SUPERVISOR_STARTUP_MARKER="/run/supervisor/startup-marker" |
| 14 | +SUPERVISOR_CIDFILE="${SUPERVISOR_DATA}/hassio_supervisor.cid" |
14 | 15 | SUPERVISOR_STARTSCRIPT_VERSION="/mnt/data/.hassos-supervisor-version" |
15 | 16 | SUPERVISOR_IMAGE="ghcr.io/home-assistant/${SUPERVISOR_ARCH}-hassio-supervisor" |
16 | 17 |
|
@@ -58,8 +59,8 @@ if [ -z "${SUPERVISOR_IMAGE_ID}" ]; then |
58 | 59 | docker tag "${SUPERVISOR_IMAGE}:${SUPERVISOR_VERSION}" "${SUPERVISOR_IMAGE}:latest" |
59 | 60 | else |
60 | 61 | # Pull failed, updater info might be corrupted or the release might have |
61 | | - # been removed from the container registry, delete the updater info |
62 | | - # to start from scratch on next try. |
| 62 | + # been removed from the container registry, delete the updater info |
| 63 | + # to start from scratch on next try. |
63 | 64 | echo "[ERROR] Supervisor download failed." |
64 | 65 | rm -f "${SUPERVISOR_DATA}/updater.json" |
65 | 66 | exit 1 |
|
87 | 88 |
|
88 | 89 | # If Supervisor container is missing, create it |
89 | 90 | if [ -z "${SUPERVISOR_CONTAINER_ID}" ]; then |
| 91 | + # We need to remove the CID file here, Docker will refuse to start if the |
| 92 | + # file is present. Single instance is ensured by other code paths. |
| 93 | + [ -f "${SUPERVISOR_CIDFILE}" ] && rm -f "${SUPERVISOR_CIDFILE}" |
| 94 | + |
90 | 95 | echo "[INFO] Creating a new Supervisor container..." |
91 | 96 | # shellcheck disable=SC2086 |
92 | 97 | docker container create \ |
93 | 98 | --name hassio_supervisor \ |
94 | 99 | --privileged --security-opt apparmor="hassio-supervisor" \ |
95 | 100 | --oom-score-adj=-300 \ |
| 101 | + --cidfile "${SUPERVISOR_CIDFILE}" \ |
| 102 | + --mount type=bind,src="${SUPERVISOR_CIDFILE}",dst=/run/cid,readonly \ |
96 | 103 | -v /run/docker.sock:/run/docker.sock:rw \ |
97 | 104 | -v /run/containerd/containerd.sock:/run/containerd/containerd.sock:rw \ |
98 | 105 | -v /run/systemd/journal/socket:/run/systemd/journal/socket:rw \ |
|
0 commit comments