Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
501683a
rebase to xenial
sparklyballs Jun 30, 2016
0a89101
rebase to use lsiobase/xenial
sparklyballs Jul 1, 2016
37eab12
edit environment settings
sparklyballs Jul 1, 2016
5888cf1
working on plex update script
sparklyballs Jul 2, 2016
9033821
working on plex update script
sparklyballs Jul 2, 2016
097b6c5
use variable for initial plex install url
sparklyballs Jul 24, 2016
3d5fd85
add check line for download of plex on update
sparklyballs Jul 24, 2016
5b48540
variable for plex download location, since they have a habit of chang…
sparklyballs Aug 1, 2016
d8395b5
add transcode mapping back to the dockerfile
sparklyballs Aug 3, 2016
4373ee6
update readme with transcode folder
sparklyballs Aug 3, 2016
827a922
less is more, or not as is the case
sparklyballs Aug 22, 2016
c90bb62
fix copy pasta error
sparklyballs Aug 22, 2016
1ed5257
more tidying
sparklyballs Aug 22, 2016
e92f5b1
add message box outline for no updates set
sparklyballs Aug 22, 2016
49591fc
move plex chown operation, and change test for it
sparklyballs Aug 22, 2016
09ee572
more and more updates
sparklyballs Aug 22, 2016
cf0daf1
reformat markdown on README
sparklyballs Aug 22, 2016
5f48db7
reformat markdown on README
sparklyballs Aug 22, 2016
c7b5488
edits to README
sparklyballs Aug 22, 2016
9bf362c
reformat markdown on README
sparklyballs Aug 22, 2016
cbb2c00
edits to README
sparklyballs Aug 22, 2016
f1cdb88
tone down the commas in README
sparklyballs Aug 22, 2016
6dc05aa
refined update script, not tested the logic fully yet
sparklyballs Aug 22, 2016
da12aa2
improve logic on test for no update
sparklyballs Aug 22, 2016
78f96a9
still working on update script
sparklyballs Aug 22, 2016
5db417d
save up for prosperity, no comment on completion or viability, just a…
sparklyballs Aug 22, 2016
d8e00e7
tweak the printf in update
sparklyballs Aug 22, 2016
3233217
correct README
sparklyballs Aug 23, 2016
b34d77d
refine update script, attempt at better error control
sparklyballs Aug 23, 2016
1d6831d
haven't quite sorted out better download error handling
sparklyballs Aug 23, 2016
892c17b
correcting locations, would be just bloody dandy if plex had some sem…
sparklyballs Aug 23, 2016
b1b4525
real belt and braches stuff here, trying to cover every possible base…
sparklyballs Aug 23, 2016
77f0ea6
real belt and braches stuff here, trying to cover every possible base…
sparklyballs Aug 23, 2016
960aa1d
move test for plex installed to top of update script, change dpkg opt…
sparklyballs Aug 23, 2016
fd5f621
Merge pull request #53 from sparklyballs/xenial
sparklyballs Aug 23, 2016
7fd2f7f
better test for package installed or not.
sparklyballs Aug 23, 2016
450947d
Update README.md
sparklyballs Aug 27, 2016
4d171be
Update README.md
sparklyballs Aug 27, 2016
83b1303
Update README.md
sparklyballs Aug 27, 2016
a0435fe
Update
sparklyballs Aug 27, 2016
bcdcb30
Update README.md
sparklyballs Aug 27, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
50 changes: 33 additions & 17 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,23 +1,39 @@
FROM linuxserver/baseimage
MAINTAINER Stian Larsen <lonixx@gmail.com>
FROM lsiobase/xenial
MAINTAINER Stian Larsen, sparklyballs

# Install Plex
RUN apt-get -q update && \
apt-get install -qy dbus avahi-daemon wget && \
curl -L 'https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu' -o /tmp/plexmediaserver.deb && \
dpkg -i /tmp/plexmediaserver.deb && rm -f /tmp/plexmediaserver.deb && \
apt-get clean && \
rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
# package version
ENV PLEX_INSTALL="https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu"

# global environment settings
ENV DEBIAN_FRONTEND="noninteractive"
ENV HOME="/config"
ENV PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server"

