mirror of
https://gh.con.sh/https://github.com/plexinc/pms-docker
synced 2024-09-20 06:45:31 +00:00
Do not install on every container start.
This commit is contained in:
parent
f247c8c414
commit
0086f00e43
10
README.md
10
README.md
|
@ -141,14 +141,14 @@ uid=1001(myuser) gid=1001(myuser) groups=1001(myuser)
|
||||||
In the above case, if you set the `PLEX_UID` and `PLEX_GID` to `1001`, then the permissions will match that of your own user.
|
In the above case, if you set the `PLEX_UID` and `PLEX_GID` to `1001`, then the permissions will match that of your own user.
|
||||||
|
|
||||||
## Tags
|
## Tags
|
||||||
In addition to the standard version and `latest` tags, there is a special `autoupdate` tag. This container behave differently than your typical containers. The `autoupdate` container does **not** have any Plex Media Server binary installed. Instead, every time this container is run, it will fetch the latest version, install it and then start the Plex Media Server.
|
In addition to the standard version and `latest` tags, there is a special `autoupdate` tag. This container behaves differently than typical containers. The `autoupdate` container does **not** have any Plex Media Server binary installed. Instead, every time this container is run, it checks to see if the server is installed. If it is (because you've already started this container before) it starts the server. If it wasn't installed (because this is the first time the server is starting) it will install it, then start the server.
|
||||||
|
|
||||||
Since containers lose their state every time they are restarted, the binary is cached in `/config/install` so it won't need to be downloaded again, but it will need to be installed every time this container starts.
|
The `autoupdate` container will automatically check for new updates every day between 4:00am - 4:30am (according to timezone set in `TZ`).
|
||||||
|
|
||||||
This container will automatically check for new updates every day between 4:00am - 4:30am (according to timezone in `TZ`).
|
|
||||||
|
|
||||||
- **AUTO_UPDATE_CHANNEL** This variable can only be `public` or `beta` (default). The `public` value restricts this check to public versions only whereas `beta` value will fetch beta versions. If the server is not logged in or you do not have Plex Pass on your account, the `beta` tagged images will be restricted to publicly available versions only.
|
- **AUTO_UPDATE_CHANNEL** This variable can only be `public` or `beta` (default). The `public` value restricts this check to public versions only whereas `beta` value will fetch beta versions. If the server is not logged in or you do not have Plex Pass on your account, the `beta` tagged images will be restricted to publicly available versions only.
|
||||||
- **FORCE_UPDATE** Set this variable to `true` in order to ignore previously cached binaries in `/config/install` upon startup. This is generally not required, but provided just-in-case. You can also manually force an update by simply deleting the `/config/install` directory.
|
|
||||||
|
### Forcing an update/install on startup
|
||||||
|
- Create an empty file called `_force_` in the `/config` directory. (i.e. `touch /config/_force_`) You can also manually force an update by simply recreating the image. Just restarting the container (or stopping and starting) will not normally update the existing installation within the container.
|
||||||
|
|
||||||
To view the Docker images head over to [https://hub.docker.com/r/plexinc/pms-docker/tags/](https://hub.docker.com/r/plexinc/pms-docker/tags/)
|
To view the Docker images head over to [https://hub.docker.com/r/plexinc/pms-docker/tags/](https://hub.docker.com/r/plexinc/pms-docker/tags/)
|
||||||
|
|
||||||
|
|
37
dev/dev.sh
37
dev/dev.sh
|
@ -6,9 +6,12 @@ IFS=$'\n\t'
|
||||||
# Assumes this is running on Linux (any distro) using (intel/amd).
|
# Assumes this is running on Linux (any distro) using (intel/amd).
|
||||||
|
|
||||||
# This bakes the specific binary into the image, you can override these vars on command line
|
# This bakes the specific binary into the image, you can override these vars on command line
|
||||||
# DOCKERHUB_IMAGE=myorg/mycontainer ./dev/sh bake
|
# prompt> DOCKERHUB_IMAGE=myorg/mycontainer ./dev/sh bake
|
||||||
VERSION_TO_BUILD=${VERSION_TO_BUILD:-"1.32.4.7195-7c8f9d3b6"}
|
VERSION_TO_BUILD=${VERSION_TO_BUILD:-"1.32.4.7195-7c8f9d3b6"}
|
||||||
DOCKERHUB_IMAGE=${DOCKERHUB_IMAGE:-"plexinc/pms-docker"}
|
DOCKERHUB_IMAGE=${DOCKERHUB_IMAGE:-"plexinc/pms-docker"}
|
||||||
|
# launch with KEEP=true to keep the container after starting/running it - manual cleanup required when done
|
||||||
|
# prompt> KEEP=true ./dev.sh debug arm64v8 autoupdate
|
||||||
|
KEEP=${KEEP:-}
|
||||||
|
|
||||||
setup() {
|
setup() {
|
||||||
# Create a multi-arch buildx builder named PlexBuilder (if it doesn't exist)
|
# Create a multi-arch buildx builder named PlexBuilder (if it doesn't exist)
|
||||||
|
@ -49,19 +52,33 @@ debug() {
|
||||||
platform=$1
|
platform=$1
|
||||||
name=$2
|
name=$2
|
||||||
autoupdate=$3
|
autoupdate=$3
|
||||||
if [ "$autoupdate" = "autoupdate" ]; then
|
[ "$autoupdate" = "autoupdate" ] && name=$name:autoupdate || name=$name:latest
|
||||||
name=$name:autoupdate
|
|
||||||
else
|
|
||||||
name=$name:latest
|
|
||||||
fi
|
|
||||||
if [[ $platform == linux/arm* ]]; then
|
if [[ $platform == linux/arm* ]]; then
|
||||||
# shellcheck disable=SC2064
|
# shellcheck disable=SC2064
|
||||||
trap "trap - SIGTERM && docker stop debug-plex" SIGINT SIGTERM EXIT
|
trap "trap - SIGTERM && docker stop debug-${name/:/_}" SIGINT SIGTERM EXIT
|
||||||
docker run --rm --name debug-plex --platform "$platform" -e DEBUG=true "$name" &
|
if [ "${KEEP,,}" = "true" ]; then
|
||||||
|
if docker start "debug-${name/:/_}"; then
|
||||||
|
docker attach "debug-${name/:/_}" &
|
||||||
|
else
|
||||||
|
docker run --name "debug-${name/:/_}" --platform "$platform" -e DEBUG=true "$name" &
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
docker run -rm --name "debug-${name/:/_}" --platform "$platform" -e DEBUG=true "$name" &
|
||||||
|
fi
|
||||||
sleep 5
|
sleep 5
|
||||||
docker exec -it debug-plex bash
|
docker exec -it "debug-${name/:/_}" bash
|
||||||
else
|
else
|
||||||
docker run --rm --name debug-plex --platform "$platform" -e DEBUG=true -it "$name" bash
|
if [ "${KEEP,,}" = "true" ]; then
|
||||||
|
if docker start "debug-${name/:/_}"; then
|
||||||
|
# shellcheck disable=SC2064
|
||||||
|
trap "trap - SIGTERM && docker stop debug-${name/:/_}" SIGINT SIGTERM EXIT
|
||||||
|
docker attach "debug-${name/:/_}"
|
||||||
|
else
|
||||||
|
docker run --name "debug-${name/:/_}" --platform "$platform" -e DEBUG=true -it "$name" bash
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
docker run -rm --name "debug-${name/:/_}" --platform "$platform" -e DEBUG=true -it "$name" bash
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,22 +5,14 @@ IFS=$'\n\t'
|
||||||
# This script is called by the autoupdate, beta, and public tags only
|
# This script is called by the autoupdate, beta, and public tags only
|
||||||
|
|
||||||
DEBUG=${DEBUG:-}
|
DEBUG=${DEBUG:-}
|
||||||
FORCE_UPDATE=${FORCE_UPDATE:-}
|
|
||||||
|
|
||||||
# If we are debugging, enable trace
|
# If we are debugging, enable trace
|
||||||
if [ "${DEBUG,,}" = "true" ]; then
|
if [ "${DEBUG,,}" = "true" ]; then
|
||||||
set -x
|
set -x
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# shellcheck source=../../plex-common.sh
|
|
||||||
. /plex-common.sh
|
|
||||||
|
|
||||||
CACHED_URL=
|
if [ -f /config/_force_ ] || ! dpkg --get-selections plexmediaserver 2> /dev/null | grep -wq "install"; then
|
||||||
[[ -r /config/install/plexmediaserver.url ]] && CACHED_URL=$(< /config/install/plexmediaserver.url)
|
|
||||||
if [ ! "${FORCE_UPDATE,,}" = "true" ] && [ -n "$CACHED_URL" ] && [ -f /config/install/plexmediaserver.deb ]; then
|
|
||||||
echo "Installing previously downloaded plex version..."
|
|
||||||
installFromRawUrl "$CACHED_URL"
|
|
||||||
else
|
|
||||||
echo "Downloading latest plex version..."
|
echo "Downloading latest plex version..."
|
||||||
exec /etc/plex/plex-update
|
exec /etc/plex/plex-update
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -38,7 +38,8 @@ else
|
||||||
# This pre-installs the specified version in TAG into this docker image.
|
# This pre-installs the specified version in TAG into this docker image.
|
||||||
remoteVersion=
|
remoteVersion=
|
||||||
remoteFile=
|
remoteFile=
|
||||||
getVersionInfo "${TAG}" "" remoteVersion remoteFile
|
remoteFileHashSha256=
|
||||||
|
getVersionInfo "${TAG}" "" remoteVersion remoteFile remoteFileHashSha256
|
||||||
|
|
||||||
if [ -z "${remoteVersion}" ] || [ -z "${remoteFile}" ]; then
|
if [ -z "${remoteVersion}" ] || [ -z "${remoteFile}" ]; then
|
||||||
echo "Could not get install version"
|
echo "Could not get install version"
|
||||||
|
@ -46,7 +47,5 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echo "Attempting to install: ${remoteVersion}"
|
echo "Attempting to install: ${remoteVersion}"
|
||||||
installFromUrl "${remoteFile}"
|
installFromUrl "${remoteFile}" "${remoteFileHashSha256}"
|
||||||
# delete unnecessary installer
|
|
||||||
rm -rf /config/install
|
|
||||||
fi
|
fi
|
||||||
|
|
|
@ -3,7 +3,6 @@ set -euo pipefail
|
||||||
IFS=$'\n\t'
|
IFS=$'\n\t'
|
||||||
|
|
||||||
PLEX_UPDATE_CHANNEL=${PLEX_UPDATE_CHANNEL:-}
|
PLEX_UPDATE_CHANNEL=${PLEX_UPDATE_CHANNEL:-}
|
||||||
FORCE_UPDATE=${FORCE_UPDATE:-}
|
|
||||||
|
|
||||||
CONT_CONF_FILE="/version.txt"
|
CONT_CONF_FILE="/version.txt"
|
||||||
|
|
||||||
|
@ -31,6 +30,7 @@ function getVersionInfo {
|
||||||
local token="$2"
|
local token="$2"
|
||||||
local -n getVersionInfo_remoteVersion=$3
|
local -n getVersionInfo_remoteVersion=$3
|
||||||
local -n getVersionInfo_remoteFile=$4
|
local -n getVersionInfo_remoteFile=$4
|
||||||
|
local -n getVersionInfo_remoteFileHashSha256=$5
|
||||||
|
|
||||||
local channel=
|
local channel=
|
||||||
local tokenNeeded=1
|
local tokenNeeded=1
|
||||||
|
@ -77,37 +77,40 @@ function installFromRawUrl {
|
||||||
local remoteFile="$1"
|
local remoteFile="$1"
|
||||||
local expectedSha256="${2:-}"
|
local expectedSha256="${2:-}"
|
||||||
|
|
||||||
# if download url matches and download is cached, then install it without download
|
rm -rf /tmp/plexmediaserver.deb
|
||||||
[[ -r /config/install/plexmediaserver.url ]] && oldurl=$(< /config/install/plexmediaserver.url)
|
if curl --create-dirs -J -L -o /tmp/plexmediaserver.deb "${remoteFile}" ; then
|
||||||
if [ ! "${FORCE_UPDATE,,}" = "true" ] && [ "$remoteFile" = "${oldurl:-}" ] && [ -f /config/install/plexmediaserver.deb ]; then
|
if [ -n "$expectedSha256" ]; then
|
||||||
|
sha256=$(sha256sum /tmp/plexmediaserver.deb | awk '{ print $1 }')
|
||||||
|
# compare sha256, if provided
|
||||||
|
if [ ! "$expectedSha256" = "$sha256" ]; then
|
||||||
|
cleanup "Download failed: sha256sum does not match: expected=$expectedSha256 actual=$sha256"
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
# no sha256, check if size appears ok
|
||||||
|
if [[ $(stat -c %s /tmp/plexmediaserver.deb) -lt 10000 ]]; then
|
||||||
|
# shellcheck disable=SC2119
|
||||||
|
cleanup "Download failed: size appears wrong"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
# looks good, move tmp into position
|
||||||
|
|
||||||
install "$remoteFile"
|
install "$remoteFile"
|
||||||
return $?
|
else
|
||||||
|
# shellcheck disable=SC2119
|
||||||
|
cleanup
|
||||||
fi
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
curl --create-dirs -J -L -o /config/install/tmp/plexmediaserver.deb "${remoteFile}"
|
function cleanup {
|
||||||
local last=$?
|
local msg="${1:-"Download failed"}"
|
||||||
local sha256;
|
rm -rf /tmp/plexmediaserver.deb
|
||||||
sha256=$(sha256sum /config/install/tmp/plexmediaserver.deb | awk '{ print $1 }')
|
echo "$msg"
|
||||||
echo "$sha256" > /config/install/tmp/plexmediaserver.sha256
|
exit 1
|
||||||
echo "$remoteFile" > /config/install/tmp/plexmediaserver.url
|
|
||||||
# test if deb file size is ok, or if download failed
|
|
||||||
if [[ "$last" -gt "0" ]] || [[ $(stat -c %s /config/install/tmp/plexmediaserver.deb) -lt 10000 ]]; then
|
|
||||||
rm -rf /config/install/tmp
|
|
||||||
echo "Failed to fetch update: curl returned $last"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
# compare sha256, if provided
|
|
||||||
if [ -n "$expectedSha256" ] && [ ! "$expectedSha256" = "$sha256" ]; then
|
|
||||||
rm -rf /config/install/tmp
|
|
||||||
echo "Failed to fetch update: sha256sum does not match: expected=$expectedSha256 actual=$sha256"
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# looks good, move tmp into position
|
|
||||||
mv /config/install/tmp/* /config/install && rm -rf /config/install/tmp
|
|
||||||
install "$remoteFile"
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function install {
|
function install {
|
||||||
dpkg -i --force-confold /config/install/plexmediaserver.deb
|
dpkg -i --force-confold /tmp/plexmediaserver.deb
|
||||||
|
rm -rf /tmp/plexmediaserver.deb
|
||||||
|
# clean up _force_ flag, if exists
|
||||||
|
rm -rf /config/_force_
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user