Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/esteanes/mopidy_multiple-instances
A guide & script to create multiple instances of Mopidy and integrate it with Snapcast
https://github.com/esteanes/mopidy_multiple-instances
mopidy snapcast
Last synced: 26 days ago
JSON representation
A guide & script to create multiple instances of Mopidy and integrate it with Snapcast
- Host: GitHub
- URL: https://github.com/esteanes/mopidy_multiple-instances
- Owner: ESteanes
- Created: 2021-07-31T03:54:48.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-08-22T00:06:35.000Z (over 3 years ago)
- Last Synced: 2024-10-19T07:08:03.240Z (3 months ago)
- Topics: mopidy, snapcast
- Language: Shell
- Homepage:
- Size: 22.5 KB
- Stars: 3
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Making Multiple Mopidy Instances
This script/instruction detials how to create multiple instances of mopidy which pipe their outputs to separate mopidy streams.
This enables you to have the flexibility to play one song across multiple speakers or have each speaker play its own song.
### Prerequistes
* Mopidy installed [Mopidy Github](https://github.com/mopidy/mopidy)
* Snapcast installed [Snapcast Github](https://github.com/badaix/snapcast)## Automatically
```
$ wget https://github.com/ESteanes/Mopidy_Multiple-Instances/releases/download/v0.1.0/multiple_mopidy.sh
$ bash multiple_mopidy.sh -N -H -O snapcast
```
Note: leaving the hostname blank will result in 127.0.0.1 which means that mopidy will only listen to local requests. Generally unfavourable setup.
## Manually\ represents the number of instances
1. Create additional mopidy_\.conf files
```
$ sudo touch /etc/mopidy/mopidy_.conf
```
2. Using a text editor, edit the file you created and add the following information in your mopidy_\.conf
```
[core]
cache_dir = /var/cache/mopidy_
data_dir = /var/lib/mopidy_[http]
port = 668[audio]
output = audioresample ! audioconvert ! audio/x-raw,rate=48000,channels=2,format=S16LE ! filesink location=/tmp/snapfifo_
```
3. _Optional_ Adding custom settingsYou may want to add custom information such as spotify accounts to different mopidy instances as that can help with personalisation. Do that in the corresponding file
For example spotify settings:
```
[spotify]
enabled = true
username = [email protected]
password = your_spotify_password
client_id = your_client_id
client_secret = your_client_secret
```4. Modify the original mopidy.conf file
Add in all the allowed origins for however many mopidy instances you created. This will allow you to access your 2nd mopidy
```
$ nano /etc/mopidy/mopidy.confallowed_origins = :6680,:668 (for all n)
```
5. Create and give ownership of cache and data directoiresIf creating multiple directories, can use * wildcard for `chown` command
```
$ mkdir /var/cache/mopidy_
$ mkdir /var/lib/mopidy_
$ chown mopidy:audio /var/cache/mopidy_ /var/lib/mopidy_
```
6. Create copies of the mopidyctl scriptCreating copies of the mopidyctl script will enable you to run these mopidy instances as a service without having to manually enable them upon reboot.
```
$ cp /usr/sbin/mopidyctl /usr/sbin/mopidyctl_
```
Then inside `usr/sbin/mopidyctl_`, change the `CONFIG_FILES` variable to the following:
```
CONFIG_FILES="/usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf:/etc/mopidy/mopidy_.conf"
```
This will make sure that the service will utilise the appropriate configuration files
unique to the extra instances, overwriting that in the base `mopidy.conf` file with the details in `mopidy_.conf` that you altered previously.7. Creating additional systemd scripts
You need to create copies of the systemd scripts to activate systemd for all the different instances
```
$ cp /lib/systemd/system/mopidy.service /lib/systemd/system/mopidy_.service
```
Then, using a text editor, edit the `mopidy_.service` file with the following:
```
ExecStart=/usr/bin/mopidy --config /usr/share/mopidy/conf.d:/etc/mopidy/mopidy.conf:/etc/mopidy/mopidy_.conf
```
8. Adding additional streams to SnapcastSince we are creating multiple instances of mopidy, we need to add these filesink locations in the snapcast configuration file that we are referencing in section 2.
```
$ nano /etc/snapserver.conf
```
then under the `[Stream]` heading, add the following:
```
source = pipe:///tmp/snapfifo_?name=
```
Here you can specify a custom name for each source. You can set up each of the mopidy instances for different people or sections of your house/apartment.9. Restart all the services
Restart all the services and complete the initialising processes
```
$ systemctl restart snapserver.service
$ mopidyctl_ local scan
$ systemctl enable mopidy*.service
$ systemctl start mopidy*.service