Skip to content

Commit

Permalink
⚓ Add env ALWAYS_UPGRADE
Browse files Browse the repository at this point in the history
  • Loading branch information
al-one committed Dec 20, 2024
1 parent 216f510 commit ae4ca5a
Show file tree
Hide file tree
Showing 5 changed files with 75 additions and 29 deletions.
15 changes: 5 additions & 10 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,20 +1,15 @@
ARG VERSION
ARG VERSION=latest
FROM homeassistant/home-assistant:${VERSION}

ENV ALWAYS_INSTALL=true
ENV ALWAYS_UPGRADE=false

COPY hacs /etc/services.d/hacs
COPY rootfs/ /

RUN \
chmod a+x /etc/services.d/hacs/run && \
chmod a+x /install.sh && \
mkdir /hacs && cd /hacs && \
touch home-assistant.log && \
wget https://hacs.vip/get && \
DOMAIN=hacs bash get && \
DOMAIN=xiaomi_miot bash get && \
DOMAIN=xiaomi_home bash get && \
DOMAIN=xiaomi_gateway3 bash get && \
DOMAIN=tianqi bash get && \
DOMAIN=ha_file_explorer bash get && \
DOMAIN=ai_conversation bash get && \
/install.sh && \
cd /config
17 changes: 17 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
services:
homeassistant:
container_name: homeassistant
image: hacn/hacn:stable
build:
context: .
volumes:
- /PATH_TO_YOUR_CONFIG:/config
- /etc/localtime:/etc/localtime:ro
- /run/dbus:/run/dbus:ro
environment:
- TZ=Asia/Shanghai
- ALWAYS_INSTALL=true # 默认为true,每次启动都会逐个预装,否则仅全新HA才会预装
- ALWAYS_UPGRADE=false # 默认为false,每次启动都会逐个预装最新版本的插件
restart: unless-stopped
privileged: true
network_mode: host
19 changes: 0 additions & 19 deletions hacs/run

This file was deleted.

33 changes: 33 additions & 0 deletions rootfs/etc/services.d/hacs/run
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/with-contenv bashio

hacs_components=/hacs/custom_components

cd /config

bashio::log.info "always_upgrade=$ALWAYS_UPGRADE"
if [ "$ALWAYS_UPGRADE" = "true" ]; then
/install.sh
ALWAYS_INSTALL=false
fi

[ ! -d custom_components ] && cp -rf $hacs_components ./ && bashio::log.info "Copied custom_components to config"

bashio::log.info "always_install=$ALWAYS_INSTALL"
if [ "$ALWAYS_INSTALL" = "true" ]; then
cd custom_components
[ ! -d hacs ] && cp -rf $hacs_components/hacs ./ && bashio::log.info "Copied hacs"
[ ! -d xiaomi_miot ] && cp -rf $hacs_components/xiaomi_miot ./ && bashio::log.info "Copied xiaomi_miot"
[ ! -d xiaomi_home ] && cp -rf $hacs_components/xiaomi_home ./ && bashio::log.info "Copied xiaomi_home"
[ ! -d xiaomi_gateway3 ] && cp -rf $hacs_components/xiaomi_gateway3 ./ && bashio::log.info "Copied xiaomi_gateway3"
[ ! -d sonoff ] && cp -rf $hacs_components/sonoff ./ && bashio::log.info "Copied sonoff"
[ ! -d tianqi ] && cp -rf $hacs_components/tianqi ./ && bashio::log.info "Copied tianqi"
[ ! -d edge_tts ] && cp -rf $hacs_components/edge_tts ./ && bashio::log.info "Copied edge_tts"
[ ! -d ha_file_explorer ] && cp -rf $hacs_components/ha_file_explorer ./ && bashio::log.info "Copied ha_file_explorer"
[ ! -d bemfa ] && cp -rf $hacs_components/bemfa ./ && bashio::log.info "Copied bemfa"
[ ! -d midea_ac_lan ] && cp -rf $hacs_components/midea_ac_lan ./ && bashio::log.info "Copied midea_ac_lan"
[ ! -d midea_ac ] && cp -rf $hacs_components/midea_ac ./ && bashio::log.info "Copied midea_ac"
[ ! -d ai_conversation ] && cp -rf $hacs_components/ai_conversation ./ && bashio::log.info "Copied ai_conversation"
cd ..
fi

sleep infinity
20 changes: 20 additions & 0 deletions rootfs/install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
#!/bin/bash

function info () { echo -e "\033[0;32m$1\033[0m"; }

wget https://hacs.vip/get

[ ! -d /config/custom_components/hacs ] && DOMAIN=hacs bash get && info "Installed hacs"
[ ! -d /config/custom_components/xiaomi_miot ] && DOMAIN=xiaomi_miot bash get && info "Installed xiaomi_miot"
[ ! -d /config/custom_components/xiaomi_home ] && DOMAIN=xiaomi_home bash get && info "Installed xiaomi_home"
[ ! -d /config/custom_components/xiaomi_gateway3 ] && DOMAIN=xiaomi_gateway3 bash get && info "Installed xiaomi_gateway3"
[ ! -d /config/custom_components/sonoff ] && DOMAIN=sonoff bash get && info "Installed sonoff"
[ ! -d /config/custom_components/tianqi ] && DOMAIN=tianqi bash get && info "Installed tianqi"
[ ! -d /config/custom_components/edge_tts ] && DOMAIN=edge_tts bash get && info "Installed edge_tts"
[ ! -d /config/custom_components/ha_file_explorer ] && DOMAIN=ha_file_explorer bash get && info "Installed ha_file_explorer"
[ ! -d /config/custom_components/ai_conversation ] && DOMAIN=ai_conversation bash get && info "Installed ai_conversation"
[ ! -d /config/custom_components/bemfa ] && DOMAIN=bemfa bash get && info "Installed bemfa"
[ ! -d /config/custom_components/midea_ac_lan ] && DOMAIN=midea_ac_lan bash get && info "Installed midea_ac_lan"
[ ! -d /config/custom_components/midea_ac ] && DOMAIN=midea_ac bash get && info "Installed midea_ac"

rm -rf ./get

0 comments on commit ae4ca5a

Please sign in to comment.