#Adding Custom files
COPY init/ /etc/my_init.d/
COPY services/ /etc/service/
RUN chmod -v +x /etc/service/*/run /etc/my_init.d/*.sh
# install packages
RUN \
apt-get update && \
apt-get install -y \
avahi-daemon \
dbus \
wget && \

# Define /config in the configuration file not using environment variables
COPY plexmediaserver /defaults/plexmediaserver
# install plex
curl -o \
/tmp/plexmediaserver.deb -L \
"${PLEX_INSTALL}" && \
dpkg -i /tmp/plexmediaserver.deb && \

#Mappings and ports
VOLUME ["/config"]
# cleanup
apt-get clean && \
rm -rf \
/etc/default/plexmediaserver \
/tmp/* \
/var/lib/apt/lists/* \
/var/tmp/*

# add local files
COPY root/ /

# ports and volumes
EXPOSE 32400 32400/udp 32469 32469/udp 5353/udp 1900/udp
VOLUME /config /transcode
62 changes: 43 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
![https://linuxserver.io](https://www.linuxserver.io/wp-content/uploads/2015/06/linuxserver_medium.png)

The [LinuxServer.io](https://linuxserver.io) team brings you another container release featuring auto-update on startup, easy user mapping and community support. Find us for support at:
The [LinuxServer.io](https://linuxserver.io) team brings you another container release featuring easy user mapping and community support. Find us for support at:
* [forum.linuxserver.io](https://forum.linuxserver.io)
* [IRC](https://www.linuxserver.io/index.php/irc/) on freenode at `#linuxserver.io`
* [Podcast](https://www.linuxserver.io/index.php/category/podcast/) covers everything to do with getting the most from your Linux Server plus a focus on all things Docker and containerisation!

# linuxserver/plex

[![](https://badge.imagelayers.io/linuxserver/plex:latest.svg)](https://imagelayers.io/?images=linuxserver/plex:latest 'Get your own badge on imagelayers.io')

[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/plex.svg)][hub]
[![Docker Stars](https://img.shields.io/docker/stars/linuxserver/plex.svg)][hub]
[hub]: https://hub.docker.com/r/linuxserver/plex/

[Plex](https://plex.tv/) organizes video, music and photos from personal media libraries and streams them to smart TVs, streaming boxes and mobile devices. This container is packaged as a standalone Plex Media Server.

![https://plex.tv](http://i2.wp.com/moonbooks.net/wp-content/uploads/2014/12/plex-logo-dark-small-77202045f47146129647bee8b1cac77c.png?resize=770%2C250 "Plex logo")
[![plex](http://the-gadgeteer.com/wp-content/uploads/2015/10/plex-logo-e1446990678679.png)][plexurl]
[plexurl]: https://plex.tv

## Usage

Expand All @@ -24,6 +28,7 @@ docker create \
-v </path/to/library>:/config \
-v <path/to/tvseries>:/data/tvshows \
-v </path/to/movies>:/data/movies \
-v </path for transcoding>:/transcode \
linuxserver/plex
```

Expand All @@ -32,11 +37,14 @@ docker create \
* `--net=host` - Shares host networking with container, **required**.
* `-v /config` - Plex library location. *This can grow very large, 50gb+ is likely for a large collection.*
* `-v /data/xyz` - Media goes here. Add as many as needed e.g. `/data/movies`, `/data/tv`, etc.
* `-e VERSION=latest` - Permits specific version selection e.g. `0.9.12.4.1192-9a47d21`, also supports `public` (this forces plex so stick with ). If left blank, auto update is disabled until set.
* `-v /transcode` - Path for transcoding folder, *optional*.
* `-e VERSION=latest` - Set whether to update plex or not - see Setting up application section.
* `-e PGID=` for for GroupID - see below for explanation
* `-e PUID=` for for UserID - see below for explanation

*Special note* - If you'd like to run Plex without requiring `--net=host` then you will need the following ports in your `docker create` command:
It is based on ubuntu xenial with s6 overlay, for shell access whilst the container is running do `docker exec -it plex /bin/bash`.

*Special note* - If you'd like to run Plex without requiring `--net=host` (not recommended) then you will need the following ports in your `docker create` command:

```
-p 32400:32400 \
Expand All @@ -58,20 +66,36 @@ In this instance `PUID=1001` and `PGID=1001`. To find yours use `id user` as bel
uid=1001(dockeruser) gid=1001(dockergroup) groups=1001(dockergroup)
```

## Updates / Monitoring
## Setting up the application
Webui can be found at `<your-ip>:32400/web`

** Note about updates, if there is no value set for the VERSION variable, then no updates will take place.**

** For new users, no updates will take place on the first run of the container as there is no preferences file to read your token from, to update restart the docker after logging in through the webui**

Valid settings for VERSION are:-

`IMPORTANT NOTE:- YOU CANNOT UPDATE TO A PLEXPASS ONLY VERSION IF YOU DO NOT HAVE PLEXPASS`

+ **`latest`**: will update plex to the latest version available that you are entitled to.
+ **`public`**: will update plexpass users to the latest public version, useful for plexpass users that don't want to be on the bleeding edge but still want the latest public updates.
+ **`<specific-version>`**: will select a specific version (eg 0.9.12.4.1192-9a47d21) of plex to install, note you cannot use this to access plexpass versions if you do not have plexpass.

## Info

* Shell access whilst the container is running: `docker exec -it plex /bin/bash`
* Upgrade to the latest version: `docker restart plex`
* To monitor the logs of the container in realtime: `docker logs -f plex`

## Changelog

+ **07.04.2016:** removed `/transcode` volume support (upstream Plex change) and modified PlexPass download method to prevent unauthorised usage of paid PMS
+ **24.09.2015:** added optional support for volume transcoding (/transcode), and various typo fixes.
+ **17.09.2015:** Changed to run chmod only once
+ **19.09.2015:** Plex updated their download servers from http to https
+ **28.08.2015:** Removed plexpass from routine, and now uses VERSION as a combination fix.
+ **18.07.2015:** Moved autoupdate to be hosted by linuxserver.io and implemented bugfix thanks to ljm42.
+ **09.07.2015:** Now with ability to pick static version number.
+ **08.07.2015:** Now with autoupdates. (Hosted by fanart.tv)
+ **03.07.2015:** Fixed a mistake that allowed plex to run as user plex rather than abc (99:100). Thanks to double16 for spotting this.
* Upgrade to the latest version (see setting up application section) : `docker restart plex`

## Versions

+ **22.08.16:** Rebased to xenial and s6 overlay
+ **07.04.16:** removed `/transcode` volume support (upstream Plex change) and modified PlexPass download method to prevent unauthorised usage of paid PMS
+ **24.09.15:** added optional support for volume transcoding (/transcode), and various typo fixes.
+ **17.09.15:** Changed to run chmod only once
+ **19.09.15:** Plex updated their download servers from http to https
+ **28.08.15:** Removed plexpass from routine, and now uses VERSION as a combination fix.
+ **18.07.15:** Moved autoupdate to be hosted by linuxserver.io and implemented bugfix thanks to ljm42.
+ **09.07.15:** Now with ability to pick static version number.
+ **08.07.15:** Now with autoupdates. (Hosted by fanart.tv)
+ **03.07.15:** Fixed a mistake that allowed plex to run as user plex rather than abc (99:100). Thanks to double16 for spotting this.
8 changes: 0 additions & 8 deletions init/10_dbus.sh

This file was deleted.

55 changes: 0 additions & 55 deletions init/30_update_plex.sh

This file was deleted.

11 changes: 0 additions & 11 deletions init/90_chown_plex_owned_files.sh

This file was deleted.

File renamed without changes.
15 changes: 15 additions & 0 deletions root/etc/cont-init.d/30-dbus
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
#!/usr/bin/with-contenv bash

# make folders
mkdir -p \
/var/run/dbus

# delete existing pid if found
[[ -e /var/run/dbus/pid ]] && \
rm -f /var/run/dbus/pid

# permissions
chown messagebus:messagebus \
/var/run/dbus
dbus-uuidgen --ensure
sleep 1
23 changes: 23 additions & 0 deletions root/etc/cont-init.d/40-chown-files
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/usr/bin/with-contenv bash

# check for preferences file, make lock file if not found and exit out
if [ ! -e "/config/Library/Application Support/Plex Media Server/Preferences.xml" ]; then
mkdir -p /config/Library
touch /config/Library/linuxserver-chown.lock
chown abc:abc \
/config/Library
chown abc:abc \
/config/Library/linuxserver-chown.lock
exit 0
fi

if [ ! -f "/config/Library/linuxserver-chown.lock" ]; then
echo "Possible migration from existing version detected, please be patient while we chown existing files"
echo "This could take some time"
chown abc:abc -R \
/config/Library
touch /config/Library/linuxserver-chown.lock
chown abc:abc \
/config/Library/linuxserver-chown.lock
echo "chown operation completed"
fi
122 changes: 122 additions & 0 deletions root/etc/cont-init.d/50-plex-update
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/usr/bin/with-contenv bash

# copy config on first run, regardless of update status
[[ ! -e /etc/default/plexmediaserver ]] && \
cp /defaults/plexmediaserver /etc/default/plexmediaserver

# test if plex is installed and try re-pulling latest if not
if (dpkg --get-selections plexmediaserver | grep -wq "install"); then
:
else
echo "for some reason plex doesn't appear to be installed, pulling a new copy and exiting out of update script"
curl -o /tmp/plexmediaserver.deb -L \
"${PLEX_INSTALL}" && \
dpkg -i --force-confold /tmp/plexmediaserver.deb
rm -f /tmp/plexmediaserver.deb
exit 0
fi

# set no update message
[[ -e /tmp/no-version.nfo ]] && \
rm /tmp/no-version.nfo
NOVERSION_SET='/tmp/no-version.nfo'
cat > "${NOVERSION_SET}" <<-EOFVERSION
#######################################################
# Update routine will not run because you havent set #
# the VERSION variable or you opted out of updates. #
# For more information checkout :- #
#  https://github.com/linuxserver/docker-plex #
#######################################################
EOFVERSION

# set update failed message
[[ -e /tmp/update_fail.nfo ]] && \
rm /tmp/update_fail.nfo
UPGRADE_FAIL='/tmp/update_fail.nfo'
cat > "${UPGRADE_FAIL}" <<-EOFFAIL
########################################################
# Upgrade attempt failed, this could be because either #
# plex update site is down, local network issues, or #
# you were trying to get a version that simply doesn't #
# exist, check over the VERSION variable thoroughly & #
# correct it or try again later. #
########################################################
EOFFAIL

# test for no version set or opt out for autoupdates
if [[ -z "$VERSION" ]] || [[ "$VERSION" == "0" ]] || [[ ! -z "$ADVANCED_DISABLEUPDATES" ]]; then
printf "\n\n\n%s\n\n\n" "$(</tmp/no-version.nfo)"
exit 0
fi

# set header for no preferences/token message
[[ -e /tmp/no-token.nfo ]] && \
rm /tmp/no-token.nfo
NOTOKEN_SET='/tmp/no-token.nfo'
cat > "${NOTOKEN_SET}" <<-EOFTOKEN
#####################################################
# Login via the webui at http://<ip>:32400/web #
# and restart the docker, because there was no #
EOFTOKEN

# if preferences files doesn't exist, exit out
if [ ! -e "/config/Library/Application Support/Plex Media Server/Preferences.xml" ]; then
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
# preference file found, possibly first startup. #
#####################################################
EOFTOKEN
printf "\n\n\n%s\n\n\n" "$(</tmp/no-token.nfo)"
exit 0
fi

# attempt to read plex token
PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' \
"/config/Library/Application Support/Plex Media Server/Preferences.xml" \
| sed "s/\".*//")

