Skip to content

Instantly share code, notes, and snippets.

@eduncan911
Last active July 6, 2023 20:06
Show Gist options
  • Save eduncan911/2489a1e012de088cd5956b78ff3db4bd to your computer and use it in GitHub Desktop.
Save eduncan911/2489a1e012de088cd5956b78ff3db4bd to your computer and use it in GitHub Desktop.
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="--insert-claim-token-here--"
TIMEZONE="America/Fort_Wayne"
PATH_TO_MEDIA_DIRECTORY="${HOME}/mnt/nfs/"
# OPTIONAL: defaults to your current path of script.
#
PATH_TO_PLEX_CONFIG_DIR="${PWD}/config"
PATH_TO_PLEX_TRANSCODE_DIR="${PWD}/cache"
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 \
--name plex \
--restart unless-stopped \
--network=host \
-e TZ="${TIMEZONE}" \
-e PLEX_CLAIM="${PLEX_CLAIM}" \
-v "/mnt/nfs:/mnt/nfs:ro" \
-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