Skip to content

Commit

Permalink
Run post-install steps on post-upgrade
Browse files Browse the repository at this point in the history
  • Loading branch information
kuba2k2 committed Apr 30, 2024
1 parent d43d741 commit 173b7bd
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 10 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

This guide, along with a few small software packages, allows to install Home Assistant Supervised on a host machine running Alpine Linux. Note that this is not a supported HA installation method, so YMMV. Personally, it works just fine on my ARMv7 machine.

Since July 2023, there are prebuilt APK packages available in this repo (for `x86`, `x86_64`, `armhf` and `armv7`). The README below has been updated to reflect that. They are signed with the following public key:
Since July 2023, there are prebuilt APK packages available in this repo (for `x86`, `x86_64`, `armhf`, `armv7` and `aarch64`). The README below has been updated to reflect that. They are signed with the following public key:

<details>
<summary>Click to show public key</summary>
Expand All @@ -27,6 +27,8 @@ FN0IX6Z7106y3qPUktG2f+cCAwEAAQ==

Building from source is also possible; the original guide is at the end of this document.

**Note:** in April 2024 the `MACHINE` variable in `/etc/hassio.json` created by this package was changed to reflect the correct system architecture. Upgrading to `hassio-supervised` v1.7.0 or newer will automatically rewrite that file.

## Prerequisites

All steps of this guide (unless otherwise noted) are to be ran by a **non-root, sudo-enabled** user.
Expand Down Expand Up @@ -110,6 +112,8 @@ sudo apk add hassio-supervised-nm
sudo apk add hassio-supervised
```

**Home Assistant will automatically be started** and added as an autostart service in OpenRC.

See Docker containers starting up:

```bash
Expand Down
2 changes: 1 addition & 1 deletion hassio-supervised/APKBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Maintainer:
pkgname=hassio-supervised
pkgver=1.7.0
pkgrel=0
pkgrel=1
pkgdesc="Home Assistant Supervised"
url="https://github.com/home-assistant/supervised-installer"
arch="noarch"
Expand Down
3 changes: 0 additions & 3 deletions hassio-supervised/hassio-supervised.post-install
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,6 @@ URL_VERSION="https://version.home-assistant.io/stable.json"
HASSIO_VERSION=$(curl -s ${URL_VERSION} | jq -e -r '.supervisor')
URL_APPARMOR_PROFILE="https://version.home-assistant.io/apparmor.txt"

# Restart Docker service
service docker restart

# Check network connection
while ! ping -c 1 -W 1 ${URL_CHECK_ONLINE} > /dev/null; do
info "Waiting for ${URL_CHECK_ONLINE} - network interface might be down..."
Expand Down
42 changes: 37 additions & 5 deletions hassio-supervised/hassio-supervised.post-upgrade
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,18 @@ ARCH=$(uname -m)

DOCKER_REPO="ghcr.io/home-assistant"

# Read infos from web
URL_CHECK_ONLINE="checkonline.home-assistant.io"
URL_VERSION="https://version.home-assistant.io/stable.json"
HASSIO_VERSION=$(curl -s ${URL_VERSION} | jq -e -r '.supervisor')
URL_APPARMOR_PROFILE="https://version.home-assistant.io/apparmor.txt"

# Check network connection
while ! ping -c 1 -W 1 ${URL_CHECK_ONLINE} > /dev/null; do
info "Waiting for ${URL_CHECK_ONLINE} - network interface might be down..."
sleep 2
done

case ${ARCH} in
"i386" | "i686")
MACHINE=${MACHINE:=i386}
Expand Down Expand Up @@ -40,6 +52,8 @@ SYSCONFDIR=${SYSCONFDIR:-/etc}
DATA_SHARE=${DATA_SHARE:-$PREFIX/share/hassio}
CONFIG="${SYSCONFDIR}/hassio.json"

mkdir -p ${DATA_SHARE}/apparmor

cat > "${CONFIG}" <<- EOF
{
"supervisor": "${HASSIO_DOCKER}",
Expand All @@ -48,8 +62,26 @@ cat > "${CONFIG}" <<- EOF
}
EOF

# If the hassio_supervisor service is running, restart it
if service hassio-supervisor status > /dev/null; then
info "Restarting hassio_supervisor service"
service hassio-supervisor restart
fi
# Install Supervisor
sed -i "s,%%HASSIO_CONFIG%%,${CONFIG},g" "${PREFIX}/sbin/hassio-supervisor"

rc-update add hassio-supervisor

# Install AppArmor
curl -sL ${URL_APPARMOR_PROFILE} > "${DATA_SHARE}/apparmor/hassio-supervisor"
sed -i "s,%%HASSIO_CONFIG%%,${CONFIG},g" "${PREFIX}/sbin/hassio-apparmor"

rc-update add hassio-apparmor
service hassio-apparmor start

# Start Supervisor
service hassio-supervisor start

# Get primary network interface
PRIMARY_INTERFACE=$(ip route | awk '/^default/ { print $5; exit }')
IP_ADDRESS=$(ip -4 addr show dev "${PRIMARY_INTERFACE}" | awk '/inet / { sub("/.*", "", $2); print $2 }')
HOSTNAME=$(hostname)

info "Within a few minutes you will be able to reach Home Assistant at:"
info "http://${HOSTNAME}.local:8123 or using the IP address of your"
info "machine: http://${IP_ADDRESS}:8123"

0 comments on commit 173b7bd

Please sign in to comment.