76 lines
2.0 KiB
Bash
Executable File
76 lines
2.0 KiB
Bash
Executable File
#!/bin/bash
|
|
|
|
set -e
|
|
|
|
source /etc/supervisor_scripts/common
|
|
|
|
echo "Run Supervisor"
|
|
|
|
start_docker
|
|
trap "stop_docker" ERR
|
|
|
|
function build_supervisor() {
|
|
docker pull "ghcr.io/home-assistant/${HA_ARCH}-builder:dev"
|
|
cosign verify \
|
|
--certificate-oidc-issuer https://token.actions.githubusercontent.com \
|
|
--certificate-identity-regexp https://github.com/home-assistant/builder/.* \
|
|
"ghcr.io/home-assistant/${HA_ARCH}-builder:dev"
|
|
|
|
docker run --rm \
|
|
--privileged \
|
|
-v /run/docker.sock:/run/docker.sock \
|
|
-v "$(pwd):/data" \
|
|
"ghcr.io/home-assistant/${HA_ARCH}-builder:dev" \
|
|
--generic latest \
|
|
--target /data \
|
|
--test \
|
|
"--${HA_ARCH}" \
|
|
--no-cache
|
|
}
|
|
|
|
function run_supervisor() {
|
|
sudo mkdir -p /workspaces/test_supervisor
|
|
|
|
echo "Start Supervisor"
|
|
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 "/workspaces/test_supervisor":/data:rw \
|
|
-v /etc/machine-id:/etc/machine-id:ro \
|
|
-v "${WD}:/usr/src/supervisor" \
|
|
-e SUPERVISOR_SHARE="/workspaces/test_supervisor" \
|
|
-e SUPERVISOR_NAME=hassio_supervisor \
|
|
-e SUPERVISOR_DEV=1 \
|
|
-e SUPERVISOR_MACHINE="qemu${QEMU_ARCH}" \
|
|
"ghcr.io/home-assistant/${HA_ARCH}-hassio-supervisor:latest"
|
|
}
|
|
|
|
|
|
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
|
|
build_supervisor
|
|
cleanup_lastboot
|
|
cleanup_docker
|
|
init_dbus
|
|
init_udev
|
|
init_os_agent
|
|
run_supervisor
|
|
stop_docker
|
|
fi
|