update formatting
This commit is contained in:
parent
1506ab2011
commit
f2325f30fe
7 changed files with 221 additions and 227 deletions
80
Dockerfile
80
Dockerfile
|
|
@ -12,48 +12,48 @@ ENV NVIDIA_DRIVER_CAPABILITIES="compute,video,utility"
|
|||
|
||||
# global environment settings
|
||||
ENV DEBIAN_FRONTEND="noninteractive" \
|
||||
PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server-new" \
|
||||
PLEX_ARCH="amd64" \
|
||||
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \
|
||||
PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \
|
||||
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \
|
||||
PLEX_MEDIA_SERVER_USER="abc" \
|
||||
PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" \
|
||||
PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (LinuxServer.io)"
|
||||
PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server-new" \
|
||||
PLEX_ARCH="amd64" \
|
||||
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \
|
||||
PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \
|
||||
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \
|
||||
PLEX_MEDIA_SERVER_USER="abc" \
|
||||
PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" \
|
||||
PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (LinuxServer.io)"
|
||||
|
||||
RUN \
|
||||
echo "**** add Intel repo ****" && \
|
||||
curl -sL https://repositories.intel.com/graphics/intel-graphics.key | apt-key add - && \
|
||||
echo 'deb [arch=amd64] https://repositories.intel.com/graphics/ubuntu focal main' > /etc/apt/sources.list.d/intel.list && \
|
||||
echo "**** install runtime packages ****" && \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
jq \
|
||||
intel-igc-cm=1.0.128+i699.3~u20.04 \
|
||||
intel-opencl-icd=21.49.21786+i643~u20.04 \
|
||||
libigdfcl1=1.0.10409+i699.3~u20.04 \
|
||||
libigdgmm11=21.3.3+i643~u20.04 \
|
||||
udev \
|
||||
unrar \
|
||||
wget && \
|
||||
echo "**** install plex ****" && \
|
||||
if [ -z ${PLEX_RELEASE+x} ]; then \
|
||||
PLEX_RELEASE=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' \
|
||||
| jq -r '.computer.Linux.version'); \
|
||||
fi && \
|
||||
curl -o \
|
||||
/tmp/plexmediaserver.deb -L \
|
||||
"${PLEX_DOWNLOAD}/${PLEX_RELEASE}/debian/plexmediaserver_${PLEX_RELEASE}_${PLEX_ARCH}.deb" && \
|
||||
dpkg -i /tmp/plexmediaserver.deb && \
|
||||
echo "**** ensure abc user's home folder is /app ****" && \
|
||||
usermod -d /app abc && \
|
||||
echo "**** cleanup ****" && \
|
||||
apt-get clean && \
|
||||
rm -rf \
|
||||
/etc/default/plexmediaserver \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
echo "**** add Intel repo ****" && \
|
||||
curl -sL https://repositories.intel.com/graphics/intel-graphics.key | apt-key add - && \
|
||||
echo 'deb [arch=amd64] https://repositories.intel.com/graphics/ubuntu focal main' > /etc/apt/sources.list.d/intel.list && \
|
||||
echo "**** install runtime packages ****" && \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
jq \
|
||||
intel-igc-cm=1.0.128+i699.3~u20.04 \
|
||||
intel-opencl-icd=21.49.21786+i643~u20.04 \
|
||||
libigdfcl1=1.0.10409+i699.3~u20.04 \
|
||||
libigdgmm11=21.3.3+i643~u20.04 \
|
||||
udev \
|
||||
unrar \
|
||||
wget && \
|
||||
echo "**** install plex ****" && \
|
||||
if [ -z ${PLEX_RELEASE+x} ]; then \
|
||||
PLEX_RELEASE=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' \
|
||||
| jq -r '.computer.Linux.version'); \
|
||||
fi && \
|
||||
curl -o \
|
||||
/tmp/plexmediaserver.deb -L \
|
||||
"${PLEX_DOWNLOAD}/${PLEX_RELEASE}/debian/plexmediaserver_${PLEX_RELEASE}_${PLEX_ARCH}.deb" && \
|
||||
dpkg -i /tmp/plexmediaserver.deb && \
|
||||
echo "**** ensure abc user's home folder is /app ****" && \
|
||||
usermod -d /app abc && \
|
||||
echo "**** cleanup ****" && \
|
||||
apt-get clean && \
|
||||
rm -rf \
|
||||
/etc/default/plexmediaserver \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
|
||||
# add local files
|
||||
COPY root/ /
|
||||
|
|
|
|||
|
|
@ -9,41 +9,41 @@ LABEL maintainer="thelamer"
|
|||
|
||||
# global environment settings
|
||||
ENV DEBIAN_FRONTEND="noninteractive" \
|
||||
PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server-new" \
|
||||
PLEX_ARCH="arm64" \
|
||||
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \
|
||||
PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \
|
||||
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \
|
||||
PLEX_MEDIA_SERVER_USER="abc" \
|
||||
PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" \
|
||||
PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (LinuxServer.io)"
|
||||
PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server-new" \
|
||||
PLEX_ARCH="arm64" \
|
||||
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \
|
||||
PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \
|
||||
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \
|
||||
PLEX_MEDIA_SERVER_USER="abc" \
|
||||
PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" \
|
||||
PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (LinuxServer.io)"
|
||||
|
||||
RUN \
|
||||
echo "**** install runtime packages ****" && \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
jq \
|
||||
udev \
|
||||
unrar \
|
||||
wget && \
|
||||
echo "**** install plex ****" && \
|
||||
if [ -z ${PLEX_RELEASE+x} ]; then \
|
||||
PLEX_RELEASE=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' \
|
||||
| jq -r '.computer.Linux.version'); \
|
||||
fi && \
|
||||
curl -o \
|
||||
/tmp/plexmediaserver.deb -L \
|
||||
"${PLEX_DOWNLOAD}/${PLEX_RELEASE}/debian/plexmediaserver_${PLEX_RELEASE}_${PLEX_ARCH}.deb" && \
|
||||
dpkg -i /tmp/plexmediaserver.deb && \
|
||||
echo "**** ensure abc user's home folder is /app ****" && \
|
||||
usermod -d /app abc && \
|
||||
echo "**** cleanup ****" && \
|
||||
apt-get clean && \
|
||||
rm -rf \
|
||||
/etc/default/plexmediaserver \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
echo "**** install runtime packages ****" && \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
jq \
|
||||
udev \
|
||||
unrar \
|
||||
wget && \
|
||||
echo "**** install plex ****" && \
|
||||
if [ -z ${PLEX_RELEASE+x} ]; then \
|
||||
PLEX_RELEASE=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' \
|
||||
| jq -r '.computer.Linux.version'); \
|
||||
fi && \
|
||||
curl -o \
|
||||
/tmp/plexmediaserver.deb -L \
|
||||
"${PLEX_DOWNLOAD}/${PLEX_RELEASE}/debian/plexmediaserver_${PLEX_RELEASE}_${PLEX_ARCH}.deb" && \
|
||||
dpkg -i /tmp/plexmediaserver.deb && \
|
||||
echo "**** ensure abc user's home folder is /app ****" && \
|
||||
usermod -d /app abc && \
|
||||
echo "**** cleanup ****" && \
|
||||
apt-get clean && \
|
||||
rm -rf \
|
||||
/etc/default/plexmediaserver \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
|
||||
# add local files
|
||||
COPY root/ /
|
||||
|
|
|
|||
|
|
@ -9,41 +9,41 @@ LABEL maintainer="thelamer"
|
|||
|
||||
# global environment settings
|
||||
ENV DEBIAN_FRONTEND="noninteractive" \
|
||||
PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server-new" \
|
||||
PLEX_ARCH="armhf" \
|
||||
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \
|
||||
PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \
|
||||
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \
|
||||
PLEX_MEDIA_SERVER_USER="abc" \
|
||||
PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" \
|
||||
PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (LinuxServer.io)"
|
||||
PLEX_DOWNLOAD="https://downloads.plex.tv/plex-media-server-new" \
|
||||
PLEX_ARCH="armhf" \
|
||||
PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR="/config/Library/Application Support" \
|
||||
PLEX_MEDIA_SERVER_HOME="/usr/lib/plexmediaserver" \
|
||||
PLEX_MEDIA_SERVER_MAX_PLUGIN_PROCS="6" \
|
||||
PLEX_MEDIA_SERVER_USER="abc" \
|
||||
PLEX_MEDIA_SERVER_INFO_VENDOR="Docker" \
|
||||
PLEX_MEDIA_SERVER_INFO_DEVICE="Docker Container (LinuxServer.io)"
|
||||
|
||||
RUN \
|
||||
echo "**** install runtime packages ****" && \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
jq \
|
||||
udev \
|
||||
unrar \
|
||||
wget && \
|
||||
echo "**** install plex ****" && \
|
||||
if [ -z ${PLEX_RELEASE+x} ]; then \
|
||||
PLEX_RELEASE=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' \
|
||||
| jq -r '.computer.Linux.version'); \
|
||||
fi && \
|
||||
curl -o \
|
||||
/tmp/plexmediaserver.deb -L \
|
||||
"${PLEX_DOWNLOAD}/${PLEX_RELEASE}/debian/plexmediaserver_${PLEX_RELEASE}_${PLEX_ARCH}.deb" && \
|
||||
dpkg -i /tmp/plexmediaserver.deb && \
|
||||
echo "**** ensure abc user's home folder is /app ****" && \
|
||||
usermod -d /app abc && \
|
||||
echo "**** cleanup ****" && \
|
||||
apt-get clean && \
|
||||
rm -rf \
|
||||
/etc/default/plexmediaserver \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
echo "**** install runtime packages ****" && \
|
||||
apt-get update && \
|
||||
apt-get install -y \
|
||||
jq \
|
||||
udev \
|
||||
unrar \
|
||||
wget && \
|
||||
echo "**** install plex ****" && \
|
||||
if [ -z ${PLEX_RELEASE+x} ]; then \
|
||||
PLEX_RELEASE=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' \
|
||||
| jq -r '.computer.Linux.version'); \
|
||||
fi && \
|
||||
curl -o \
|
||||
/tmp/plexmediaserver.deb -L \
|
||||
"${PLEX_DOWNLOAD}/${PLEX_RELEASE}/debian/plexmediaserver_${PLEX_RELEASE}_${PLEX_ARCH}.deb" && \
|
||||
dpkg -i /tmp/plexmediaserver.deb && \
|
||||
echo "**** ensure abc user's home folder is /app ****" && \
|
||||
usermod -d /app abc && \
|
||||
echo "**** cleanup ****" && \
|
||||
apt-get clean && \
|
||||
rm -rf \
|
||||
/etc/default/plexmediaserver \
|
||||
/tmp/* \
|
||||
/var/lib/apt/lists/* \
|
||||
/var/tmp/*
|
||||
|
||||
# add local files
|
||||
COPY root/ /
|
||||
|
|
|
|||
|
|
@ -2,24 +2,24 @@
|
|||
|
||||
# create folders
|
||||
if [ ! -d "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}" ]; then \
|
||||
mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}"
|
||||
chown -R abc:abc /config
|
||||
mkdir -p "${PLEX_MEDIA_SERVER_APPLICATION_SUPPORT_DIR}"
|
||||
chown -R abc:abc /config
|
||||
fi
|
||||
|
||||
# check Library permissions
|
||||
PUID=${PUID:-911}
|
||||
if [ ! "$(stat -c %u /config/Library)" = "$PUID" ]; then
|
||||
echo "Change in ownership detected, please be patient while we chown existing files"
|
||||
echo "This could take some time"
|
||||
chown abc:abc -R \
|
||||
/config/Library
|
||||
echo "Change in ownership detected, please be patient while we chown existing files"
|
||||
echo "This could take some time"
|
||||
chown abc:abc -R \
|
||||
/config/Library
|
||||
fi
|
||||
|
||||
# remove plex pid after unclean stop
|
||||
[[ -f "/config/Library/Application Support/Plex Media Server/plexmediaserver.pid" ]] && \
|
||||
rm -f "/config/Library/Application Support/Plex Media Server/plexmediaserver.pid"
|
||||
rm -f "/config/Library/Application Support/Plex Media Server/plexmediaserver.pid"
|
||||
|
||||
# permissions (non-recursive) on config root and folders
|
||||
chown abc:abc \
|
||||
/config \
|
||||
/config/*
|
||||
/config \
|
||||
/config/*
|
||||
|
|
|
|||
|
|
@ -1,79 +1,79 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
if grep -qs "PlexOnlineToken" "/config/Library/Application Support/Plex Media Server/Preferences.xml" || [ -z "$PLEX_CLAIM" ]; then
|
||||
exit 0
|
||||
exit 0
|
||||
fi
|
||||
PREFNAME="/config/Library/Application Support/Plex Media Server/Preferences.xml"
|
||||
if [ ! -f "${PREFNAME}" ]; then
|
||||
UMASK_SET="${UMASK_SET:-022}"
|
||||
umask "$UMASK_SET"
|
||||
echo "Temporarily starting Plex Media Server."
|
||||
export PLEX_MEDIA_SERVER_INFO_MODEL=$(uname -m)
|
||||
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION=$(uname -r)
|
||||
s6-setuidgid abc /bin/bash -c \
|
||||
'LD_LIBRARY_PATH=/usr/lib/plexmediaserver:/usr/lib/plexmediaserver/lib /usr/lib/plexmediaserver/Plex\ Media\ Server' & PID=$!
|
||||
echo "Waiting for Plex to generate its config"
|
||||
DBNAME="/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db-wal"
|
||||
until [ -f "${DBNAME}" ]; do
|
||||
sleep 1
|
||||
done
|
||||
while true; do
|
||||
echo "Waiting for database creation to complete..."
|
||||
if [ -z "${COMPARE_MD5+x}" ]; then
|
||||
COMPARE_MD5=$(md5sum "${DBNAME}"| cut -c1-8)
|
||||
sleep 3
|
||||
else
|
||||
sleep 3
|
||||
CURRENT_MD5=$(md5sum "${DBNAME}"| cut -c1-8)
|
||||
if [ "${CURRENT_MD5}" == "${COMPARE_MD5}" ]; then
|
||||
break
|
||||
else
|
||||
COMPARE_MD5=$(md5sum "${DBNAME}"| cut -c1-8)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
until grep -qs "ProcessedMachineIdentifier" "${PREFNAME}"; do
|
||||
sleep 1
|
||||
done
|
||||
while true; do
|
||||
echo "Waiting for pref file creation to complete..."
|
||||
if [ -z "${PREF_COMPARE_MD5+x}" ]; then
|
||||
PREF_COMPARE_MD5=$(md5sum "${PREFNAME}"| cut -c1-8)
|
||||
sleep 3
|
||||
else
|
||||
sleep 3
|
||||
PREF_CURRENT_MD5=$(md5sum "${PREFNAME}"| cut -c1-8)
|
||||
if [ "${PREF_CURRENT_MD5}" == "${PREF_COMPARE_MD5}" ]; then
|
||||
break
|
||||
else
|
||||
PREF_COMPARE_MD5=$(md5sum "${PREFNAME}"| cut -c1-8)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "Stopping Plex to claim server"
|
||||
while ps -p $PID > /dev/null; do
|
||||
kill $PID
|
||||
sleep 1
|
||||
done
|
||||
echo "Plex stopped"
|
||||
UMASK_SET="${UMASK_SET:-022}"
|
||||
umask "$UMASK_SET"
|
||||
echo "Temporarily starting Plex Media Server."
|
||||
export PLEX_MEDIA_SERVER_INFO_MODEL=$(uname -m)
|
||||
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION=$(uname -r)
|
||||
s6-setuidgid abc /bin/bash -c \
|
||||
'LD_LIBRARY_PATH=/usr/lib/plexmediaserver:/usr/lib/plexmediaserver/lib /usr/lib/plexmediaserver/Plex\ Media\ Server' & PID=$!
|
||||
echo "Waiting for Plex to generate its config"
|
||||
DBNAME="/config/Library/Application Support/Plex Media Server/Plug-in Support/Databases/com.plexapp.plugins.library.db-wal"
|
||||
until [ -f "${DBNAME}" ]; do
|
||||
sleep 1
|
||||
done
|
||||
while true; do
|
||||
echo "Waiting for database creation to complete..."
|
||||
if [ -z "${COMPARE_MD5+x}" ]; then
|
||||
COMPARE_MD5=$(md5sum "${DBNAME}"| cut -c1-8)
|
||||
sleep 3
|
||||
else
|
||||
sleep 3
|
||||
CURRENT_MD5=$(md5sum "${DBNAME}"| cut -c1-8)
|
||||
if [ "${CURRENT_MD5}" == "${COMPARE_MD5}" ]; then
|
||||
break
|
||||
else
|
||||
COMPARE_MD5=$(md5sum "${DBNAME}"| cut -c1-8)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
until grep -qs "ProcessedMachineIdentifier" "${PREFNAME}"; do
|
||||
sleep 1
|
||||
done
|
||||
while true; do
|
||||
echo "Waiting for pref file creation to complete..."
|
||||
if [ -z "${PREF_COMPARE_MD5+x}" ]; then
|
||||
PREF_COMPARE_MD5=$(md5sum "${PREFNAME}"| cut -c1-8)
|
||||
sleep 3
|
||||
else
|
||||
sleep 3
|
||||
PREF_CURRENT_MD5=$(md5sum "${PREFNAME}"| cut -c1-8)
|
||||
if [ "${PREF_CURRENT_MD5}" == "${PREF_COMPARE_MD5}" ]; then
|
||||
break
|
||||
else
|
||||
PREF_COMPARE_MD5=$(md5sum "${PREFNAME}"| cut -c1-8)
|
||||
fi
|
||||
fi
|
||||
done
|
||||
echo "Stopping Plex to claim server"
|
||||
while ps -p $PID > /dev/null; do
|
||||
kill $PID
|
||||
sleep 1
|
||||
done
|
||||
echo "Plex stopped"
|
||||
fi
|
||||
|
||||
ProcessedMachineIdentifier=$(sed -n "s/^.*ProcessedMachineIdentifier=\"\([^\"]*\)\".*$/\1/p" "${PREFNAME}")
|
||||
PlexOnlineToken="$(curl -X POST \
|
||||
-H 'X-Plex-Client-Identifier: '"${ProcessedMachineIdentifier}" \
|
||||
-H 'X-Plex-Product: Plex Media Server'\
|
||||
-H 'X-Plex-Version: 1.1' \
|
||||
-H 'X-Plex-Provides: server' \
|
||||
-H 'X-Plex-Platform: Linux' \
|
||||
-H 'X-Plex-Platform-Version: 1.0' \
|
||||
-H 'X-Plex-Device-Name: PlexMediaServer' \
|
||||
-H 'X-Plex-Device: Linux' \
|
||||
"https://plex.tv/api/claim/exchange?token=${PLEX_CLAIM}" \
|
||||
| sed -n 's/.*<authentication-token>\(.*\)<\/authentication-token>.*/\1/p')"
|
||||
-H 'X-Plex-Client-Identifier: '"${ProcessedMachineIdentifier}" \
|
||||
-H 'X-Plex-Product: Plex Media Server'\
|
||||
-H 'X-Plex-Version: 1.1' \
|
||||
-H 'X-Plex-Provides: server' \
|
||||
-H 'X-Plex-Platform: Linux' \
|
||||
-H 'X-Plex-Platform-Version: 1.0' \
|
||||
-H 'X-Plex-Device-Name: PlexMediaServer' \
|
||||
-H 'X-Plex-Device: Linux' \
|
||||
"https://plex.tv/api/claim/exchange?token=${PLEX_CLAIM}" \
|
||||
| sed -n 's/.*<authentication-token>\(.*\)<\/authentication-token>.*/\1/p')"
|
||||
|
||||
if [ -n "$PlexOnlineToken" ]; then
|
||||
echo "Server claimed successfully, navigate to http://serverip:32400/web to complete plex setup."
|
||||
sed -i "s/\/>/ PlexOnlineToken=\"${PlexOnlineToken}\"\/>/g" "${PREFNAME}"
|
||||
echo "Server claimed successfully, navigate to http://serverip:32400/web to complete plex setup."
|
||||
sed -i "s/\/>/ PlexOnlineToken=\"${PlexOnlineToken}\"\/>/g" "${PREFNAME}"
|
||||
else
|
||||
echo "Unable to claim Plex server. Either manually claim by connecting to http://serverip:32400/web from the same network subnet, or recreate container with a new claim token."
|
||||
echo "Unable to claim Plex server. Either manually claim by connecting to http://serverip:32400/web from the same network subnet, or recreate container with a new claim token."
|
||||
fi
|
||||
|
|
@ -2,25 +2,25 @@
|
|||
|
||||
# If docker manages versioning exit
|
||||
if [ "${VERSION}" ] && [ "${VERSION}" == 'docker' ]; then
|
||||
echo "Docker is used for versioning skip update check"
|
||||
exit 0
|
||||
echo "Docker is used for versioning skip update check"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# test if plex is installed and try re-pulling latest if not
|
||||
if (dpkg --get-selections plexmediaserver | grep -wq "install"); 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_DOWNLOAD}/${REMOTE_VERSION}/debian/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb" && \
|
||||
dpkg -i --force-confold /tmp/plexmediaserver.deb
|
||||
rm -f /tmp/plexmediaserver.deb
|
||||
exit 0
|
||||
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_DOWNLOAD}/${REMOTE_VERSION}/debian/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb" && \
|
||||
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
|
||||
rm /tmp/no-version.nfo
|
||||
NOVERSION_SET='/tmp/no-version.nfo'
|
||||
cat > "${NOVERSION_SET}" <<-EOFVERSION
|
||||
#######################################################
|
||||
|
|
@ -33,7 +33,7 @@ EOFVERSION
|
|||
|
||||
# set update failed message
|
||||
[[ -e /tmp/update_fail.nfo ]] && \
|
||||
rm /tmp/update_fail.nfo
|
||||
rm /tmp/update_fail.nfo
|
||||
UPGRADE_FAIL='/tmp/update_fail.nfo'
|
||||
cat > "${UPGRADE_FAIL}" <<-EOFFAIL
|
||||
########################################################
|
||||
|
|
@ -47,13 +47,13 @@ EOFFAIL
|
|||
|
||||
# test for no version set or opt out for autoupdates
|
||||
if [[ -z "$VERSION" ]] || [[ "$VERSION" == "0" ]] || [[ -n "$ADVANCED_DISABLEUPDATES" ]]; then
|
||||
printf '\n\n\n%s\n\n\n' "$(</tmp/no-version.nfo)"
|
||||
exit 0
|
||||
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
|
||||
rm /tmp/no-token.nfo
|
||||
NOTOKEN_SET='/tmp/no-token.nfo'
|
||||
cat > "${NOTOKEN_SET}" <<-EOFTOKEN
|
||||
#####################################################
|
||||
|
|
@ -63,27 +63,27 @@ 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
|
||||
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
|
||||
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/\".*//")
|
||||
"/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
|
||||
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
|
||||
printf '\n\n\n%s\n\n\n' "$(</tmp/no-token.nfo)"
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# determine installed version of plex
|
||||
|
|
@ -91,37 +91,37 @@ INSTALLED_VERSION=$(dpkg-query -W -f='${Version}' plexmediaserver)
|
|||
|
||||
# start update routine
|
||||
if [[ "${VERSION,,}" = latest ]] || [[ "${VERSION,,}" = plexpass ]] || [[ "$PLEXPASS" == "1" ]]; then
|
||||
if [[ "${PLEX_ARCH}" = amd64 ]]; then
|
||||
PLEX_URL_ARCH="x86_64"
|
||||
elif [[ "${PLEX_ARCH}" = armhf ]]; then
|
||||
PLEX_URL_ARCH="armv7hf_neon"
|
||||
elif [[ "${PLEX_ARCH}" = arm64 ]]; then
|
||||
PLEX_URL_ARCH="aarch64"
|
||||
fi
|
||||
REMOTE_VERSION=$(curl -s "https://plex.tv/downloads/details/5?distro=debian&build=linux-${PLEX_URL_ARCH}&channel=8&X-Plex-Token=$PLEX_TOKEN"| grep -oP 'version="\K[^"]+' | tail -n 1 )
|
||||
if [[ "${PLEX_ARCH}" = amd64 ]]; then
|
||||
PLEX_URL_ARCH="x86_64"
|
||||
elif [[ "${PLEX_ARCH}" = armhf ]]; then
|
||||
PLEX_URL_ARCH="armv7hf_neon"
|
||||
elif [[ "${PLEX_ARCH}" = arm64 ]]; then
|
||||
PLEX_URL_ARCH="aarch64"
|
||||
fi
|
||||
REMOTE_VERSION=$(curl -s "https://plex.tv/downloads/details/5?distro=debian&build=linux-${PLEX_URL_ARCH}&channel=8&X-Plex-Token=$PLEX_TOKEN"| grep -oP 'version="\K[^"]+' | tail -n 1 )
|
||||
elif [[ "${VERSION,,}" = public ]]; then
|
||||
REMOTE_VERSION=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' | jq -r '.computer.Linux.version')
|
||||
REMOTE_VERSION=$(curl -sX GET 'https://plex.tv/api/downloads/5.json' | jq -r '.computer.Linux.version')
|
||||
else
|
||||
REMOTE_VERSION="${VERSION}"
|
||||
REMOTE_VERSION="${VERSION}"
|
||||
fi
|
||||
|
||||
if [[ "$REMOTE_VERSION" == "$INSTALLED_VERSION" ]]; then
|
||||
echo "No update required"
|
||||
exit 0
|
||||
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}/debian/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb"
|
||||
"${PLEX_DOWNLOAD}/${REMOTE_VERSION}/debian/plexmediaserver_${REMOTE_VERSION}_${PLEX_ARCH}.deb"
|
||||
last=$?
|
||||
|
||||
# test if deb file size is ok, or if download failed
|
||||
if [[ "$last" -gt "0" ]] || [[ $(stat -c %s /tmp/plexmediaserver_"${REMOTE_VERSION}"_${PLEX_ARCH}.deb) -lt 10000 ]]; then
|
||||
printf '\n\n\n%s\n\n\n' "$(</tmp/update_fail.nfo)"
|
||||
exit 0
|
||||
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}"_${PLEX_ARCH}.deb
|
||||
rm -f /tmp/plexmediaserver_*.deb
|
||||
dpkg -i --force-confold /tmp/plexmediaserver_"${REMOTE_VERSION}"_${PLEX_ARCH}.deb
|
||||
rm -f /tmp/plexmediaserver_*.deb
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -1,14 +1,8 @@
|
|||
#!/usr/bin/with-contenv bash
|
||||
|
||||
|
||||
if [ -n "${UMASK_SET}" ] && [ -z "${UMASK}" ]; then
|
||||
echo -e "You are using a legacy method of defining umask\nplease update your environment variable from UMASK_SET to UMASK\nto keep the functionality after July 2021"
|
||||
umask ${UMASK_SET}
|
||||
fi
|
||||
|
||||
echo "Starting Plex Media Server."
|
||||
export PLEX_MEDIA_SERVER_INFO_MODEL=$(uname -m)
|
||||
export PLEX_MEDIA_SERVER_INFO_PLATFORM_VERSION=$(uname -r)
|
||||
exec \
|
||||
s6-setuidgid abc \
|
||||
/usr/lib/plexmediaserver/Plex\ Media\ Server
|
||||
s6-setuidgid abc \
|
||||
/usr/lib/plexmediaserver/Plex\ Media\ Server
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue