From 467befcec40ccb7111d17e4d1ef17ab0df322049 Mon Sep 17 00:00:00 2001 From: Stefan Agner Date: Wed, 5 Mar 2025 06:08:30 +0100 Subject: [PATCH] Use /var/lib/homeassistant as Supervisor data directory (#397) * Use /var/lib/homeassistant as Supervisor data directory Instead of using /usr/share/hassio use /var/lib/homeassistant as Supervisor data directory. While the Supervisor data directory is a mixed bag of user and somewhat static files, /var/lib seems the better fit than /usr/local. Fixes: #393 * Handle upgrade correctly --- README.md | 2 +- homeassistant-supervised/DEBIAN/postinst | 10 +++++++++- homeassistant-supervised/usr/sbin/hassio-apparmor | 2 +- homeassistant-supervised/usr/sbin/hassio-supervisor | 4 ++-- 4 files changed, 13 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index 755c9ab..5baf02e 100644 --- a/README.md +++ b/README.md @@ -92,7 +92,7 @@ apt install ./homeassistant-supervised.deb ## Configuration -The default path for our `$DATA_SHARE` is `/usr/share/hassio`. +The default path for our `$DATA_SHARE` is `/var/lib/homeassistant` (used to be `/usr/share/hassio`). This path is used to store all home assistant related things. You can reconfigure this path during installation with diff --git a/homeassistant-supervised/DEBIAN/postinst b/homeassistant-supervised/DEBIAN/postinst index bacdc79..387c9dd 100755 --- a/homeassistant-supervised/DEBIAN/postinst +++ b/homeassistant-supervised/DEBIAN/postinst @@ -118,10 +118,18 @@ case ${ARCH} in error "${ARCH} unknown!" ;; esac + PREFIX=${PREFIX:-/usr} SYSCONFDIR=${SYSCONFDIR:-/etc} -DATA_SHARE=${DATA_SHARE:-$PREFIX/share/hassio} +DEFAULT_DATA_SHARE=/var/lib/homeassistant +DATA_SHARE=${DATA_SHARE:-$DEFAULT_DATA_SHARE} CONFIG="${SYSCONFDIR}/hassio.json" + +if [ -f "${CONFIG}" ]; then + # Using data share of existing configuration + DATA_SHARE=$(jq -r --arg default "$DEFAULT_DATA_SHARE" '.data // $default' "$CONFIG") +fi + cat > "${CONFIG}" <<- EOF { "supervisor": "${HASSIO_DOCKER}", diff --git a/homeassistant-supervised/usr/sbin/hassio-apparmor b/homeassistant-supervised/usr/sbin/hassio-apparmor index 8f62c51..a37d83d 100644 --- a/homeassistant-supervised/usr/sbin/hassio-apparmor +++ b/homeassistant-supervised/usr/sbin/hassio-apparmor @@ -5,7 +5,7 @@ set -e CONFIG_FILE=%%HASSIO_CONFIG%% # Read configs -DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})" +DATA="$(jq --raw-output '.data // "/var/lib/homeassistant"' ${CONFIG_FILE})" PROFILES_DIR="${DATA}/apparmor" CACHE_DIR="${PROFILES_DIR}/cache" diff --git a/homeassistant-supervised/usr/sbin/hassio-supervisor b/homeassistant-supervised/usr/sbin/hassio-supervisor index 24c1b36..2c10c5a 100644 --- a/homeassistant-supervised/usr/sbin/hassio-supervisor +++ b/homeassistant-supervised/usr/sbin/hassio-supervisor @@ -9,7 +9,7 @@ set -e CONFIG_FILE=%%HASSIO_CONFIG%% # Init supervisor -SUPERVISOR_DATA="$(jq --raw-output '.data // "/usr/share/hassio"' ${CONFIG_FILE})" +SUPERVISOR_DATA="$(jq --raw-output '.data // "/var/lib/homeassistant"' ${CONFIG_FILE})" SUPERVISOR_STARTUP_MARKER="/run/supervisor/startup-marker" SUPERVISOR_STARTSCRIPT_VERSION="${SUPERVISOR_DATA}/supervisor-version" SUPERVISOR_MACHINE="$(jq --raw-output '.machine' ${CONFIG_FILE})" @@ -110,4 +110,4 @@ fi mkdir -p ${SUPERVISOR_DATA} echo "[INFO] Starting the Supervisor..." docker container start hassio_supervisor -exec docker container wait hassio_supervisor \ No newline at end of file +exec docker container wait hassio_supervisor