mirror of
https://github.com/home-assistant/supervisor.git
synced 2025-07-08 17:56:33 +00:00
Adjust development tasks (#2425)
* Adjust development tasks * add development
This commit is contained in:
parent
1434077f4e
commit
01a6e074a5
@ -2,6 +2,11 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:0-3.8
|
|||||||
|
|
||||||
WORKDIR /workspaces
|
WORKDIR /workspaces
|
||||||
|
|
||||||
|
# Set Docker daemon config
|
||||||
|
RUN \
|
||||||
|
mkdir -p /etc/docker \
|
||||||
|
&& echo '{"storage-driver": "vfs"}' > /etc/docker/daemon.json
|
||||||
|
|
||||||
# Install Node/Yarn for Frontent
|
# Install Node/Yarn for Frontent
|
||||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||||
curl \
|
curl \
|
||||||
|
22
.vscode/tasks.json
vendored
22
.vscode/tasks.json
vendored
@ -2,9 +2,9 @@
|
|||||||
"version": "2.0.0",
|
"version": "2.0.0",
|
||||||
"tasks": [
|
"tasks": [
|
||||||
{
|
{
|
||||||
"label": "Run Testenv",
|
"label": "Run Supervisor",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "./scripts/test_env.sh",
|
"command": "./scripts/run-supervisor.sh",
|
||||||
"group": {
|
"group": {
|
||||||
"kind": "test",
|
"kind": "test",
|
||||||
"isDefault": true
|
"isDefault": true
|
||||||
@ -16,7 +16,21 @@
|
|||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Run Testenv CLI",
|
"label": "Build Supervisor",
|
||||||
|
"type": "shell",
|
||||||
|
"command": "./scripts/build-supervisor.sh",
|
||||||
|
"group": {
|
||||||
|
"kind": "build",
|
||||||
|
"isDefault": true
|
||||||
|
},
|
||||||
|
"presentation": {
|
||||||
|
"reveal": "always",
|
||||||
|
"panel": "new"
|
||||||
|
},
|
||||||
|
"problemMatcher": []
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"label": "Run Supervisor CLI",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "docker exec -ti hassio_cli /usr/bin/cli.sh",
|
"command": "docker exec -ti hassio_cli /usr/bin/cli.sh",
|
||||||
"group": {
|
"group": {
|
||||||
@ -30,7 +44,7 @@
|
|||||||
"problemMatcher": []
|
"problemMatcher": []
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"label": "Update UI",
|
"label": "Update Supervisor Panel",
|
||||||
"type": "shell",
|
"type": "shell",
|
||||||
"command": "./scripts/update-frontend.sh",
|
"command": "./scripts/update-frontend.sh",
|
||||||
"group": {
|
"group": {
|
||||||
|
29
README.md
29
README.md
@ -10,26 +10,23 @@ network settings or installing and updating software.
|
|||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
|
|
||||||
Installation instructions can be found at https://home-assistant.io/hassio.
|
Installation instructions can be found at https://home-assistant.io/getting-started.
|
||||||
|
|
||||||
## Development
|
## Development
|
||||||
|
|
||||||
The development of the Supervisor is not difficult but tricky.
|
For small changes and bugfixes you can just follow this, but for significant changes open a RFC first.
|
||||||
|
Development instructions can be found [here][development].
|
||||||
- You can use the builder to create your Supervisor: https://github.com/home-assistant/hassio-builder
|
|
||||||
- Access a HassOS device or VM and pull your Supervisor.
|
|
||||||
- Set the developer modus with the CLI tool: `ha supervisor options --channel=dev`
|
|
||||||
- Tag it as `homeassistant/xy-hassio-supervisor:latest`
|
|
||||||
- Restart the service with `systemctl restart hassos-supervisor | journalctl -fu hassos-supervisor`
|
|
||||||
- Test your changes
|
|
||||||
|
|
||||||
For small bugfixes or improvements, make a PR. For significant changes open a RFC first, please. Thanks.
|
|
||||||
|
|
||||||
## Release
|
## Release
|
||||||
|
|
||||||
Follow is the relase circle process:
|
Releases are done in 3 stages (channels) with this structure:
|
||||||
|
|
||||||
1. Merge master into dev / make sure version stay on dev
|
1. Pull requests are merged to the `main` branch
|
||||||
2. Merge dev into master
|
2. A new build is pushed to the `dev` stage.
|
||||||
3. Bump the release on master
|
3. Releases are published
|
||||||
4. Create a GitHub Release from master with the right version tag
|
4. A new build is pushed to the `beta` stage.
|
||||||
|
5. The [`stable.json][stable] file is updated
|
||||||
|
6. The build that was pushed to `beta` will now be pushed to `stable`
|
||||||
|
|
||||||
|
[development]: https://developers.home-assistant.io/docs/supervisor/development
|
||||||
|
[stable]: https://github.com/home-assistant/version/blob/master/stable.json
|
||||||
|
28
scripts/build-supervisor.sh
Executable file
28
scripts/build-supervisor.sh
Executable file
@ -0,0 +1,28 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source "${BASH_SOURCE[0]%/*}/common.sh"
|
||||||
|
|
||||||
|
set -eE
|
||||||
|
|
||||||
|
DOCKER_TIMEOUT=30
|
||||||
|
DOCKER_PID=0
|
||||||
|
|
||||||
|
function build_supervisor() {
|
||||||
|
docker pull homeassistant/amd64-builder:dev
|
||||||
|
|
||||||
|
docker run --rm \
|
||||||
|
--privileged \
|
||||||
|
-v /run/docker.sock:/run/docker.sock \
|
||||||
|
-v "$(pwd):/data" \
|
||||||
|
homeassistant/amd64-builder:dev \
|
||||||
|
--generic latest \
|
||||||
|
--target /data \
|
||||||
|
--test \
|
||||||
|
--amd64 \
|
||||||
|
--no-cache
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Build Supervisor"
|
||||||
|
start_docker
|
||||||
|
trap "stop_docker" ERR
|
||||||
|
|
||||||
|
build_supervisor
|
58
scripts/common.sh
Normal file
58
scripts/common.sh
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
function start_docker() {
|
||||||
|
local starttime
|
||||||
|
local endtime
|
||||||
|
|
||||||
|
echo "Starting docker."
|
||||||
|
dockerd 2> /dev/null &
|
||||||
|
DOCKER_PID=$!
|
||||||
|
|
||||||
|
echo "Waiting for docker to initialize..."
|
||||||
|
starttime="$(date +%s)"
|
||||||
|
endtime="$(date +%s)"
|
||||||
|
until docker info >/dev/null 2>&1; do
|
||||||
|
if [ $((endtime - starttime)) -le $DOCKER_TIMEOUT ]; then
|
||||||
|
sleep 1
|
||||||
|
endtime=$(date +%s)
|
||||||
|
else
|
||||||
|
echo "Timeout while waiting for docker to come up"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
echo "Docker was initialized"
|
||||||
|
}
|
||||||
|
|
||||||
|
function stop_docker() {
|
||||||
|
local starttime
|
||||||
|
local endtime
|
||||||
|
|
||||||
|
echo "Stopping in container docker..."
|
||||||
|
if [ "$DOCKER_PID" -gt 0 ] && kill -0 "$DOCKER_PID" 2> /dev/null; then
|
||||||
|
starttime="$(date +%s)"
|
||||||
|
endtime="$(date +%s)"
|
||||||
|
|
||||||
|
# Now wait for it to die
|
||||||
|
kill "$DOCKER_PID"
|
||||||
|
while kill -0 "$DOCKER_PID" 2> /dev/null; do
|
||||||
|
if [ $((endtime - starttime)) -le $DOCKER_TIMEOUT ]; then
|
||||||
|
sleep 1
|
||||||
|
endtime=$(date +%s)
|
||||||
|
else
|
||||||
|
echo "Timeout while waiting for container docker to die"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
else
|
||||||
|
echo "Your host might have been left with unreleased resources"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
function cleanup_lastboot() {
|
||||||
|
if [[ -f /workspaces/test_supervisor/config.json ]]; then
|
||||||
|
echo "Cleaning up last boot"
|
||||||
|
cp /workspaces/test_supervisor/config.json /tmp/config.json
|
||||||
|
jq -rM 'del(.last_boot)' /tmp/config.json > /workspaces/test_supervisor/config.json
|
||||||
|
rm /tmp/config.json
|
||||||
|
fi
|
||||||
|
}
|
81
scripts/run-supervisor.sh
Executable file
81
scripts/run-supervisor.sh
Executable file
@ -0,0 +1,81 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
source "${BASH_SOURCE[0]%/*}/common.sh"
|
||||||
|
source "${BASH_SOURCE[0]%/*}/build-supervisor.sh"
|
||||||
|
|
||||||
|
set -eE
|
||||||
|
|
||||||
|
DOCKER_TIMEOUT=30
|
||||||
|
DOCKER_PID=0
|
||||||
|
|
||||||
|
|
||||||
|
function cleanup_docker() {
|
||||||
|
echo "Cleaning up stopped containers..."
|
||||||
|
docker rm $(docker ps -a -q) || true
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function run_supervisor() {
|
||||||
|
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 \
|
||||||
|
-v /run/dbus:/run/dbus \
|
||||||
|
-v "/workspaces/test_supervisor":/data \
|
||||||
|
-v /etc/machine-id:/etc/machine-id:ro \
|
||||||
|
-v /workspaces/supervisor:/usr/src/supervisor \
|
||||||
|
-e SUPERVISOR_SHARE="/workspaces/test_supervisor" \
|
||||||
|
-e SUPERVISOR_NAME=hassio_supervisor \
|
||||||
|
-e SUPERVISOR_DEV=1 \
|
||||||
|
-e SUPERVISOR_MACHINE="qemux86-64" \
|
||||||
|
homeassistant/amd64-hassio-supervisor:latest
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function init_dbus() {
|
||||||
|
if pgrep dbus-daemon; then
|
||||||
|
echo "Dbus is running"
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
echo "Startup dbus"
|
||||||
|
mkdir -p /var/lib/dbus
|
||||||
|
cp -f /etc/machine-id /var/lib/dbus/machine-id
|
||||||
|
|
||||||
|
# cleanups
|
||||||
|
mkdir -p /run/dbus
|
||||||
|
rm -f /run/dbus/pid
|
||||||
|
|
||||||
|
# run
|
||||||
|
dbus-daemon --system --print-address
|
||||||
|
}
|
||||||
|
|
||||||
|
echo "Run Supervisor"
|
||||||
|
|
||||||
|
start_docker
|
||||||
|
trap "stop_docker" ERR
|
||||||
|
|
||||||
|
|
||||||
|
if [ "$( docker container inspect -f '{{.State.Status}}' hassio_supervisor )" == "running" ]; then
|
||||||
|
echo "Restarting Supervisor"
|
||||||
|
docker rm -f hassio_supervisor
|
||||||
|
init_dbus
|
||||||
|
cleanup_lastboot
|
||||||
|
run_supervisor
|
||||||
|
stop_docker
|
||||||
|
|
||||||
|
else
|
||||||
|
echo "Starting Supervisor"
|
||||||
|
docker system prune -f
|
||||||
|
build_supervisor
|
||||||
|
cleanup_lastboot
|
||||||
|
cleanup_docker
|
||||||
|
init_dbus
|
||||||
|
run_supervisor
|
||||||
|
stop_docker
|
||||||
|
fi
|
@ -1,135 +0,0 @@
|
|||||||
#!/bin/bash
|
|
||||||
set -eE
|
|
||||||
|
|
||||||
DOCKER_TIMEOUT=30
|
|
||||||
DOCKER_PID=0
|
|
||||||
|
|
||||||
|
|
||||||
function start_docker() {
|
|
||||||
local starttime
|
|
||||||
local endtime
|
|
||||||
|
|
||||||
echo "Starting docker."
|
|
||||||
dockerd 2> /dev/null &
|
|
||||||
DOCKER_PID=$!
|
|
||||||
|
|
||||||
echo "Waiting for docker to initialize..."
|
|
||||||
starttime="$(date +%s)"
|
|
||||||
endtime="$(date +%s)"
|
|
||||||
until docker info >/dev/null 2>&1; do
|
|
||||||
if [ $((endtime - starttime)) -le $DOCKER_TIMEOUT ]; then
|
|
||||||
sleep 1
|
|
||||||
endtime=$(date +%s)
|
|
||||||
else
|
|
||||||
echo "Timeout while waiting for docker to come up"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
echo "Docker was initialized"
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function stop_docker() {
|
|
||||||
local starttime
|
|
||||||
local endtime
|
|
||||||
|
|
||||||
echo "Stopping in container docker..."
|
|
||||||
if [ "$DOCKER_PID" -gt 0 ] && kill -0 "$DOCKER_PID" 2> /dev/null; then
|
|
||||||
starttime="$(date +%s)"
|
|
||||||
endtime="$(date +%s)"
|
|
||||||
|
|
||||||
# Now wait for it to die
|
|
||||||
kill "$DOCKER_PID"
|
|
||||||
while kill -0 "$DOCKER_PID" 2> /dev/null; do
|
|
||||||
if [ $((endtime - starttime)) -le $DOCKER_TIMEOUT ]; then
|
|
||||||
sleep 1
|
|
||||||
endtime=$(date +%s)
|
|
||||||
else
|
|
||||||
echo "Timeout while waiting for container docker to die"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
done
|
|
||||||
else
|
|
||||||
echo "Your host might have been left with unreleased resources"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function build_supervisor() {
|
|
||||||
docker pull homeassistant/amd64-builder:dev
|
|
||||||
|
|
||||||
docker run --rm --privileged \
|
|
||||||
-v /run/docker.sock:/run/docker.sock -v "$(pwd):/data" \
|
|
||||||
homeassistant/amd64-builder:dev \
|
|
||||||
--generic dev -t /data --test --amd64 --no-cache
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function cleanup_lastboot() {
|
|
||||||
if [[ -f /workspaces/test_supervisor/config.json ]]; then
|
|
||||||
echo "Cleaning up last boot"
|
|
||||||
cp /workspaces/test_supervisor/config.json /tmp/config.json
|
|
||||||
jq -rM 'del(.last_boot)' /tmp/config.json > /workspaces/test_supervisor/config.json
|
|
||||||
rm /tmp/config.json
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function cleanup_docker() {
|
|
||||||
echo "Cleaning up stopped containers..."
|
|
||||||
docker rm $(docker ps -a -q) || true
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function setup_test_env() {
|
|
||||||
mkdir -p /workspaces/test_supervisor
|
|
||||||
|
|
||||||
echo "Start Supervisor"
|
|
||||||
docker run --rm --privileged \
|
|
||||||
--name hassio_supervisor \
|
|
||||||
--security-opt seccomp=unconfined \
|
|
||||||
--security-opt apparmor:unconfined \
|
|
||||||
-v /run/docker.sock:/run/docker.sock \
|
|
||||||
-v /run/dbus:/run/dbus \
|
|
||||||
-v "/workspaces/test_supervisor":/data \
|
|
||||||
-v /etc/machine-id:/etc/machine-id:ro \
|
|
||||||
-e SUPERVISOR_SHARE="/workspaces/test_supervisor" \
|
|
||||||
-e SUPERVISOR_NAME=hassio_supervisor \
|
|
||||||
-e SUPERVISOR_DEV=1 \
|
|
||||||
-e SUPERVISOR_MACHINE="qemux86-64" \
|
|
||||||
homeassistant/amd64-hassio-supervisor:latest
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
function init_dbus() {
|
|
||||||
if pgrep dbus-daemon; then
|
|
||||||
echo "Dbus is running"
|
|
||||||
return 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
echo "Startup dbus"
|
|
||||||
mkdir -p /var/lib/dbus
|
|
||||||
cp -f /etc/machine-id /var/lib/dbus/machine-id
|
|
||||||
|
|
||||||
# cleanups
|
|
||||||
mkdir -p /run/dbus
|
|
||||||
rm -f /run/dbus/pid
|
|
||||||
|
|
||||||
# run
|
|
||||||
dbus-daemon --system --print-address
|
|
||||||
}
|
|
||||||
|
|
||||||
echo "Start Test-Env"
|
|
||||||
|
|
||||||
start_docker
|
|
||||||
trap "stop_docker" ERR
|
|
||||||
|
|
||||||
docker system prune -f
|
|
||||||
|
|
||||||
build_supervisor
|
|
||||||
cleanup_lastboot
|
|
||||||
cleanup_docker
|
|
||||||
init_dbus
|
|
||||||
setup_test_env
|
|
||||||
stop_docker
|
|
Loading…
x
Reference in New Issue
Block a user