diff --git a/airsonos/Dockerfile b/airsonos/Dockerfile new file mode 100755 index 0000000..661f389 --- /dev/null +++ b/airsonos/Dockerfile @@ -0,0 +1,44 @@ +ARG BUILD_FROM=hassioaddons/debian-base-amd64:0.2.0 +FROM ${BUILD_FROM} + +# Setup base system +RUN \ + echo 'deb http://deb.debian.org/debian jessie main' >> /etc/apt/sources.list \ + \ + && apt-get update \ + \ + && apt-get install -y --no-install-recommends libssl1.0.0 \ + \ + && rm -f -r \ + /tmp/* \ + /var/lib/apt/lists/* + +# Copy root filesystem +COPY rootfs / + +# Add airsonos binary +ARG BUILD_ARCH +ADD bin/airsonos-${BUILD_ARCH} /usr/bin/airsonos + +# Build arugments +ARG BUILD_DATE +ARG BUILD_REF +ARG BUILD_VERSION + +# Labels +LABEL \ + io.hass.name="AirSonos" \ + io.hass.description="AirPlay capabilities for your Sonos (and UPnP) devices" \ + io.hass.arch="${BUILD_ARCH}" \ + io.hass.type="addon" \ + io.hass.version=${BUILD_VERSION} \ + maintainer="Franck Nijhof " \ + org.label-schema.description="AirPlay capabilities for your Sonos (and UPnP) devices" \ + org.label-schema.build-date=${BUILD_DATE} \ + org.label-schema.name="AirSonos" \ + org.label-schema.schema-version="1.0" \ + org.label-schema.url="https://community.home-assistant.io/t/community-hass-io-add-on-airsonos/36796?u=frenck" \ + org.label-schema.usage="https://github.com/hassio-addons/addon-airsonos/tree/master/README.md" \ + org.label-schema.vcs-ref=${BUILD_REF} \ + org.label-schema.vcs-url="https://github.com/hassio-addons/addon-airsonos" \ + org.label-schema.vendor="Community Hass.io Add-ons" diff --git a/airsonos/bin/airsonos-aarch64 b/airsonos/bin/airsonos-aarch64 new file mode 100755 index 0000000..87233cf Binary files /dev/null and b/airsonos/bin/airsonos-aarch64 differ diff --git a/airsonos/bin/airsonos-amd64 b/airsonos/bin/airsonos-amd64 new file mode 100755 index 0000000..1aa373b Binary files /dev/null and b/airsonos/bin/airsonos-amd64 differ diff --git a/airsonos/bin/airsonos-armhf b/airsonos/bin/airsonos-armhf new file mode 100755 index 0000000..87233cf Binary files /dev/null and b/airsonos/bin/airsonos-armhf differ diff --git a/airsonos/bin/airsonos-i386 b/airsonos/bin/airsonos-i386 new file mode 100755 index 0000000..23ade2f Binary files /dev/null and b/airsonos/bin/airsonos-i386 differ diff --git a/airsonos/build.json b/airsonos/build.json new file mode 100644 index 0000000..d715d55 --- /dev/null +++ b/airsonos/build.json @@ -0,0 +1,9 @@ +{ + "build_from": { + "aarch64": "hassioaddons/debian-base-aarch64:0.2.0", + "amd64": "hassioaddons/debian-base-amd64:0.2.0", + "armhf": "hassioaddons/debian-base-armhf:0.2.0", + "i386": "hassioaddons/debian-base-i386:0.2.0" + }, + "args": {} +} diff --git a/airsonos/config.json b/airsonos/config.json new file mode 100755 index 0000000..2d1367d --- /dev/null +++ b/airsonos/config.json @@ -0,0 +1,31 @@ +{ + "name": "AirSonos", + "version": "dev", + "slug": "airsonos", + "description": "AirPlay capabilities for your Sonos (and UPnP) devices.", + "url": "https://community.home-assistant.io/t/community-hass-io-add-on-airsonos/36796?u=frenck", + "startup": "services", + "boot": "auto", + "hassio_api": true, + "homeassistant_api": false, + "host_network": true, + "options": { + "log_level": "info", + "address": "", + "port": 49152, + "latency_rtp": 1000, + "latency_http": 2000, + "drift": false + }, + "schema": { + "log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)", + "address": "str", + "port": "port", + "latency_rtp": "int", + "latency_http": "int", + "drift": "bool" + }, + "environment": { + "LOG_FORMAT": "{LEVEL}: {MESSAGE}" + } +} diff --git a/airsonos/rootfs/etc/cont-init.d/50-airsonos.sh b/airsonos/rootfs/etc/cont-init.d/50-airsonos.sh new file mode 100644 index 0000000..b38c1c6 --- /dev/null +++ b/airsonos/rootfs/etc/cont-init.d/50-airsonos.sh @@ -0,0 +1,16 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Community Hass.io Add-ons: AirSonos +# Checks latency settings before starting the AirSonos server +# ============================================================================== +# shellcheck disable=SC1091 +source /usr/lib/hassio-addons/base.sh + +declare latency + +latency=$(hass.config.get 'latency_rtp') + +if [[ "${latency}" -lt 500 && "${latency}" -ne 0 ]]; then + hass.log.warning \ + 'Setting the RTP latency of AirPlay audio below 500ms is not recommended!' +fi diff --git a/airsonos/rootfs/etc/services.d/airsonos/finish b/airsonos/rootfs/etc/services.d/airsonos/finish new file mode 100644 index 0000000..d913214 --- /dev/null +++ b/airsonos/rootfs/etc/services.d/airsonos/finish @@ -0,0 +1,9 @@ +#!/usr/bin/execlineb -S0 +# ============================================================================== +# Community Hass.io Add-ons: AirSonos +# Take down the S6 supervision tree when the AirSonos server fails +# ============================================================================== +if -n { s6-test $# -ne 0 } +if -n { s6-test ${1} -eq 256 } + +s6-svscanctl -t /var/run/s6/services \ No newline at end of file diff --git a/airsonos/rootfs/etc/services.d/airsonos/run b/airsonos/rootfs/etc/services.d/airsonos/run new file mode 100644 index 0000000..f6f9c99 --- /dev/null +++ b/airsonos/rootfs/etc/services.d/airsonos/run @@ -0,0 +1,46 @@ +#!/usr/bin/with-contenv bash +# ============================================================================== +# Community Hass.io Add-ons: AirSonos +# Runs the AirSonos server +# ============================================================================== +# shellcheck disable=SC1091 +source /usr/lib/hassio-addons/base.sh + +declare -a options + +hass.log.info 'Starting the AirSonos server' + +# Bind to a specific interface +if hass.config.has_value 'address'; then + options+=(-b "$(hass.config.get 'address'):$(hass.config.get 'port')") +fi + +# Find the matching AirSonos log level +case "$(hass.string.lower "$(hass.config.get 'log_level')")" in + all|trace) + options+=(-d 'all=sdebug') + ;; + debug) + options+=(-d 'all=debug') + ;; + info|notice) + options+=(-d 'all=info') + ;; + warning) + options+=(-d 'all=warn') + ;; + error|fatal|off) + options+=(-d 'all=error') + ;; +esac + +# Set latency +options+=(-l "$(hass.config.get 'latency_rtp'):$(hass.config.get 'latency_http')") + +# Drift mode? +if hass.config.true 'drift'; then + options+=(-r) +fi + +# Run the AirSonos server +exec airsonos "${options[@]}"