mirror of
https://github.com/lildude/ha-addon-teslamate.git
synced 2026-10-13 13:10:30 -04:00
Update, refactor and restructure repo (#1)
* Remove unused files * Update dev env * Update config * Update docker config * Add translations * Update run script * Auto-gen enc key if not set * Replace workflows * Replace dependabot with renovate * Remove armhf * Lint * Remove armhf * Whoops * Remove stray comma * Add image * Reorder options * Split and improve docs * Add back image line * Update cw * Typo * Use correct org * Move bootstrap to run * Update scripts * Update config * Add note about database * Label in dockerfile * tmp force devcontainer version * Start implementing db creation if not exists * Create DB if doesn't exist * Update words * Remove unused file
This commit is contained in:
@@ -1,45 +0,0 @@
|
||||
FROM ubuntu:20.04
|
||||
|
||||
WORKDIR /workspaces
|
||||
|
||||
# Default ENV
|
||||
ENV LANG C.UTF-8
|
||||
ENV DEBIAN_FRONTEND noninteractive
|
||||
|
||||
# Set shell
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Use the mirror protocol for a fast mirror
|
||||
RUN sed -i -e 's/http:\/\/archive\.ubuntu\.com\/ubuntu\//mirror:\/\/mirrors\.ubuntu\.com\/mirrors\.txt/' /etc/apt/sources.list
|
||||
|
||||
# Install docker, jq, socat
|
||||
# https://docs.docker.com/engine/installation/linux/docker-ce/ubuntu/
|
||||
RUN apt-get update && apt-get install -y --no-install-recommends \
|
||||
apt-transport-https \
|
||||
ca-certificates \
|
||||
curl \
|
||||
dbus \
|
||||
software-properties-common \
|
||||
gpg-agent \
|
||||
git \
|
||||
jq \
|
||||
socat \
|
||||
sudo \
|
||||
&& curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add - \
|
||||
&& add-apt-repository "deb https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" \
|
||||
&& apt-get update && apt-get install -y --no-install-recommends \
|
||||
docker-ce \
|
||||
docker-ce-cli \
|
||||
containerd.io
|
||||
# This is a development container. Don't bother to clean up apt cache, this way we have it handy later
|
||||
|
||||
COPY .devcontainer/start_ha.sh /usr/local/bin/start_ha.sh
|
||||
|
||||
# Install dependencies for the add-on development below. For example, if you're running Node.js,
|
||||
# you may want something like the following...
|
||||
# RUN apt-get install -y --no-install-recommends nodejs npm
|
||||
|
||||
# Generate a machine-id for this container
|
||||
RUN rm /etc/machine-id && dbus-uuidgen --ensure=/etc/machine-id
|
||||
|
||||
ENV DEBIAN_FRONTEND=dialog
|
||||
@@ -1,29 +1,31 @@
|
||||
// For format details, see https://aka.ms/vscode-remote/devcontainer.json
|
||||
// TODO: When https://github.com/microsoft/vscode-remote-release/issues/2129 is fixed, move to ${localWorkspaceFolderBasename}\
|
||||
{
|
||||
"name": "Home Assistant Add-On",
|
||||
"context": "..",
|
||||
"dockerFile": "Dockerfile",
|
||||
"appPort": 8123,
|
||||
"runArgs": [
|
||||
"-e",
|
||||
"GIT_EDITOR=code --wait",
|
||||
"--privileged"
|
||||
],
|
||||
"settings": {
|
||||
"terminal.integrated.shell.linux": "/bin/bash"
|
||||
},
|
||||
"workspaceMount": "source=${localWorkspaceFolder},target=/workspaces/test_hassio/addons/local/myaddon,type=bind,consistency=delegated",
|
||||
"workspaceFolder": "/workspaces/test_hassio/addons/local/myaddon",
|
||||
"mounts": [
|
||||
// Cache docker images between devcontainer rebuilds (and share between devcontainers)
|
||||
"source=vsc-hassio-docker,target=/var/lib/docker,type=volume"
|
||||
]
|
||||
|
||||
// Post-create command to initialize the workspace. For example, for a node.js add-on you may want:
|
||||
// "postCreateCommand": "cd /workspaces/test_hassio/addons/local/myaddon && npm install",
|
||||
// "extensions": [
|
||||
// "dbaeumer.vscode-eslint",
|
||||
// "maty.vscode-mocha-sidebar"
|
||||
// ]
|
||||
"name": "HA Addon: TeslaMate",
|
||||
"image": "ghcr.io/home-assistant/devcontainer:addons",
|
||||
"appPort": ["7123:8123", "7357:4357"],
|
||||
"postStartCommand": "sudo sed -i 's/export SUPERVISOR_VERSION=.*/export SUPERVISOR_VERSION=2024.03.1.dev1803/' /etc/supervisor_scripts/common && bash devcontainer_bootstrap", // Workaround until https://github.com/home-assistant/supervisor/issues/5021 is fixed"
|
||||
"runArgs": ["-e", "GIT_EDITOR=code --wait", "--privileged"],
|
||||
"containerEnv": {
|
||||
"WORKSPACE_DIRECTORY": "${containerWorkspaceFolder}"
|
||||
},
|
||||
"customizations": {
|
||||
"vscode": {
|
||||
"extensions": [
|
||||
"timonwong.shellcheck",
|
||||
"esbenp.prettier-vscode"
|
||||
],
|
||||
"settings": {
|
||||
"terminal.integrated.profiles.linux": {
|
||||
"zsh": {
|
||||
"path": "/usr/bin/zsh"
|
||||
}
|
||||
},
|
||||
"terminal.integrated.defaultProfile.linux": "zsh",
|
||||
"editor.formatOnPaste": false,
|
||||
"editor.formatOnSave": true,
|
||||
"editor.formatOnType": true,
|
||||
"files.trimTrailingWhitespace": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"mounts": ["type=volume,target=/var/lib/docker"]
|
||||
}
|
||||
|
||||
@@ -1,103 +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 install() {
|
||||
docker pull homeassistant/amd64-hassio-supervisor:dev
|
||||
docker pull homeassistant/amd64-hassio-cli:dev
|
||||
}
|
||||
|
||||
function cleanup_hass_data() {
|
||||
rm -rf /workspaces/test_hassio/{apparmor,backup,config.json,dns,dns.json,homeassistant,homeassistant.json,ingress.json,share,ssl,tmp,updater.json}
|
||||
rm -rf /workspaces/test_hassio/addons/{core,data,git}
|
||||
}
|
||||
|
||||
function cleanup_docker() {
|
||||
echo "Cleaning up stopped containers..."
|
||||
docker rm $(docker ps -a -q)
|
||||
}
|
||||
|
||||
function run_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_hassio":/data \
|
||||
-v /etc/machine-id:/etc/machine-id:ro \
|
||||
-e SUPERVISOR_SHARE="/workspaces/test_hassio" \
|
||||
-e SUPERVISOR_NAME=hassio_supervisor \
|
||||
-e SUPERVISOR_DEV=1 \
|
||||
-e HOMEASSISTANT_REPOSITORY="homeassistant/qemux86-64-homeassistant" \
|
||||
homeassistant/amd64-hassio-supervisor:dev
|
||||
}
|
||||
|
||||
case "$1" in
|
||||
"--cleanup")
|
||||
echo "Cleaning up old environment"
|
||||
cleanup_docker || true
|
||||
cleanup_hass_data || true
|
||||
exit 0;;
|
||||
*)
|
||||
echo "Creating development Home Assistant environment"
|
||||
start_docker
|
||||
trap "stop_docker" ERR
|
||||
install
|
||||
cleanup_docker || true
|
||||
run_supervisor
|
||||
stop_docker;;
|
||||
esac
|
||||
Reference in New Issue
Block a user