mirror of
https://github.com/hassio-addons/addon-mopidy.git
synced 2025-05-03 19:11:39 +00:00
🎉 Initial add-on code
This commit is contained in:
parent
7449a68fbf
commit
7e088d7e7f
23 changed files with 881 additions and 0 deletions
15
.gitlab-ci.yml
Normal file
15
.gitlab-ci.yml
Normal file
|
@ -0,0 +1,15 @@
|
|||
---
|
||||
include: https://raw.githubusercontent.com/hassio-addons/organization/master/gitlabci/addon.yml
|
||||
|
||||
variables:
|
||||
ADDON_GITHUB_REPO: "hassio-addons/addon-mopidy"
|
||||
ADDON_SLUG: "mopidy"
|
||||
ADDON_TARGET: "mopidy"
|
||||
|
||||
ADDON_LEGACY_TAGS: "true"
|
||||
ADDON_ARMHF: "false"
|
||||
|
||||
ADDON_AARCH64_BASE: "hassioaddons/base-aarch64:3.0.1"
|
||||
ADDON_AMD64_BASE: "hassioaddons/base-amd64:3.0.1"
|
||||
ADDON_ARMV7_BASE: "hassioaddons/base-armv7:3.0.1"
|
||||
ADDON_I386_BASE: "hassioaddons/base-i386:3.0.1"
|
248
README.md
Normal file
248
README.md
Normal file
|
@ -0,0 +1,248 @@
|
|||
# Community Hass.io Add-ons: Mopidy
|
||||
|
||||
[![GitHub Release][releases-shield]][releases]
|
||||
![Project Stage][project-stage-shield]
|
||||
[![License][license-shield]](LICENSE.md)
|
||||
|
||||
[![GitLab CI][gitlabci-shield]][gitlabci]
|
||||
![Project Maintenance][maintenance-shield]
|
||||
[![GitHub Activity][commits-shield]][commits]
|
||||
|
||||
[![Discord][discord-shield]][discord]
|
||||
[![Community Forum][forum-shield]][forum]
|
||||
|
||||
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
|
||||
|
||||
[![Support my work on Patreon][patreon-shield]][patreon]
|
||||
|
||||

