Skip to content

Commit b95261b

Browse files
authored
Merge pull request #56 from linuxserver/xenial
Rebase plex to xenial
2 parents b9224a4 + bcdcb30 commit b95261b

14 files changed

Lines changed: 253 additions & 118 deletions

File tree

Dockerfile

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,39 @@
1-
FROM linuxserver/baseimage
2-
MAINTAINER Stian Larsen <lonixx@gmail.com>
1+
FROM lsiobase/xenial
2+
MAINTAINER Stian Larsen, sparklyballs
33

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

7+
# global environment settings
8+
ENV DEBIAN_FRONTEND="noninteractive"
9+
ENV HOME="/config"
10+
ENV PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server"
1211

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

18-
# Define /config in the configuration file not using environment variables
19-
COPY plexmediaserver /defaults/plexmediaserver
20+
# install plex
21+
curl -o \
22+
/tmp/plexmediaserver.deb -L \
23+
"${PLEX_INSTALL}" && \
24+
dpkg -i /tmp/plexmediaserver.deb && \
2025

21-
#Mappings and ports
22-
VOLUME ["/config"]
26+
# cleanup
27+
apt-get clean && \
28+
rm -rf \
29+
/etc/default/plexmediaserver \
30+
/tmp/* \
31+
/var/lib/apt/lists/* \
32+
/var/tmp/*
33+
34+
# add local files
35+
COPY root/ /
36+
37+
# ports and volumes
2338
EXPOSE 32400 32400/udp 32469 32469/udp 5353/udp 1900/udp
39+
VOLUME /config /transcode

README.md

Lines changed: 43 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
11
![https://linuxserver.io](https://www.linuxserver.io/wp-content/uploads/2015/06/linuxserver_medium.png)
22

3-
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:
3+
The [LinuxServer.io](https://linuxserver.io) team brings you another container release featuring easy user mapping and community support. Find us for support at:
44
* [forum.linuxserver.io](https://forum.linuxserver.io)
55
* [IRC](https://www.linuxserver.io/index.php/irc/) on freenode at `#linuxserver.io`
66
* [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!
77

88
# linuxserver/plex
99

10-
[![](https://badge.imagelayers.io/linuxserver/plex:latest.svg)](https://imagelayers.io/?images=linuxserver/plex:latest 'Get your own badge on imagelayers.io')
10+
11+
[![Docker Pulls](https://img.shields.io/docker/pulls/linuxserver/plex.svg)][hub]
12+
[![Docker Stars](https://img.shields.io/docker/stars/linuxserver/plex.svg)][hub]
13+
[hub]: https://hub.docker.com/r/linuxserver/plex/
1114

1215
[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.
1316

14-
![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")
17+
[![plex](http://the-gadgeteer.com/wp-content/uploads/2015/10/plex-logo-e1446990678679.png)][plexurl]
18+
[plexurl]: https://plex.tv
1519

1620
## Usage
1721

@@ -24,6 +28,7 @@ docker create \
2428
-v </path/to/library>:/config \
2529
-v <path/to/tvseries>:/data/tvshows \
2630
-v </path/to/movies>:/data/movies \
31+
-v </path for transcoding>:/transcode \
2732
linuxserver/plex
2833
```
2934

@@ -32,11 +37,14 @@ docker create \
3237
* `--net=host` - Shares host networking with container, **required**.
3338
* `-v /config` - Plex library location. *This can grow very large, 50gb+ is likely for a large collection.*
3439
* `-v /data/xyz` - Media goes here. Add as many as needed e.g. `/data/movies`, `/data/tv`, etc.
35-
* `-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.
40+
* `-v /transcode` - Path for transcoding folder, *optional*.
41+
* `-e VERSION=latest` - Set whether to update plex or not - see Setting up application section.
3642
* `-e PGID=` for for GroupID - see below for explanation
3743
* `-e PUID=` for for UserID - see below for explanation
3844

39-
*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:
45+
It is based on ubuntu xenial with s6 overlay, for shell access whilst the container is running do `docker exec -it plex /bin/bash`.
46+
47+
*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:
4048

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

61-
## Updates / Monitoring
69+
## Setting up the application
70+
Webui can be found at `<your-ip>:32400/web`
71+
72+
** Note about updates, if there is no value set for the VERSION variable, then no updates will take place.**
73+
74+
** 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**
75+
76+
Valid settings for VERSION are:-
77+
78+
`IMPORTANT NOTE:- YOU CANNOT UPDATE TO A PLEXPASS ONLY VERSION IF YOU DO NOT HAVE PLEXPASS`
79+
80+
+ **`latest`**: will update plex to the latest version available that you are entitled to.
81+
+ **`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.
82+
+ **`<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.
83+
84+
## Info
6285

6386
* Shell access whilst the container is running: `docker exec -it plex /bin/bash`
64-
* Upgrade to the latest version: `docker restart plex`
6587
* To monitor the logs of the container in realtime: `docker logs -f plex`
66-
67-
## Changelog
68-
69-
+ **07.04.2016:** removed `/transcode` volume support (upstream Plex change) and modified PlexPass download method to prevent unauthorised usage of paid PMS
70-
+ **24.09.2015:** added optional support for volume transcoding (/transcode), and various typo fixes.
71-
+ **17.09.2015:** Changed to run chmod only once
72-
+ **19.09.2015:** Plex updated their download servers from http to https
73-
+ **28.08.2015:** Removed plexpass from routine, and now uses VERSION as a combination fix.
74-
+ **18.07.2015:** Moved autoupdate to be hosted by linuxserver.io and implemented bugfix thanks to ljm42.
75-
+ **09.07.2015:** Now with ability to pick static version number.
76-
+ **08.07.2015:** Now with autoupdates. (Hosted by fanart.tv)
77-
+ **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.
88+
* Upgrade to the latest version (see setting up application section) : `docker restart plex`
89+
90+
## Versions
91+
92+
+ **22.08.16:** Rebased to xenial and s6 overlay
93+
+ **07.04.16:** removed `/transcode` volume support (upstream Plex change) and modified PlexPass download method to prevent unauthorised usage of paid PMS
94+
+ **24.09.15:** added optional support for volume transcoding (/transcode), and various typo fixes.
95+
+ **17.09.15:** Changed to run chmod only once
96+
+ **19.09.15:** Plex updated their download servers from http to https
97+
+ **28.08.15:** Removed plexpass from routine, and now uses VERSION as a combination fix.
98+
+ **18.07.15:** Moved autoupdate to be hosted by linuxserver.io and implemented bugfix thanks to ljm42.
99+
+ **09.07.15:** Now with ability to pick static version number.
100+
+ **08.07.15:** Now with autoupdates. (Hosted by fanart.tv)
101+
+ **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.

init/10_dbus.sh

Lines changed: 0 additions & 8 deletions
This file was deleted.

init/30_update_plex.sh

Lines changed: 0 additions & 55 deletions
This file was deleted.

init/90_chown_plex_owned_files.sh

Lines changed: 0 additions & 11 deletions
This file was deleted.

root/etc/cont-init.d/30-dbus

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# make folders
4+
mkdir -p \
5+
/var/run/dbus
6+
7+
# delete existing pid if found
8+
[[ -e /var/run/dbus/pid ]] && \
9+
rm -f /var/run/dbus/pid
10+
11+
# permissions
12+
chown messagebus:messagebus \
13+
/var/run/dbus
14+
dbus-uuidgen --ensure
15+
sleep 1
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# check for preferences file, make lock file if not found and exit out
4+
if [ ! -e "/config/Library/Application Support/Plex Media Server/Preferences.xml" ]; then
5+
mkdir -p /config/Library
6+
touch /config/Library/linuxserver-chown.lock
7+
chown abc:abc \
8+
/config/Library
9+
chown abc:abc \
10+
/config/Library/linuxserver-chown.lock
11+
exit 0
12+
fi
13+
14+
if [ ! -f "/config/Library/linuxserver-chown.lock" ]; then
15+
echo "Possible migration from existing version detected, please be patient while we chown existing files"
16+
echo "This could take some time"
17+
chown abc:abc -R \
18+
/config/Library
19+
touch /config/Library/linuxserver-chown.lock
20+
chown abc:abc \
21+
/config/Library/linuxserver-chown.lock
22+
echo "chown operation completed"
23+
fi
Lines changed: 122 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,122 @@
1+
#!/usr/bin/with-contenv bash
2+
3+
# copy config on first run, regardless of update status
4+
[[ ! -e /etc/default/plexmediaserver ]] && \
5+
cp /defaults/plexmediaserver /etc/default/plexmediaserver
6+
7+
# test if plex is installed and try re-pulling latest if not
8+
if (dpkg --get-selections plexmediaserver | grep -wq "install"); then
9+
:
10+
else
11+
echo "for some reason plex doesn't appear to be installed, pulling a new copy and exiting out of update script"
12+
curl -o /tmp/plexmediaserver.deb -L \
13+
"${PLEX_INSTALL}" && \
14+
dpkg -i --force-confold /tmp/plexmediaserver.deb
15+
rm -f /tmp/plexmediaserver.deb
16+
exit 0
17+
fi
18+
19+
# set no update message
20+
[[ -e /tmp/no-version.nfo ]] && \
21+
rm /tmp/no-version.nfo
22+
NOVERSION_SET='/tmp/no-version.nfo'
23+
cat > "${NOVERSION_SET}" <<-EOFVERSION
24+
#######################################################
25+
# Update routine will not run because you havent set #
26+
# the VERSION variable or you opted out of updates. #
27+
# For more information checkout :- #
28+
#  https://github.com/linuxserver/docker-plex #
29+
#######################################################
30+
EOFVERSION
31+
32+
# set update failed message
33+
[[ -e /tmp/update_fail.nfo ]] && \
34+
rm /tmp/update_fail.nfo
35+
UPGRADE_FAIL='/tmp/update_fail.nfo'
36+
cat > "${UPGRADE_FAIL}" <<-EOFFAIL
37+
########################################################
38+
# Upgrade attempt failed, this could be because either #
39+
# plex update site is down, local network issues, or #
40+
# you were trying to get a version that simply doesn't #
41+
# exist, check over the VERSION variable thoroughly & #
42+
# correct it or try again later. #
43+
########################################################
44+
EOFFAIL
45+
46+
# test for no version set or opt out for autoupdates
47+
if [[ -z "$VERSION" ]] || [[ "$VERSION" == "0" ]] || [[ ! -z "$ADVANCED_DISABLEUPDATES" ]]; then
48+
printf "\n\n\n%s\n\n\n" "$(</tmp/no-version.nfo)"
49+
exit 0
50+
fi
51+
52+
# set header for no preferences/token message
53+
[[ -e /tmp/no-token.nfo ]] && \
54+
rm /tmp/no-token.nfo
55+
NOTOKEN_SET='/tmp/no-token.nfo'
56+
cat > "${NOTOKEN_SET}" <<-EOFTOKEN
57+
#####################################################
58+
# Login via the webui at http://<ip>:32400/web #
59+
# and restart the docker, because there was no #
60+
EOFTOKEN
61+
62+
# if preferences files doesn't exist, exit out
63+
if [ ! -e "/config/Library/Application Support/Plex Media Server/Preferences.xml" ]; then
64+
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
65+
# preference file found, possibly first startup. #
66+
#####################################################
67+
EOFTOKEN
68+
printf "\n\n\n%s\n\n\n" "$(</tmp/no-token.nfo)"
69+
exit 0
70+
fi
71+
72+
# attempt to read plex token
73+
PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' \
74+
"/config/Library/Application Support/Plex Media Server/Preferences.xml" \
75+
| sed "s/\".*//")
76+
77+
# if plex token isn't found, exit out
78+
if [ -z "$PLEX_TOKEN" ]; then
79+
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
80+
# plex token found in the preference file #
81+
#####################################################
82+
EOFTOKEN
83+
printf "\n\n\n%s\n\n\n" "$(</tmp/no-token.nfo)"
84+
exit 0
85+
fi
86+
87+
# determine installed version of plex
88+
INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' plexmediaserver)
89+
90+
# start update routine
91+
if [[ "$VERSION" = latest ]] || [[ "$VERSION" = plexpass ]] || [[ "$PLEXPASS" == "1" ]]; then
92+
REMOTE_VERSION=$(curl -s "${PLEX_INSTALL}&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 )
93+
elif [[ "$VERSION" = public ]]; then
94+
PLEX_TOKEN=""
95+
REMOTE_VERSION=$(curl -s "${PLEX_INSTALL}&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 )
96+
else
97+
REMOTE_VERSION="${VERSION}"
98+
fi
99+
100+
if [[ "$REMOTE_VERSION" == "$INSTALLED_VERSION" ]]; then
101+
echo "No update required"
102+
exit 0
103+
fi
104+
105+
echo "Atempting to upgrade to: $REMOTE_VERSION"
106+
rm -f /tmp/plexmediaserver_*.deb
107+
wget -nv -P /tmp \
108+
"${PLEX_DOWNLOAD}/$REMOTE_VERSION/plexmediaserver_${REMOTE_VERSION}_amd64.deb"
109+
last=$?
110+
111+
# test if deb file size is ok, or if download failed
112+
if [[ "$last" -gt "0" ]] || [[ $(stat -c %s /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb) -lt 10000 ]]; then
113+
printf "\n\n\n%s\n\n\n" "$(</tmp/update_fail.nfo)"
114+
exit 0
115+
# if ok, try to install it.
116+
else
117+
dpkg -i --force-confold /tmp/plexmediaserver_"${REMOTE_VERSION}"_amd64.deb
118+
rm -f /tmp/plexmediaserver_*.deb
119+
fi
120+
121+
# recopy config file
122+
cp /defaults/plexmediaserver /etc/default/plexmediaserver

0 commit comments

Comments
 (0)