Use WORKSPACE_DIRECTORY for add-on directory (#2000)

* Use WORKSPACE_DIRECTORY  for add-on directory

* Don't break Alpine backed WSL

* Add comment
This commit is contained in:
Joakim Sørensen
2021-05-12 11:49:53 +02:00
committed by GitHub
parent 9065f7056f
commit 4b7f3274bd
2 changed files with 12 additions and 9 deletions

View File

@@ -1,4 +1,3 @@
// Based on https://github.com/issacg/hassio-addon-devcontainer
{
"name": "Home Assistant Add-Ons",
"context": "..",
@@ -6,6 +5,9 @@
"appPort": ["7123:8123", "7357:4357"],
"postStartCommand": "service docker start",
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
"containerEnv": {
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
},
"extensions": [
"timonwong.shellcheck",
"esbenp.prettier-vscode"

View File

@@ -1,18 +1,19 @@
#!/bin/bash
set -eE
SUPERVISOR_VERSON="$(curl -s https://version.home-assistant.io/dev.json | jq -e -r '.supervisor')"
DOCKER_TIMEOUT=30
DOCKER_PID=0
SUPERVISOR_VERSON="$(curl -s https://version.home-assistant.io/dev.json | jq -e -r '.supervisor')"
function start_docker() {
local starttime
local endtime
update-alternatives --set iptables /usr/sbin/iptables-legacy || echo "Fails adjust iptables"
update-alternatives --set ip6tables /usr/sbin/iptables-legacy || echo "Fails adjust ip6tables"
if grep -q 'Alpine' /proc/version; then
# The docker daemon does not start when running Alpine backed WSL2 without adjusting iptables
update-alternatives --set iptables /usr/sbin/iptables-legacy || echo "Fails adjust iptables"
update-alternatives --set ip6tables /usr/sbin/iptables-legacy || echo "Fails adjust ip6tables"
fi
echo "Starting docker."
dockerd 2> /dev/null &
@@ -33,7 +34,6 @@ function start_docker() {
echo "Docker was initialized"
}
function stop_docker() {
local starttime
local endtime
@@ -79,13 +79,14 @@ 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 "/workspaces/addons":/data/addons/local: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 \
@@ -141,4 +142,4 @@ cleanup_docker
init_dbus
init_udev
run_supervisor
stop_docker
stop_docker