Merge pull request #53 from sparklyballs/xenial

Xenial
pull/54/head
sparklyballs 8 years ago committed by GitHub
commit fd5f6217eb

@ -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

@ -1,6 +1,6 @@
![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!
@ -24,6 +24,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
```
@ -32,11 +33,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 \
@ -58,20 +62,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.

@ -1,8 +0,0 @@
#!/bin/bash
[[ -e /var/run/dbus/pid ]] && rm -f /var/run/dbus/pid
mkdir -p /var/run/dbus
chown messagebus:messagebus /var/run/dbus
dbus-uuidgen --ensure
sleep 1

@ -1,55 +0,0 @@
#!/bin/bash
# opt out for autoupdates
[ "$ADVANCED_DISABLEUPDATES" ] && exit 0
export DEBIAN_FRONTEND=noninteractive
while ! ping -c1 tools.linuxserver.io &>/dev/null; do :; done
#The following error is not an error.
INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver)
#Get stuff from things.
PLEX_TOKEN=$( sed -n 's/.*PlexOnlineToken="//p' "/config/Library/Application Support/Plex Media Server/Preferences.xml" | sed "s/\".*//")
[ -z "$PLEX_TOKEN" ] && echo "Plex token not avalible, please login " && exit 0
[ "$PLEXPASS" ] && echo "PLEXPASS is deprecated, please use VERSION"
if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is depricated please use version latest"; fi
#Start update rutine
if [[ "$VERSION" = latest || "$VERSION" = plexpass ]]; then
VERSION=$(curl -s "https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 )
echo "Target version: $VERSION set by: latest\plexpass"
elif [[ "$VERSION" = public ]]; then
VERSION=$(curl -s "https://plex.tv/downloads/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu&X-Plex-Token="| cut -d "/" -f 5 )
echo "Target version: $VERSION set by: public"
elif [[ -z "$VERSION" ]]; then
echo "Target version: Version not set, Defaulting to supplied version"
else
echo "Target version: $VERSION set by: manually"
fi
last=130
if [[ "$VERSION" == "" ]]; then
echo "ERROR: No version found, running installed version $INSTALLED"
elif [[ "$VERSION" != "$INSTALLED" ]]; then
echo "Upgrading from version: $INSTALLED to version: $VERSION"
while [[ $last -ne "0" ]]; do
rm -f /tmp/plexmediaserver_*.deb
wget -P /tmp "https://downloads.plex.tv/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb"
last=$?
done
apt-get remove --purge -y plexmediaserver
dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb
else
echo "No need to update!"
fi
cp -v /defaults/plexmediaserver /etc/default/plexmediaserver

@ -1,11 +0,0 @@
#!/bin/bash
if [ ! -d "/config/Library" ]; then
mkdir /config/Library
chown abc:abc /config/Library
fi
if [ ! -f "/config/Library/linuxserver-chown.lock" ]; then
find /config/Library ! \( -user abc -a -group root \) -print0 | xargs -0 chown abc:root
touch /config/Library/linuxserver-chown.lock
fi

@ -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

@ -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

@ -0,0 +1,121 @@
#!/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 -s plexmediaserver > /dev/null 2>&1 ; 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

@ -0,0 +1,9 @@
#!/usr/bin/with-contenv bash
until [[ -e /var/run/dbus/system_bus_socket ]]; do
sleep 1s
done
echo "Starting Avahi daemon"
exec avahi-daemon --no-chroot

@ -1,3 +1,5 @@
#!/bin/bash
#!/usr/bin/with-contenv bash
echo "Starting dbus-daemon"
exec dbus-daemon --system --nofork

@ -0,0 +1,5 @@
#!/usr/bin/with-contenv bash
echo "Starting Plex Media Server."
exec s6-setuidgid abc /usr/sbin/start_pms

@ -1,3 +0,0 @@
#!/bin/bash
echo "Starting Avahi daemon"
exec avahi-daemon --no-chroot

@ -1,4 +0,0 @@
#!/bin/bash
echo "Starting Plex Media Server."
exec /sbin/setuser abc /usr/sbin/start_pms
Loading…
Cancel
Save