mirror of
https://github.com/hassio-addons/addon-debian-base.git
synced 2025-05-07 04:31:30 +00:00
✨ Adds version requirements checks for HA and Supervisor
This commit is contained in:
parent
28e7b081c4
commit
95113cd6d1
2 changed files with 51 additions and 0 deletions
|
@ -32,6 +32,13 @@ RUN \
|
|||
&& curl -L -s "https://github.com/just-containers/s6-overlay/releases/download/v1.20.0.0/s6-overlay-${S6_ARCH}.tar.gz" \
|
||||
| tar zxvf - -C / \
|
||||
\
|
||||
&& if [ "${BUILD_ARCH}" = "i386" ]; then SEMVER_ARCH="386"; \
|
||||
elif [ "${BUILD_ARCH}" = "aarch64" ] || [ "${BUILD_ARCH}" = "armhf" ]; then SEMVER_ARCH="arm"; \
|
||||
else SEMVER_ARCH="${BUILD_ARCH}"; fi \
|
||||
\
|
||||
&& curl -L -s "https://github.com/frenck/semver/releases/download/v0.1.0/semver_linux_${SEMVER_ARCH}.tar.gz" \
|
||||
| tar zxvf - -C /usr/bin/ \
|
||||
\
|
||||
&& mkdir -p /etc/fix-attrs.d \
|
||||
\
|
||||
&& \
|
||||
|
|
44
base/rootfs/etc/cont-init.d/03-version-requirements.sh
Normal file
44
base/rootfs/etc/cont-init.d/03-version-requirements.sh
Normal file
|
@ -0,0 +1,44 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Base Images
|
||||
# Checks version requirements for this add-on
|
||||
# ==============================================================================
|
||||
# shellcheck source=base/rootfs/usr/lib/hassio-addons/base.sh
|
||||
source /usr/lib/hassio-addons/base.sh
|
||||
|
||||
declare version
|
||||
|
||||
if hass.api.supervisor.ping; then
|
||||
|
||||
if [[ ! -z "${SUPERVISOR_VERSION:-}" ]]; then
|
||||
version=$(hass.api.supervisor.info.version)
|
||||
hass.log.debug "Current Supervisor version: ${version}"
|
||||
hass.log.debug "Supervisor version condition: ${SUPERVISOR_VERSION}"
|
||||
|
||||
if ! semver -q "${SUPERVISOR_VERSION}" "${version}"; then
|
||||
hass.log.info "Supervisor version requirements checks passed."
|
||||
else
|
||||
hass.log.fatal "You Supervisor version is: ${version}"
|
||||
hass.log.fatal "This add-on requires: ${SUPERVISOR_VERSION}"
|
||||
hass.die 'Please consider upgrading.'
|
||||
fi
|
||||
fi
|
||||
|
||||
if [[ ! -z "${HOME_ASSISTANT_VERSION:-}" ]]; then
|
||||
version=$(hass.api.homeassistant.info.version)
|
||||
hass.log.debug "Current Home Assistant version: ${version}"
|
||||
hass.log.debug "Home Assistant version condition: ${HOME_ASSISTANT_VERSION}"
|
||||
|
||||
if ! semver -q "${HOME_ASSISTANT_VERSION}" "${version}"; then
|
||||
hass.log.info "Home Assistant version requirements checks passed."
|
||||
else
|
||||
hass.log.fatal "You Home Assistant version is: ${version}"
|
||||
hass.log.fatal "This add-on requires: ${HOME_ASSISTANT_VERSION}"
|
||||
hass.die 'Please consider upgrading.'
|
||||
fi
|
||||
fi
|
||||
|
||||
else
|
||||
hass.log.warning 'Could not check version requirements!'
|
||||
hass.log.warning 'Continue startup process... (might fail)'
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue