Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lmiphay committed Sep 6, 2021
1 parent 1a333ac commit 6a116d4
Show file tree
Hide file tree
Showing 7 changed files with 152 additions and 1 deletion.
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,31 @@
# logitechmediaserver-docker
Logitechmediaserver in a container

Logitechmediaserver in a container.

## Configuration

Variables at the start of the `logitechmediaserver-docker` script allow these settings to be customised:

1. logitechmediaserver version
2. directories to mount from the host
3. ports

## Quickstart

```
$ logitechmediaserver-docker settings
...
$ logitechmediaserver-docker pull
$ logitechmediaserver-docker create
$ logitechmediaserver-docker start
$ logitechmediaserver-docker logs
...
$ logitechmediaserver-docker stop
...
$ logitechmediaserver-docker delete
```

## References

1. https://hub.docker.com/r/lmscommunity/logitechmediaserver
2. https://forums.slimdevices.com/showthread.php?111828-Official-docker-container-for-LMS
8 changes: 8 additions & 0 deletions bin/custom-init.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/bin/sh

# see: https://hub.docker.com/r/lmscommunity/logitechmediaserver

apt-get update -qq
apt-get install --no-install-recommends -qy ffmpeg

exit 0
62 changes: 62 additions & 0 deletions bin/logitechmediaserver-docker
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

lms_version=${lms_version:-8.2.0}

lms_config=${lms_config:-/music/config}
lms_music=${lms_music:-/music/music}
lms_playlist=${lms_playlist:-/music/playlist}

# mappings for specific ports; other option is --net=host
# spotify 4070
lms_host_web_port=${lms_host_web_port:-9000} # TCP web UI
lms_host_cli_port=${lms_host_cli_port:-9090} # TCP server CLI
lms_host_players_port=${lms_host_players_port:-3483} # TCP/UDP control channel for client players (UDP is for discovery)
lms_host_firmware_port=${lms_host_firmware_port:-31337} # firmware updates

LMS_DOCKER_CONFIG=${LMS_DOCKER_CONFIG:-/etc/logitechmediaserver.conf}

if [ -n "${LMS_DOCKER_CONFIG}" -a -f "${LMS_DOCKER_CONFIG}" ] ; then source "${LMS_DOCKER_CONFIG}" ; fi

case "$1" in
pull)
docker pull "lmscommunity/logitechmediaserver:${lms_version}"
;;
create)
docker create \
--name logitechmediaserver \
-v "${lms_config}":"/config":rw \
-v "${lms_music}":"/music":ro \
-v "${lms_playlist}":"/playlist":rw \
-v "/etc/localtime":"/etc/localtime":ro \
-v "/etc/timezone":"/etc/timezone":ro \
-p "${lms_host_web_port}:9000/tcp" \
-p "${lms_host_cli_port}:9090/tcp" \
-p "${lms_host_players_port}:3483/tcp" \
-p "${lms_host_players_port}:3483/udp" \
-p "${lms_host_firmware_port}:31337/tcp" \
"lmscommunity/logitechmediaserver:${lms_version}"
;;
start|run)
[ ! -d "${lms_config}" ] && mkdir -p "${lms_config}"
[ ! -d "${lms_music}" ] && mkdir -p "${lms_music}"
[ ! -d "${lms_playlist}" ] && mkdir -p "${lms_playlist}"
docker start logitechmediaserver
;;
stop)
docker stop logitechmediaserver
;;
delete|rm)
docker rm logitechmediaserver
;;
logs)
docker logs -f logitechmediaserver
;;
settings)
set | egrep '^lms_' | sort
;;
*)
echo "Usage: $(basename $0) {pull|create|start|stop|delete|logs|settings}"
;;
esac

exit 0
12 changes: 12 additions & 0 deletions etc/logitechmediaserver.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# /etc/logitechmediaserver.conf: configuration for logitechmediaserver-docker

#logitechmediaserver_version=8.2.0

#lms_config=/music/config
#lms_music=/music/music
#lms_playlist=/music/playlist

#lms_host_web_port=9000 # TCP web UI
#lms_host_cli_port=9090 # TCP server CLI
#lms_host_players_port=3483 # TCP/UDP control channel for client players (UDP is for discovery)
#lms_host_firmware_port=31337 # firmware updates
16 changes: 16 additions & 0 deletions etc/logitechmediaserver.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
[Unit]
Description=Logitechmediaserver Service
After=network-online.target
Description=Logitechmediaserver Docker Appliance Service
Documentation=man:logitechmediaserver-docker(8)

[Service]
Type=oneshot
RemainAfterExit=yes
Environment=LOGITECHMEDIASERVER_DOCKER_CONFIG=/etc/logitechmediaserver.conf
WorkingDirectory=/var/tmp
ExecStart=/usr/bin/logitechmediaserver-docker start
ExecStop=/usr/bin/logitechmediaserver-docker stop

[Install]
WantedBy=multi-user.target
3 changes: 3 additions & 0 deletions openrc/logitechmediaserver.conf.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# /etc/conf.d/logitechmediaserver: configuration for /etc/init.d/logitechmediaserver

#LOGITECHMEDIASERVER_DOCKER_CONFIG=/etc/logitechmediaserver.conf
21 changes: 21 additions & 0 deletions openrc/logitechmediaserver.init.d
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/sbin/openrc-run
# Copyright 1999-2021 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2

description="Logitechmediaserver in a container"

depend() {
need net docker
}

start() {
ebegin "Starting Logitechmediaserver container"
/usr/bin/logitechmediaserver-docker start
eend $?
}

stop() {
ebegin "Stopping Logitechmediaserver container"
/usr/bin/logitechmediaserver-docker stop
eend $?
}

0 comments on commit 6a116d4

Please sign in to comment.