Add Hass.io add-on (#408)

This commit is contained in:
andig 2020-11-08 13:25:20 +01:00 • committed by GitHub
parent 7d638c655c
commit d8e894045c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 26 additions and 7 deletions

3
.gitignore vendored
View file

@ -8,8 +8,7 @@ __debug_bin
evcc
linux-*.Dockerfile
!evcc.dist.yaml
!modules/**
dist
*.py
node_modules
server/assets.go
server/assets.go

View file

@ -7,7 +7,7 @@ FROM golang:1.14-alpine as builder
# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates is required to call HTTPS endpoints.
RUN apk update && apk add --no-cache git ca-certificates tzdata alpine-sdk npm && update-ca-certificates
RUN apk update && apk add --no-cache git jq ca-certificates tzdata alpine-sdk npm && update-ca-certificates
WORKDIR /build
@ -34,6 +34,8 @@ ENV TZ=Europe/Berlin
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /build/evcc /usr/local/bin/evcc
COPY --from=builder /usr/bin/jq /usr/bin/
COPY --from=builder /usr/lib/libjq.so.1* /usr/lib/
COPY docker/bin/* /evcc/

View file

@ -1,8 +1,24 @@
#!/bin/sh
set -e
if [ "$1" == '"evcc"' ] || expr "$1" : '-*' > /dev/null; then
exec evcc "$@"
# started as hassio addon
HASSIO_OPTIONSFILE=/data/options.json
if [ -f ${HASSIO_OPTIONSFILE} ]; then
CONFIG=$(jq -r .config_file ${HASSIO_OPTIONSFILE})
echo "Using config file: ${CONFIG}"
if [ ! -f ${CONFIG} ]; then
echo "Config not found. Please create a config under ${CONFIG}."
echo "For details see evcc documentation at https://github.com/andig/evcc#readme."
else
echo "starting evcc: 'evcc --config ${CONFIG}'"
exec evcc --config ${CONFIG}
fi
else
exec "$@"
if [ "$1" == '"evcc"' ] || expr "$1" : '-*' > /dev/null; then
exec evcc "$@"
else
exec "$@"
fi
fi

View file

@ -6,7 +6,7 @@ FROM golang:1.14-alpine as builder
# Install git + SSL ca certificates.
# Git is required for fetching the dependencies.
# Ca-certificates is required to call HTTPS endpoints.
RUN apk update && apk add --no-cache git ca-certificates tzdata alpine-sdk npm && update-ca-certificates
RUN apk update && apk add --no-cache git jq ca-certificates tzdata alpine-sdk npm && update-ca-certificates
WORKDIR /build
@ -30,6 +30,8 @@ ENV TZ=Europe/Berlin
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /build/evcc /usr/local/bin/evcc
COPY --from=builder /usr/bin/jq /usr/bin/
COPY --from=builder /usr/lib/libjq.so.1* /usr/lib/
COPY docker/bin/* /evcc/