# if plex token isn't found, exit out
if [ -z "$PLEX_TOKEN" ]; then
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
# plex token found in the preference file #
#####################################################
EOFTOKEN
printf "\n\n\n%s\n\n\n" "$(</tmp/no-token.nfo)"
exit 0
fi

# determine installed version of plex
INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' plexmediaserver)

# start update routine
if [[ "$VERSION" = latest ]] || [[ "$VERSION" = plexpass ]] || [[ "$PLEXPASS" == "1" ]]; then
REMOTE_VERSION=$(curl -s "${PLEX_INSTALL}&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 )
elif [[ "$VERSION" = public ]]; then
PLEX_TOKEN=""
REMOTE_VERSION=$(curl -s "${PLEX_INSTALL}&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 )
else
REMOTE_VERSION="${VERSION}"
fi

if [[ "$REMOTE_VERSION" == "$INSTALLED_VERSION" ]]; then
echo "No update required"
exit 0
fi

echo "Atempting to upgrade to: $REMOTE_VERSION"
rm -f /tmp/plexmediaserver_*.deb
wget -nv -P /tmp \
"${PLEX_DOWNLOAD}/$REMOTE_VERSION/plexmediaserver_${REMOTE_VERSION}_amd64.deb"
last=$?

# test if deb file size is ok, or if download failed
if [[ "$last" -gt "0" ]] || [[ $(stat -c %s /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb) -lt 10000 ]]; then
printf "\n\n\n%s\n\n\n" "$(</tmp/update_fail.nfo)"
exit 0
# if ok, try to install it.
else
dpkg -i --force-confold /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb
rm -f /tmp/plexmediaserver_*.deb
fi

# recopy config file
cp /defaults/plexmediaserver /etc/default/plexmediaserver
Loading