|
||||
|
||||
Mopidy is an extensible music server.
|
||||
|
||||
## About
|
||||
|
||||
Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music, and more. You edit the playlist from any phone, tablet, or computer using a range of MPD and web clients.
|
||||
|
||||
## Installation
|
||||
|
||||
The installation of this add-on is pretty straightforward and not different in
|
||||
comparison to installing any other Hass.io add-on.
|
||||
|
||||
1. [Add our Hass.io add-ons repository][repository] to your Hass.io instance.
|
||||
1. Install the "Mopidy" add-on.
|
||||
1. Start the "Mopidy" add-on
|
||||
1. Check the logs of the "Mopidy" add-on to see if everything went well.
|
||||
|
||||
**NOTE**: Do not add this repository to Hass.io, please use:
|
||||
`https://github.com/hassio-addons/repository`.
|
||||
|
||||
## Configuration
|
||||
|
||||
**Note**: _Remember to restart the add-on when the configuration is changed._
|
||||
|
||||
Example add-on configuration:
|
||||
|
||||
```json
|
||||
{
|
||||
"settings": [
|
||||
{
|
||||
"name": "soundcloud/auth_token",
|
||||
"value": "1-1111-1111-11eeaswdf23"
|
||||
},
|
||||
{
|
||||
"name": "spotify/username",
|
||||
"value": "your@email.com"
|
||||
},
|
||||
{
|
||||
"name": "spotify/password",
|
||||
"value": "thesupersecretpassword"
|
||||
},
|
||||
{
|
||||
"name": "spotify/client_id",
|
||||
"value": "spotify-client-id"
|
||||
},
|
||||
{
|
||||
"name": "spotify/client_secret",
|
||||
"value": "spotify-client-secret="
|
||||
},
|
||||
{
|
||||
"name": "gmusic/username",
|
||||
"value": "username"
|
||||
},
|
||||
{
|
||||
"name": "gmusic/password",
|
||||
"value": "thesupersecretpassword"
|
||||
},
|
||||
{
|
||||
"name": "gmusic/deviceid",
|
||||
"value": "yodeviceid"
|
||||
}
|
||||
],
|
||||
"system_packages": [],
|
||||
"python_packages": []
|
||||
}
|
||||
```
|
||||
|
||||
### Option: `settings`
|
||||
|
||||
This option allows you to tweak every aspect of Mopidy by setting
|
||||
configuration options. See the example at the start of this chapter
|
||||
to get an idea of how the configuration looks.
|
||||
|
||||
For more information about using these settings, see the official Mopidy
|
||||
documentation:
|
||||
|
||||
<https://docs.mopidy.com/en/latest/config/>
|
||||
|
||||
**Note**: _This option support secrets, e.g., `!secret spotify_password`._
|
||||
|
||||
### Option: `system_packages`
|
||||
|
||||
Allows you to specify additional [Ubuntu packages][ubuntu-packages] to be
|
||||
installed in your shell environment (e.g., Python, PHP, Go).
|
||||
|
||||
**Note**: _Adding many packages will result in a longer start-up
|
||||
time for the add-on._
|
||||
|
||||
### Option: `python_packages`
|
||||
|
||||
Allows you to specify additional [Python packages][python-packages] to be
|
||||
installed to your Mopidy setup (e.g., `PyMySQL`. `Requests`, `Pillow`).
|
||||
|
||||
**Note**: _Adding many packages will result in a longer start-up time
|
||||
for the add-on._
|
||||
|
||||
### Option: `leave_front_door_open`
|
||||
|
||||
Adding this option to the add-on configuration allows you to disable
|
||||
authentication on the VSCode by setting it to `true`.
|
||||
|
||||
**Note**: _We STRONGLY suggest, not to use this, even if this add-on is
|
||||
only exposed to your internal network. USE AT YOUR OWN RISK!_
|
||||
|
||||
## Embedding into Home Assistant
|
||||
|
||||
It is possible to embed mopidy directly into Home Assistant, allowing
|
||||
you to access your mopidy through the Home Assistant frontend.
|
||||
|
||||
Home Assistant provides the `panel_iframe` component, for these purposes.
|
||||
|
||||
Example configuration:
|
||||
|
||||
```yaml
|
||||
panel_iframe:
|
||||
mopidy:
|
||||
title: Mopidy
|
||||
icon: mdi:music
|
||||
url: http://address.to.your.hass.io:6680/iris/
|
||||
```
|
||||
|
||||
## Changelog & Releases
|
||||
|
||||
This repository keeps a change log using [GitHub's releases][releases]
|
||||
functionality. The format of the log is based on
|
||||
[Keep a Changelog][keepchangelog].
|
||||
|
||||
Releases are based on [Semantic Versioning][semver], and use the format
|
||||
of ``MAJOR.MINOR.PATCH``. In a nutshell, the version will be incremented
|
||||
based on the following:
|
||||
|
||||
- ``MAJOR``: Incompatible or major changes.
|
||||
- ``MINOR``: Backwards-compatible new features and enhancements.
|
||||
- ``PATCH``: Backwards-compatible bugfixes and package updates.
|
||||
|
||||
## Support
|
||||
|
||||
Got questions?
|
||||
|
||||
You have several options to get them answered:
|
||||
|
||||
- The [Community Hass.io Add-ons Discord chat server][discord] for add-on
|
||||
support and feature requests.
|
||||
- The [Home Assistant Discord chat server][discord-ha] for general Home
|
||||
Assistant discussions and questions.
|
||||
- The Home Assistant [Community Forum][forum].
|
||||
- Join the [Reddit subreddit][reddit] in [/r/homeassistant][reddit]
|
||||
|
||||
You could also [open an issue here][issue] GitHub.
|
||||
|
||||
## Contributing
|
||||
|
||||
This is an active open-source project. We are always open to people who want to
|
||||
use the code or contribute to it.
|
||||
|
||||
We have set up a separate document containing our
|
||||
[contribution guidelines](CONTRIBUTING.md).
|
||||
|
||||
Thank you for being involved! :heart_eyes:
|
||||
|
||||
## Authors & contributors
|
||||
|
||||
The original setup of this repository is by [Bram Mittendorff][brammittendorff],
|
||||
[Franck Nijhof][frenck] and [Robbert Müller][mjrider].
|
||||
|
||||
For a full list of all authors and contributors,
|
||||
check [the contributor's page][contributors].
|
||||
|
||||
## We have got some Hass.io add-ons for you
|
||||
|
||||
Want some more functionality to your Hass.io Home Assistant instance?
|
||||
|
||||
We have created multiple add-ons for Hass.io. For a full list, check out
|
||||
our [GitHub Repository][repository].
|
||||
|
||||
## License
|
||||
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2019 Bram Mittendorff, Franck Nijhof, Robbert Müller
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
|
||||
[brammittendorff]: https://github.com/brammittendorff
|
||||
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg
|
||||
[buymeacoffee]: https://www.buymeacoffee.com/frenck
|
||||
[commits-shield]: https://img.shields.io/github/commit-activity/y/hassio-addons/addon-mopidy.svg
|
||||
[commits]: https://github.com/hassio-addons/addon-mopidy/commits/master
|
||||
[contributors]: https://github.com/hassio-addons/addon-mopidy/graphs/contributors
|
||||
[discord-ha]: https://discord.gg/c5DvZ4e
|
||||
[discord-shield]: https://img.shields.io/discord/478094546522079232.svg
|
||||
[discord]: https://discord.me/hassioaddons
|
||||
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg
|
||||
[forum]: https://community.home-assistant.io/?u=frenck
|
||||
[frenck]: https://github.com/frenck
|
||||
[gitlabci-shield]: https://gitlab.com/hassio-addons/addon-mopidy/badges/master/pipeline.svg
|
||||
[gitlabci]: https://gitlab.com/hassio-addons/addon-mopidy/pipelines
|
||||
[home-assistant]: https://home-assistant.io
|
||||
[issue]: https://github.com/hassio-addons/addon-mopidy/issues
|
||||
[keepchangelog]: http://keepachangelog.com/en/1.0.0/
|
||||
[license-shield]: https://img.shields.io/github/license/hassio-addons/addon-mopidy.svg
|
||||
[maintenance-shield]: https://img.shields.io/maintenance/yes/2019.svg
|
||||
[mjrider]: https://github.com/mjrider
|
||||
[patreon-shield]: https://www.frenck.nl/images/patreon.png
|
||||
[patreon]: https://www.patreon.com/
|
||||
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
|
||||
[python-packages]: https://pypi.org
|
||||
[python-packages]: https://pypi.org/
|
||||
[reddit]: https://reddit.com/r/homeassistant
|
||||
[releases-shield]: https://img.shields.io/github/release/hassio-addons/addon-mopidy.svg
|
||||
[releases]: https://github.com/hassio-addons/addon-mopidy/releases
|
||||
[repository]: https://github.com/hassio-addons/repository
|
||||
[semver]: http://semver.org/spec/v2.0.0.htm
|
||||
[ubuntu-packages]: https://packages.ubuntu.com
|
BIN
images/screenshot.png
Normal file
BIN
images/screenshot.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 62 KiB |
75
mopidy/.README.j2
Normal file
75
mopidy/.README.j2
Normal file
|
@ -0,0 +1,75 @@
|
|||
# Community Hass.io Add-ons: Mopidy
|
||||
|
||||
[![Release][release-shield]][release] ![Project Stage][project-stage-shield] ![Project Maintenance][maintenance-shield]
|
||||
|
||||
[![Discord][discord-shield]][discord] [![Community Forum][forum-shield]][forum]
|
||||
|
||||
[![Buy me a coffee][buymeacoffee-shield]][buymeacoffee]
|
||||
|
||||
[![Support my work on Patreon][patreon-shield]][patreon]
|
||||
|
||||
Mopidy is an extensible music server.
|
||||
|
||||
## About
|
||||
|
||||
Mopidy plays music from local disk, Spotify, SoundCloud, Google Play Music,
|
||||
and more. You edit the playlist from any phone, tablet, or computer using a
|
||||
range of MPD and web clients.
|
||||
|
||||
[Click here for the full documentation][docs]
|
||||
|
||||
![Mopidy screenshot][screenshot]
|
||||
|
||||
{% if channel == "edge" %}
|
||||
## WARNING! THIS IS AN EDGE VERSION!
|
||||
|
||||
This Hass.io Add-ons repository contains edge builds of add-ons. Edge builds
|
||||
add-ons are based upon the latest development version.
|
||||
|
||||
- They may not work at all.
|
||||
- They might stop working at any time.
|
||||
- They could have a negative impact on your system.
|
||||
|
||||
This repository was created for:
|
||||
|
||||
- Anybody willing to test.
|
||||
- Anybody interested in trying out upcoming add-ons or add-on features.
|
||||
- Developers.
|
||||
|
||||
If you are more interested in stable releases of our add-ons:
|
||||
|
||||
<https://github.com/hassio-addons/repository>
|
||||
|
||||
{% endif %}
|
||||
{% if channel == "beta" %}
|
||||
## WARNING! THIS IS A BETA VERSION!
|
||||
|
||||
This Hass.io Add-ons repository contains beta releases of add-ons.
|
||||
|
||||
- They might stop working at any time.
|
||||
- They could have a negative impact on your system.
|
||||
|
||||
This repository was created for:
|
||||
|
||||
- Anybody willing to test.
|
||||
- Anybody interested in trying out upcoming add-ons or add-on features.
|
||||
|
||||
If you are more interested in stable releases of our add-ons:
|
||||
|
||||
<https://github.com/hassio-addons/repository>
|
||||
|
||||
{% endif %}
|
||||
[buymeacoffee-shield]: https://www.buymeacoffee.com/assets/img/guidelines/download-assets-sm-2.svg
|
||||
[buymeacoffee]: https://www.buymeacoffee.com/frenck
|
||||
[discord-shield]: https://img.shields.io/discord/478094546522079232.svg
|
||||
[discord]: https://discord.me/hassioaddons
|
||||
[docs]: {{ repo }}/blob/{{ version }}/README.md
|
||||
[forum-shield]: https://img.shields.io/badge/community-forum-brightgreen.svg
|
||||
[forum]: https://community.home-assistant.io/?u=frenck
|
||||
[maintenance-shield]: https://img.shields.io/maintenance/yes/2019.svg
|
||||
[patreon-shield]: https://www.frenck.nl/images/patreon.png
|
||||
[patreon]: https://www.patreon.com/frenck
|
||||
[project-stage-shield]: https://img.shields.io/badge/project%20stage-experimental-yellow.svg
|
||||
[release-shield]: https://img.shields.io/badge/version-{{ version }}-blue.svg
|
||||
[release]: {{ repo }}/tree/{{ version }}
|
||||
[screenshot]: https://github.com/hassio-addons/addon-mopidy/raw/master/images/screenshot.png
|
100
mopidy/Dockerfile
Executable file
100
mopidy/Dockerfile
Executable file
|
@ -0,0 +1,100 @@
|
|||
ARG BUILD_FROM=hassioaddons/ubuntu-base:3.0.0
|
||||
# hadolint ignore=DL3006
|
||||
FROM ${BUILD_FROM}
|
||||
|
||||
# Set shell
|
||||
SHELL ["/bin/bash", "-o", "pipefail", "-c"]
|
||||
|
||||
# Copy Python requirements file
|
||||
COPY requirements.txt /tmp/
|
||||
|
||||
# Setup base
|
||||
RUN \
|
||||
apt-get update \
|
||||
\
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
dirmngr=2.2.4-1ubuntu1.2 \
|
||||
gpg-agent=2.2.4-1ubuntu1.2 \
|
||||
gpg=2.2.4-1ubuntu1.2 \
|
||||
libnginx-mod-http-lua=1.14.0-0ubuntu1.2 \
|
||||
luarocks=2.4.2+dfsg-1 \
|
||||
nginx=1.14.0-0ubuntu1.2 \
|
||||
\
|
||||
&& curl -L https://apt.mopidy.com/mopidy.gpg | apt-key add - \
|
||||
&& curl -L https://apt.mopidy.com/mopidy.list -o /etc/apt/sources.list.d/mopidy.list \
|
||||
\
|
||||
&& apt-get update \
|
||||
\
|
||||
&& apt-get install -y --no-install-recommends \
|
||||
build-essential=12.4ubuntu1 \
|
||||
gstreamer1.0-alsa=1.14.1-1ubuntu1~ubuntu18.04.1 \
|
||||
gstreamer1.0-plugins-bad=1.14.1-1ubuntu1~ubuntu18.04.1 \
|
||||
gstreamer1.0-pulseaudio=1.14.1-1ubuntu1~ubuntu18.04.1 \
|
||||
libffi-dev=3.2.1-8 \
|
||||
libxml2-dev=2.9.4+dfsg1-6.1ubuntu1.2 \
|
||||
libxslt1-dev=1.1.29-5 \
|
||||
mopidy-alsamixer=1.0.3-3 \
|
||||
mopidy-local-sqlite=1.0.0-2 \
|
||||
mopidy-spotify-tunigo=1.0.0-0mopidy1 \
|
||||
mopidy-spotify=3.1.0-0mopidy1 \
|
||||
mopidy=2.2.2-1 \
|
||||
python-dev=2.7.15~rc1-1 \
|
||||
zlib1g-dev=1:1.2.11.dfsg-0ubuntu2 \
|
||||
\
|
||||
&& luarocks install lua-resty-http 0.13-0 \
|
||||
\
|
||||
&& curl https://bootstrap.pypa.io/get-pip.py | python \
|
||||
&& pip install --no-cache-dir -r /tmp/requirements.txt \
|
||||
\
|
||||
&& find /usr/local/lib/python2.7/ -type d -name tests -depth -exec rm -rf {} \; \
|
||||
&& find /usr/local/lib/python2.7/ -type d -name test -depth -exec rm -rf {} \; \
|
||||
&& find /usr/local/lib/python2.7/ -name __pycache__ -depth -exec rm -rf {} \; \
|
||||
&& find /usr/local/lib/python2.7/ -name "*.pyc" -depth -exec rm -f {} \; \
|
||||
\
|
||||
&& apt-get purge -y --auto-remove \
|
||||
build-essential \
|
||||
dirmngr \
|
||||
dpkg-dev \
|
||||
gcc \
|
||||
gcc-7 \
|
||||
gpg \
|
||||
gpg-agent \
|
||||
libffi-dev \
|
||||
libxml2-dev \
|
||||
libxslt1-dev \
|
||||
luarocks \
|
||||
python-dev \
|
||||
zlib1g-dev \
|
||||
\
|
||||
&& find /tmp/ -mindepth 1 -delete \
|
||||
&& rm -fr \
|
||||
/var/{cache,log}/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/root/.cache
|
||||
|
||||
# Copy root filesystem
|
||||
COPY rootfs /
|
||||
|
||||
# Build arguments
|
||||
ARG BUILD_ARCH
|
||||
ARG BUILD_DATE
|
||||
ARG BUILD_REF
|
||||
ARG BUILD_VERSION
|
||||
|
||||
# Labels
|
||||
LABEL \
|
||||
io.hass.name="Mopidy" \
|
||||
io.hass.description="Mopidy is an extensible music server" \
|
||||
io.hass.arch="${BUILD_ARCH}" \
|
||||
io.hass.type="addon" \
|
||||
io.hass.version=${BUILD_VERSION} \
|
||||
maintainer="Bram Mittendorff, Franck Nijhof, Robbert Müller" \
|
||||
org.label-schema.description="Mopidy is an extensible music server" \
|
||||
org.label-schema.build-date=${BUILD_DATE} \
|
||||
org.label-schema.name="Mopidy" \
|
||||
org.label-schema.schema-version="1.0" \
|
||||
org.label-schema.url="https://community.home-assistant.io/" \
|
||||
org.label-schema.usage="https://github.com/hassio-addons/addon-mopidy/tree/master/README.md" \
|
||||
org.label-schema.vcs-ref=${BUILD_REF} \
|
||||
org.label-schema.vcs-url="https://github.com/hassio-addons/addon-mopidy" \
|
||||
org.label-schema.vendor="Community Hass.io Add-ons"
|
9
mopidy/build.json
Normal file
9
mopidy/build.json
Normal file
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
"build_from": {
|
||||
"aarch64": "hassioaddons/ubuntu-base-aarch64:3.0.0",
|
||||
"amd64": "hassioaddons/ubuntu-base-amd64:3.0.0",
|
||||
"armv7": "hassioaddons/ubuntu-base-armv7:3.0.0",
|
||||
"i386": "hassioaddons/ubuntu-base-i386:3.0.0"
|
||||
},
|
||||
"args": {}
|
||||
}
|
48
mopidy/config.json
Executable file
48
mopidy/config.json
Executable file
|
@ -0,0 +1,48 @@
|
|||
{
|
||||
"name": "Mopidy",
|
||||
"version": "dev",
|
||||
"slug": "mopidy",
|
||||
"description": "Mopidy is an extensible music server",
|
||||
"url": "https://github.com/hassio-addons/addon-mopidy",
|
||||
"webui": "http://[HOST]:[PORT:6680]/iris/",
|
||||
"startup": "application",
|
||||
"arch": [
|
||||
"aarch64",
|
||||
"amd64",
|
||||
"armv7",
|
||||
"i386"
|
||||
],
|
||||
"boot": "auto",
|
||||
"hassio_api": true,
|
||||
"auth_api": true,
|
||||
"hassio_role": "default",
|
||||
"host_network": false,
|
||||
"audio": true,
|
||||
"ports": {
|
||||
"55555/udp": 5555,
|
||||
"6600/tcp": 6600,
|
||||
"6680/tcp": 6680
|
||||
},
|
||||
"map": [
|
||||
"config",
|
||||
"share:rw",
|
||||
"ssl"
|
||||
],
|
||||
"options": {
|
||||
"system_packages": [],
|
||||
"python_packages": [],
|
||||
"settings": []
|
||||
},
|
||||
"schema": {
|
||||
"log_level": "match(^(trace|debug|info|notice|warning|error|fatal)$)?",
|
||||
"system_packages": ["str"],
|
||||
"python_packages": ["str"],
|
||||
"settings": [
|
||||
{
|
||||
"name": "str",
|
||||
"value": "str"
|
||||
}
|
||||
],
|
||||
"leave_front_door_open": "bool?"
|
||||
}
|
||||
}
|
BIN
mopidy/icon.png
Normal file
BIN
mopidy/icon.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.9 KiB |
BIN
mopidy/logo.png
Normal file
BIN
mopidy/logo.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.3 KiB |
3
mopidy/requirements.txt
Normal file
3
mopidy/requirements.txt
Normal file
|
@ -0,0 +1,3 @@
|
|||
Mopidy-GMusic==3.0.0
|
||||
Mopidy-Iris==3.33.0
|
||||
Mopidy-SoundCloud==2.1.0
|
7
mopidy/rootfs/etc/cont-init.d/10-requirements.sh
Normal file
7
mopidy/rootfs/etc/cont-init.d/10-requirements.sh
Normal file
|
@ -0,0 +1,7 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# This files check if all user configuration requirements are met
|
||||
# ==============================================================================
|
||||
bashio::config.require.ssl
|
||||
|
18
mopidy/rootfs/etc/cont-init.d/11-nginx.sh
Normal file
18
mopidy/rootfs/etc/cont-init.d/11-nginx.sh
Normal file
|
@ -0,0 +1,18 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# Configures NGINX for use with code-server
|
||||
# ==============================================================================
|
||||
declare certfile
|
||||
declare keyfile
|
||||
|
||||
mkdir -p /var/log/nginx
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
certfile=$(bashio::config 'certfile')
|
||||
keyfile=$(bashio::config 'keyfile')
|
||||
|
||||
sed -i "s/%%certfile%%/${certfile}/g" /etc/nginx/nginx-ssl.conf
|
||||
sed -i "s/%%keyfile%%/${keyfile}/g" /etc/nginx/nginx-ssl.conf
|
||||
fi
|
||||
|
10
mopidy/rootfs/etc/cont-init.d/20-folders.sh
Normal file
10
mopidy/rootfs/etc/cont-init.d/20-folders.sh
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# Ensures needed folder exists.
|
||||
# ==============================================================================
|
||||
readonly MEDIA_DIR="/share/mopidy/media"
|
||||
|
||||
if ! bashio::fs.directory_exist "${MEDIA_DIR}"; then
|
||||
mkdir -p "${MEDIA_DIR}" || bashio::exit.nok "Could not create media folder: ${MEDIA_DIR}"
|
||||
fi
|
14
mopidy/rootfs/etc/cont-init.d/80-system-packages.sh
Normal file
14
mopidy/rootfs/etc/cont-init.d/80-system-packages.sh
Normal file
|
@ -0,0 +1,14 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# Install user configured/requested packages
|
||||
# ==============================================================================
|
||||
if bashio::config.has_value 'system_packages'; then
|
||||
apt update \
|
||||
|| bashio::exit.nok 'Failed updating Ubuntu packages repository indexes'
|
||||
|
||||
for package in $(bashio::config 'system_packages'); do
|
||||
apt install -y "$package" \
|
||||
|| bashio::exit.nok "Failed installing package ${package}"
|
||||
done
|
||||
fi
|
11
mopidy/rootfs/etc/cont-init.d/81-python-packages.sh
Normal file
11
mopidy/rootfs/etc/cont-init.d/81-python-packages.sh
Normal file
|
@ -0,0 +1,11 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# Install user configured/requested Python packages
|
||||
# ==============================================================================
|
||||
if bashio::config.has_value 'python_packages'; then
|
||||
for package in $(bashio::config 'python_packages'); do
|
||||
pip install "$package" \
|
||||
|| bashio::exit.nok "Failed installing package ${package}"
|
||||
done
|
||||
fi
|
43
mopidy/rootfs/etc/mopidy/mopidy.conf
Normal file
43
mopidy/rootfs/etc/mopidy/mopidy.conf
Normal file
|
@ -0,0 +1,43 @@
|
|||
[core]
|
||||
cache_dir = /data/cache
|
||||
config_dir = /etc/mopidy
|
||||
data_dir = /data/mopidy
|
||||
max_tracklist_length = 10000
|
||||
restore_state = false
|
||||
|
||||
[logging]
|
||||
color = true
|
||||
console_format = %(levelname)-8s %(message)s
|
||||
debug_format = %(levelname)-8s %(asctime)s [%(process)d:%(threadName)s] %(name)s\n %(message)s
|
||||
debug_file = /proc/1/fd/1
|
||||
config_file =
|
||||
|
||||
[audio]
|
||||
mixer = software
|
||||
mixer_volume =
|
||||
output = autoaudiosink
|
||||
buffer_time =
|
||||
|
||||
[http]
|
||||
hostname = 127.0.0.1
|
||||
port = 4478
|
||||
|
||||
[mpd]
|
||||
hostname = 0.0.0.0
|
||||
|
||||
[local]
|
||||
media_dir = /share/mopidy/media
|
||||
library = sqlite
|
||||
scan_flush_threshold = 100
|
||||
|
||||
[stream]
|
||||
enabled = true
|
||||
protocols =
|
||||
http
|
||||
https
|
||||
mms
|
||||
rtmp
|
||||
rtmps
|
||||
rtsp
|
||||
timeout = 5000
|
||||
metadata_blacklist =
|
84
mopidy/rootfs/etc/nginx/ha-auth.lua
Normal file
84
mopidy/rootfs/etc/nginx/ha-auth.lua
Normal file
|
@ -0,0 +1,84 @@
|
|||
local http = require "resty.http"
|
||||
local auths = ngx.shared.auths
|
||||
|
||||
function authenticate()
|
||||
|
||||
--- Test Authentication header is set and with a value
|
||||
local header = ngx.req.get_headers()['Authorization']
|
||||
if header == nil or header:find(" ") == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
local divider = header:find(' ')
|
||||
if header:sub(0, divider-1) ~= 'Basic' then
|
||||
return false
|
||||
end
|
||||
|
||||
local auth = ngx.decode_base64(header:sub(divider+1))
|
||||
if auth == nil or auth:find(':') == nil then
|
||||
return false
|
||||
end
|
||||
|
||||
divider = auth:find(':')
|
||||
local username = auth:sub(0, divider-1)
|
||||
local password = auth:sub(divider+1)
|
||||
|
||||
--- Check if authentication is cached
|
||||
if auths:get(username) == password then
|
||||
ngx.log(ngx.DEBUG, "Authenticated user against Home Assistant (cache).")
|
||||
return true
|
||||
end
|
||||
|
||||
--- HTTP request against Hassio API
|
||||
local httpc = http.new()
|
||||
local res, err = httpc:request_uri("http://hassio/auth", {
|
||||
method = "POST",
|
||||
body = ngx.encode_args({["username"]=username, ["password"]=password}),
|
||||
headers = {
|
||||
["Content-Type"] = "application/x-www-form-urlencoded",
|
||||
["X-HASSIO-KEY"] = os.getenv("HASSIO_TOKEN"),
|
||||
},
|
||||
keepalive_timeout = 60,
|
||||
keepalive_pool = 10
|
||||
})
|
||||
|
||||
--- Error during API request
|
||||
if err then
|
||||
ngx.log(ngx.WARN, "Error during Hassio user authentication.", err)
|
||||
return false
|
||||
end
|
||||
|
||||
--- No result? Something went wrong...
|
||||
if not res then
|
||||
ngx.log(ngx.WARN, "Error during Hassio user authentication.")
|
||||
return false
|
||||
end
|
||||
|
||||
--- Valid response, the username/password is valid
|
||||
if res.status == 200 then
|
||||
ngx.log(ngx.INFO, "Authenticated user against Home Assistant.")
|
||||
auths:set(username, password, 60)
|
||||
return true
|
||||
end
|
||||
|
||||
--- Whatever the response is, it is invalid
|
||||
ngx.log(ngx.WARN, "Authentication against Home Assistant failed!")
|
||||
return false
|
||||
end
|
||||
|
||||
-- Only authenticate if its not disabled
|
||||
if not os.getenv('DISABLE_HA_AUTHENTICATION') then
|
||||
|
||||
--- Try to authenticate against HA
|
||||
local authenticated = authenticate()
|
||||
|
||||
--- If authentication failed, throw a basic auth
|
||||
if not authenticated then
|
||||
ngx.header.content_type = 'text/plain'
|
||||
ngx.header.www_authenticate = 'Basic realm="Home Assistant"'
|
||||
ngx.status = ngx.HTTP_UNAUTHORIZED
|
||||
ngx.say('401 Access Denied')
|
||||
ngx.exit(ngx.HTTP_UNAUTHORIZED)
|
||||
end
|
||||
end
|
||||
|
72
mopidy/rootfs/etc/nginx/nginx-ssl.conf
Normal file
72
mopidy/rootfs/etc/nginx/nginx-ssl.conf
Normal file
|
@ -0,0 +1,72 @@
|
|||
worker_processes 1;
|
||||
pid /var/run/nginx.pid;
|
||||
error_log stderr;
|
||||
env HASSIO_TOKEN;
|
||||
env DISABLE_HA_AUTHENTICATION;
|
||||
load_module "/usr/lib/nginx/modules/ndk_http_module.so";
|
||||
load_module "/usr/lib/nginx/modules/ngx_http_lua_module.so";
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
access_log stdout;
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
lua_shared_dict auths 16k;
|
||||
resolver 127.0.0.11;
|
||||
|
||||
upstream mopidy {
|
||||
ip_hash;
|
||||
server 127.0.0.1:4478;
|
||||
}
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
server_name hassio.local;
|
||||
listen 6680 default_server ssl;
|
||||
root /dev/null;
|
||||
|
||||
ssl_certificate /ssl/%%certfile%%;
|
||||
ssl_certificate_key /ssl/%%keyfile%%;
|
||||
ssl_protocols TLSv1.2;
|
||||
ssl_prefer_server_ciphers on;
|
||||
ssl_ciphers ECDHE-RSA-AES256-GCM-SHA512:DHE-RSA-AES256-GCM-SHA512:ECDHE-RSA-AES256-GCM-SHA384:DHE-RSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:DHE-RSA-AES256-SHA;
|
||||
ssl_ecdh_curve secp384r1;
|
||||
ssl_session_timeout 10m;
|
||||
ssl_session_cache shared:SSL:10m;
|
||||
ssl_session_tickets off;
|
||||
ssl_stapling on;
|
||||
ssl_stapling_verify on;
|
||||
|
||||
add_header X-Content-Type-Options nosniff;
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Robots-Tag none;
|
||||
|
||||
location / {
|
||||
access_by_lua_file /etc/nginx/ha-auth.lua;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_pass http://mopidy;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Authorization "";
|
||||
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
58
mopidy/rootfs/etc/nginx/nginx.conf
Normal file
58
mopidy/rootfs/etc/nginx/nginx.conf
Normal file
|
@ -0,0 +1,58 @@
|
|||
worker_processes 1;
|
||||
pid /var/run/nginx.pid;
|
||||
error_log stderr;
|
||||
env HASSIO_TOKEN;
|
||||
env DISABLE_HA_AUTHENTICATION;
|
||||
load_module "/usr/lib/nginx/modules/ndk_http_module.so";
|
||||
load_module "/usr/lib/nginx/modules/ngx_http_lua_module.so";
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
http {
|
||||
access_log stdout;
|
||||
include mime.types;
|
||||
default_type application/octet-stream;
|
||||
sendfile on;
|
||||
keepalive_timeout 65;
|
||||
lua_shared_dict auths 16k;
|
||||
resolver 127.0.0.11;
|
||||
|
||||
upstream mopidy {
|
||||
ip_hash;
|
||||
server 127.0.0.1:4478;
|
||||
}
|
||||
|
||||
map $http_upgrade $connection_upgrade {
|
||||
default upgrade;
|
||||
'' close;
|
||||
}
|
||||
|
||||
server {
|
||||
server_name hassio.local;
|
||||
listen 6680 default_server;
|
||||
root /dev/null;
|
||||
|
||||
location / {
|
||||
access_by_lua_file /etc/nginx/ha-auth.lua;
|
||||
|
||||
proxy_redirect off;
|
||||
proxy_pass http://mopidy;
|
||||
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection $connection_upgrade;
|
||||
proxy_set_header Authorization "";
|
||||
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_set_header Host $http_host;
|
||||
proxy_set_header X-NginX-Proxy true;
|
||||
proxy_read_timeout 86400s;
|
||||
proxy_send_timeout 86400s;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
9
mopidy/rootfs/etc/services.d/mopidy/finish
Normal file
9
mopidy/rootfs/etc/services.d/mopidy/finish
Normal file
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# Take down the S6 supervision tree when Mopidy fails
|
||||
# ==============================================================================
|
||||
if -n { s6-test $# -ne 0 }
|
||||
if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
19
mopidy/rootfs/etc/services.d/mopidy/run
Normal file
19
mopidy/rootfs/etc/services.d/mopidy/run
Normal file
|
@ -0,0 +1,19 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# Runs the Mopidy
|
||||
# ==============================================================================
|
||||
declare -a options
|
||||
|
||||
bashio::log.info "Starting Mopidy..."
|
||||
|
||||
for var in $(bashio::config 'settings|keys'); do
|
||||
name=$(bashio::config "settings[${var}].name")
|
||||
value=$(bashio::config "settings[${var}].value")
|
||||
bashio::log.info "Setting ${name} to ${value}"
|
||||
|
||||
options+=(-o "${name}=${value}")
|
||||
done
|
||||
|
||||
# Run Mopidy
|
||||
exec mopidy --config /etc/mopidy/mopidy.conf "${options[@]}"
|
10
mopidy/rootfs/etc/services.d/nginx/finish
Normal file
10
mopidy/rootfs/etc/services.d/nginx/finish
Normal file
|
@ -0,0 +1,10 @@
|
|||
#!/usr/bin/execlineb -S0
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# Take down the S6 supervision tree when Nginx fails
|
||||
# ==============================================================================
|
||||
if -n { s6-test $# -ne 0 }
|
||||
if -n { s6-test ${1} -eq 256 }
|
||||
|
||||
s6-svscanctl -t /var/run/s6/services
|
||||
|
28
mopidy/rootfs/etc/services.d/nginx/run
Normal file
28
mopidy/rootfs/etc/services.d/nginx/run
Normal file
|
@ -0,0 +1,28 @@
|
|||
#!/usr/bin/with-contenv bashio
|
||||
# ==============================================================================
|
||||
# Community Hass.io Add-ons: Mopidy
|
||||
# Runs the Nginx daemon
|
||||
# ==============================================================================
|
||||
declare -a options
|
||||
|
||||
# Wait for Mopidy to become available
|
||||
s6-svwait -u -t 5000 /var/run/s6/services/mopidy
|
||||
timeout 15 \
|
||||
bash -c \
|
||||
'until echo > /dev/tcp/localhost/4478 ; do sleep 0.5; done' \
|
||||
> /dev/null 2>&1
|
||||
|
||||
bashio::log.info "Starting NGinx..."
|
||||
|
||||
# Disable HA Authentication if front door is open
|
||||
if bashio::config.true 'leave_front_door_open'; then
|
||||
export DISABLE_HA_AUTHENTICATION=true
|
||||
fi
|
||||
|
||||
options+=(-g "daemon off;")
|
||||
|
||||
if bashio::config.true 'ssl'; then
|
||||
options+=(-c /etc/nginx/nginx-ssl.conf)
|
||||
fi
|
||||
|
||||
exec nginx "${options[@]}"
|
Loading…
Add table
Add a link
Reference in a new issue