summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authors-ol <s+removethis@s-ol.nu>2022-05-13 08:07:30 +0000
committers-ol <s+removethis@s-ol.nu>2022-05-13 08:07:30 +0000
commit4cc5d90debae95114945c6c32f31888beca4b3f8 (patch)
tree1c5985ce344965054a72944ed90c322b9e7cc3e9
downloadhassio-addons-main.tar.gz
hassio-addons-main.zip
initial commitmain
-rw-r--r--repository.yaml3
-rw-r--r--snapserver/Dockerfile24
-rw-r--r--snapserver/config.json57
-rw-r--r--snapserver/icon.pngbin0 -> 12090 bytes
-rw-r--r--snapserver/logo.pngbin0 -> 7817 bytes
-rw-r--r--snapserver/run.sh44
6 files changed, 128 insertions, 0 deletions
diff --git a/repository.yaml b/repository.yaml
new file mode 100644
index 0000000..cef17f7
--- /dev/null
+++ b/repository.yaml
@@ -0,0 +1,3 @@
+name: "s-ol's Addons"
+url: https://git.s-ol.nu/hassio-addons/
+maintainer: s-ol bekic
diff --git a/snapserver/Dockerfile b/snapserver/Dockerfile
new file mode 100644
index 0000000..29d93fd
--- /dev/null
+++ b/snapserver/Dockerfile
@@ -0,0 +1,24 @@
+ARG BUILD_FROM
+FROM $BUILD_FROM
+
+# Add env
+ENV LANG C.UTF-8
+
+# Install snapcast and librespot
+RUN apk -U add bash build-base curl cargo portaudio-dev protobuf-dev \
+ && cd /root \
+ && curl -LO https://github.com/librespot-org/librespot/archive/refs/tags/v0.3.1.zip \
+ && unzip v0.3.1.zip \
+ && cd librespot-0.3.1 \
+ && cargo build --jobs $(grep -c ^processor /proc/cpuinfo) --release --no-default-features \
+ && mv target/release/librespot /usr/local/bin \
+ && cd / \
+ && apk --purge del curl cargo portaudio-dev protobuf-dev \
+ && apk add llvm-libunwind snapcast-server \
+ && rm -rf /etc/ssl /var/cache/apk/* /lib/apk/db/* /root/v0.1.3.zip /root/librespot-0.3.1 /root/.ca
+
+# Copy data for add-on
+COPY run.sh /
+RUN chmod a+x /run.sh
+
+CMD [ "/run.sh" ]
diff --git a/snapserver/config.json b/snapserver/config.json
new file mode 100644
index 0000000..4c931f9
--- /dev/null
+++ b/snapserver/config.json
@@ -0,0 +1,57 @@
+{
+ "name": "snapcast-server",
+ "version": "0.25",
+ "slug": "snapcastserver",
+ "description": "Snapcast Server (with librespot)",
+ "startup": "system",
+ "boot": "auto",
+ "map": ["share:rw"],
+ "options": {
+ "stream": {
+ "streams": ["pipe:///share/snapfifo/librespot?name=SpotifyConnect&sampleformat=44100:16:2", "pipe:///share/snapfifo/mopidy?name=Mopidy&sampleformat=44100:16:2", "tcp://0.0.0.0?port=4953&name=snapbroadcast"],
+ "buffer": "1000",
+ "codec": "flac",
+ "send_to_muted": "false",
+ "sampleformat": "48000:16:2"
+ },
+ "http": {
+ "enabled": "true",
+ "doc_root": " "
+ },
+ "tcp": {
+ "enabled": "true"
+ },
+ "logging": {
+ "enabled": "true"
+ },
+ "server": {
+ "threads": "-1",
+ "datadir": "/share/snapcast/"
+ }
+ },
+ "schema": {
+ "stream": {
+ "streams": ["str"],
+ "buffer": "int",
+ "codec": "str",
+ "send_to_muted": "str",
+ "sampleformat": "str"
+ },
+ "http": {
+ "enabled": "str",
+ "doc_root": "str"
+ },
+ "tcp": {
+ "enabled": "str"
+ },
+ "logging": {
+ "enabled": "str"
+ },
+ "server": {
+ "threads": "int",
+ "datadir": "str"
+ }
+ },
+ "ports": {"1704/tcp": 1704, "1705/tcp": 1705, "1780/tcp": 1780, "4953/tcp": 4953},
+ "arch": ["armhf", "armv7", "aarch64", "amd64", "i386"]
+ }
diff --git a/snapserver/icon.png b/snapserver/icon.png
new file mode 100644
index 0000000..5f6635a
--- /dev/null
+++ b/snapserver/icon.png
Binary files differ
diff --git a/snapserver/logo.png b/snapserver/logo.png
new file mode 100644
index 0000000..4139486
--- /dev/null
+++ b/snapserver/logo.png
Binary files differ
diff --git a/snapserver/run.sh b/snapserver/run.sh
new file mode 100644
index 0000000..e85e3d6
--- /dev/null
+++ b/snapserver/run.sh
@@ -0,0 +1,44 @@
+
+#!/usr/bin/env bashio
+
+mkdir -p /share/snapfifo
+mkdir -p /share/snapcast
+
+config=/etc/snapserver.conf
+
+if ! bashio::fs.file_exists '/etc/snapserver.conf'; then
+ touch /etc/snapserver.conf ||
+ bashio::exit.nok "Could not create snapserver.conf file on filesystem"
+fi
+bashio::log.info "Populating snapserver.conf..."
+
+# Start creation of configuration
+
+echo "[stream]" > "${config}"
+for stream in $(bashio::config 'stream.streams'); do
+ echo "stream = ${stream}" >> "${config}"
+done
+echo "buffer = $(bashio::config 'stream.buffer')" >> "${config}"
+echo "codec = $(bashio::config 'stream.codec')" >> "${config}"
+echo "send_to_muted = $(bashio::config 'stream.send_to_muted')" >> "${config}"
+echo "sampleformat = $(bashio::config 'stream.sampleformat')" >> "${config}"
+
+echo "[http]" >> "${config}"
+echo "enabled = $(bashio::config 'http.enabled')" >> "${config}"
+echo "doc_root = $(bashio::config 'http.docroot')" >> "${config}"
+
+echo "[tcp]" >> "${config}"
+echo "enabled = $(bashio::config 'tcp.enabled')" >> "${config}"
+
+echo "[logging]" >> "${config}"
+echo "debug = $(bashio::config 'logging.enabled')" >> "${config}"
+
+echo "[server]" >> "${config}"
+echo "threads = $(bashio::config 'server.threads')" >> "${config}"
+
+echo "[server]" >> "${config}"
+echo "datadir = $(bashio::config 'server.datadir')" >> "${config}"
+
+bashio::log.info "Starting SnapServer..."
+
+/usr/bin/snapserver -c /etc/snapserver.conf