diff --git a/music-assistant/kustomization.yaml b/music-assistant/kustomization.yaml index 9ce2daf..f579ba0 100644 --- a/music-assistant/kustomization.yaml +++ b/music-assistant/kustomization.yaml @@ -16,6 +16,25 @@ resources: - music-assistant.yaml - ingress.yaml +patches: +- patch: | + apiVersion: apps/v1 + kind: StatefulSet + metadata: + name: music-assistant + spec: + template: + spec: + containers: + - name: music-assistant + lifecycle: + postStart: + exec: + command: + - wget + - -qO- + - http://ntfy.ntfy:2586/0e386416-ac43-488c-b709-efac8e2555a3/publish?message=restart + images: - name: ghcr.io/music-assistant/server newTag: 2.6.0b18 diff --git a/music-assistant/restart-sync.service b/music-assistant/restart-sync.service new file mode 100644 index 0000000..025e8c8 --- /dev/null +++ b/music-assistant/restart-sync.service @@ -0,0 +1,22 @@ +# vim: set ft=systemd : + +# In order for this to be effective, `shairport-sync.service` needs a +# configuration override to enable auto-restart, e.g.: +# +# [Service] +# Restart=always +# RestartSec=1 + +[Unit] +Description=Restart shairport-sync when music-assistant restarts +Wants=network-online.target +After=network-online.target + +[Service] +Type=simple +ExecStart=/usr/local/libexec/restart-sync.sh +Restart=always +RestartSec=1 + +[Install] +WantedBy=shairport-sync.service diff --git a/music-assistant/restart-sync.sh b/music-assistant/restart-sync.sh new file mode 100644 index 0000000..a1d7e96 --- /dev/null +++ b/music-assistant/restart-sync.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +TOPIC=0e386416-ac43-488c-b709-efac8e2555a3 +NTFY=https://ntfy.pyrocufflink.net +DELAY=10 + +url=$(printf '%s/%s/raw' "${NTFY}" "${TOPIC}") + +curl -sN "${url}" \ + | stdbuf -o0 grep restart \ + | while read l; do +printf 'Restarting shairport-sync in %d seconds\n' "$DELAY" >&2 +sleep $DELAY +busctl call org.gnome.ShairportSync /org/gnome/ShairportSync org.gnome.ShairportSync Quit +done