diff --git a/CT-Build/Alpine.yaml b/CT-Build/Alpine.yaml index d79edaf..4d12eac 100644 --- a/CT-Build/Alpine.yaml +++ b/CT-Build/Alpine.yaml @@ -331,6 +331,13 @@ files: variants: - mqtt +#FileForMqtt +- path: /opt/Setup + generator: copy + source: CT-Files/hass + variants: + - hass + packages: manager: apk update: true @@ -459,6 +466,29 @@ packages: variants: - mqtt +#PKGS for Hass + - packages: + - git + - python3 + - py3-virtualenv + - py3-pip + - python3-dev + - ca-certificates + - libffi-dev + - libressl-dev + - nmap + - iputils + - build-base + - tzdata + - sudo + - jpeg-dev + - zlib-dev + - bash + - mariadb-connector-c-dev + action: install + variants: + - hass + repositories: - name: /etc/apk/repositories url: |- @@ -529,6 +559,7 @@ actions: - nodered - nextcloud - mqtt + - hass # Enable service for iscsi CT - trigger: post-files diff --git a/CT-Files/hass/Configs/hass.service b/CT-Files/hass/Configs/hass.service new file mode 100644 index 0000000..514775b --- /dev/null +++ b/CT-Files/hass/Configs/hass.service @@ -0,0 +1,31 @@ +#!/sbin/openrc-run +CONFIG_DIR=/opt/HomeAssistant/data/ +USER=hass +GROUP=hass +PIDFILE=/var/run/homeassistant/homeassistant.pid + +CMD="/opt/HomeAssistant/srv/bin/hass" +ARGS="-c ${CONFIG_DIR} --pid-file ${PIDFILE}" + +depend() { + use dns +} + +start() { + mkdir -p /var/log/homeassistant + chown -R ${USER}.${GROUP} /var/log/homeassistant + mkdir -p /var/run/homeassistant + chown -R ${USER}.${GROUP} /var/run/homeassistant + ebegin "Starting ${SVCNAME}" + start-stop-daemon --pidfile $PIDFILE -u $USER -g $GROUP -b \ + -1 /var/log/homeassistant/homeassistant.log \ + -2 /var/log/homeassistant/homeassistant.log \ + -x $CMD -- $ARGS + eend $? +} + +stop() { + ebegin "Stopping ${SVCNAME}" + start-stop-daemon --pidfile $PIDFILE -u $USER -g $GROUP -x $CMD -K -q + eend $? +} diff --git a/CT-Files/hass/Scripts/Init.sh b/CT-Files/hass/Scripts/Init.sh new file mode 100644 index 0000000..24c3386 --- /dev/null +++ b/CT-Files/hass/Scripts/Init.sh @@ -0,0 +1,25 @@ +#!/bin/ash +#Install HomeAssistant +mkdir -p /opt/HomeAssistant/srv +mkdir -p /opt/HomeAssistant/data +touch /opt/HomeAssistant/data/home-assistant.log +addgroup hass +adduser -h /opt/HomeAssistant/data -D -G hass -s /bin/sh hass +chown -R hass:hass /opt/HomeAssistant +sudo -u hass python3 -m venv /opt/HomeAssistant/srv +sudo -u hass sh -c '. /opt/HomeAssistant/srv/bin/activate && pip install --upgrade pip && pip3 install wheel mysqlclient && pip3 install homeassistant' + +#Install Home Assistant Community Store +sudo -u hass sh -c 'cd /opt/HomeAssistant/data && wget -O - https://get.hacs.xyz | bash -' + +#Update script +mv /opt/Setup/Scripts/UpdateHASS.sh /opt/UpdateHASS.sh + +#CleanUp +rm -rf /opt/HomeAssistant/data/.cache/* +rm -rf /build/TMP/usr/lib/python3.9/__pycache__/* + +#Setup HomeAssistant service +mv /opt/Setup/Configs/hass.service /etc/init.d/hass +chmod +x /etc/init.d/hass +rc-update add hass diff --git a/CT-Files/hass/Scripts/UpdateHASS.sh b/CT-Files/hass/Scripts/UpdateHASS.sh new file mode 100644 index 0000000..ad0ac5c --- /dev/null +++ b/CT-Files/hass/Scripts/UpdateHASS.sh @@ -0,0 +1,4 @@ +#!/bin/ash +service hass stop +sudo -u hass sh -c '. /opt/HomeAssistant/srv/bin/activate && pip install --upgrade pip && pip3 install --upgrade homeassistant' +service hass start \ No newline at end of file diff --git a/Readme.md b/Readme.md index ea139bd..be5b043 100644 --- a/Readme.md +++ b/Readme.md @@ -39,12 +39,13 @@ This can be done on a Minimal debian CT (make sure to enable nesting) on the new | nodered | Alpine | Node-Red | | nodejs | Alpine | Basic nodejs install with pm2 | | mqtt | Alpine | Mosquitto mqtt broker | +| hass | Alpine | HomeAssistant instance with HACS and mysql support | ## TODO **Begin original list** -Hass -Mqtt + + @@ -177,10 +178,15 @@ lxc.mount.entry: /dev/ttyACM-Zwave dev/ttyACM-Zwave none bind,optional,create=fi ## tvheadend **Do first login and setup wizzard in a incognito/Private window, since the authentication system can get confused after setting the new username** -* Tvheadend avalible on http://``:9981 +* Tvheadend avalible on http://``:9981 * Default credentials: setup/setup * Follow the setup wizzard after login, otherwise authentication will be disabled +## hass +* After first start of CT HomeAssistant will finish its instalation this wil take at least 10 minutes +* HomeAssistantavalible on http://``:8123 + + # Further CT documentation ## iscsi