Skip to content

Instantly share code, notes, and snippets.

@eduncan911

eduncan911/plex.sh

Created Apr 2, 2020
Embed
What would you like to do?
Plex + Docker + Updated Chromecast Ultra Config
#!/usr/bin/env bash
#
# Plex's profile for Chromecast is too conservative and only plays 1080p on
# the Chromecast Ultra UHD device (4k).
#
# This script will download an updated Chromecast definition and start a Plex
# docker container, binding a few local paths of where you run this script.
#
# You may want to refer to the Official Plex Docker repository and read the
# README text: https://github.com/plexinc/pms-docker
#
# REQUIRED:
#
# * Docker installed and started
# * Change at least the PATH_TO_MEDIA_DIRECTORY location below for your files
# * Change the PLEX_CLAIM token to be yours.
#
# USAGE:
#
# $ ./plex.sh [start|stop]
#
# REQUIRED: set these
#
PLEX_CLAIM="<get-from-https://www.plex.tv/claim>"
TIMEZONE="America/New_York"
PATH_TO_MEDIA_DIRECTORY="${HOME}/Downloads/torrents"
# OPTIONAL: it uses your local dir by default
#
PATH_TO_PLEX_CONFIG_DIR="${PWD}/config"
PATH_TO_PLEX_TRANSCODE_DIR="${PWD}/transcode"
PATH_TO_CHROMECAST_PROFILE="${PWD}/Chromecast.xml"
# OPTIONAL: lock plex media server to this docker version.
# must be prefixed with ":" colon.
#
# version list:
# https://hub.docker.com/r/plexinc/pms-docker/tags/
#
PLEX_PMS_VERSION_TO_RUN=":latest"
##########################################################
# You shouldn't need to change anything below this line. #
##########################################################
set -e
ACTION=$1
# default action is to START the docker container. we'll check if we're
# trying to stop it first. otherwise, just start it.
#
if [[ "${ACTION}" == "stop" ]]; then
echo "Gracefully shutting down Plex ..."
docker stop plex
echo "Plex has been stopped. Use './plex.sh [start] to start back up."
exit 0
fi
# download the modified chromecast.xml to use
#
if [[ ! -f "${PATH_TO_CHROMECAST_PROFILE}" ]]; then
wget https://raw.githubusercontent.com/ambroisemaupate/plex-profiles/master/Chromecast.xml -O ${PATH_TO_CHROMECAST_PROFILE}
fi
set -x
# run the docker container
docker run \
-d -it --rm \
--name plex \
--network=host \
-e TZ="${TIMEZONE}" \
-e PLEX_CLAIM="${PLEX_CLAIM}" \
-v ${PATH_TO_MEDIA_DIRECTORY}:/data \
-v ${PATH_TO_PLEX_CONFIG_DIR}:/config \
-v ${PATH_TO_PLEX_TRANSCODE_DIR}:/transcode \
-v ${PATH_TO_CHROMECAST_PROFILE}:/usr/lib/plexmediaserver/Resources/Profiles/Chromecast.xml:ro \
--device=/dev/dri:/dev/dri \
plexinc/pms-docker${PLEX_PMS_VERSION_TO_RUN}
set +x
echo "Plex is now running. Use './plex.sh stop' to gracefully shut it down."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment