devcontainer/addons/rootfs/usr/bin/supervisor_run

54 lines
1.3 KiB
Bash
Executable File

#!/bin/bash
set -e
source /etc/supervisor_scripts/common
echo "Run Supervisor"
start_docker
trap "stop_docker" ERR
function run_supervisor() {
mkdir -p /tmp/supervisor_data
docker run --rm --privileged \
--name hassio_supervisor \
--privileged \
--security-opt seccomp=unconfined \
--security-opt apparmor=unconfined \
-v /run/docker.sock:/run/docker.sock:rw \
-v /run/dbus:/run/dbus:ro \
-v /run/udev:/run/udev:ro \
-v /tmp/supervisor_data:/data:rw \
-v "$WORKSPACE_DIRECTORY":/data/addons/local:rw \
-v /etc/machine-id:/etc/machine-id:ro \
-e SUPERVISOR_SHARE="/tmp/supervisor_data" \
-e SUPERVISOR_NAME=hassio_supervisor \
-e SUPERVISOR_DEV=1 \
-e SUPERVISOR_MACHINE="qemu${QEMU_ARCH}" \
"${SUPERVISOR_IMAGE}:${SUPERVISOR_VERSION}"
}
if [ "$( docker container inspect -f '{{.State.Status}}' hassio_supervisor )" == "running" ]; then
echo "Restarting Supervisor"
docker rm -f hassio_supervisor
init_dbus
init_udev
init_os_agent
cleanup_lastboot
run_supervisor
stop_docker
else
echo "Starting Supervisor"
docker system prune -f
cleanup_lastboot
cleanup_docker
init_dbus
init_udev
init_os_agent
run_supervisor
stop_docker
fi