From 5db417d56e9016cbda7fff6386590bc49345bcdc Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Mon, 22 Aug 2016 22:02:36 +0100 Subject: [PATCH] save up for prosperity, no comment on completion or viability, just a save up --- Dockerfile | 1 + root/etc/cont-init.d/50-plex-update | 45 +++++++++++++---------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index 94a1db4..4d526d9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -26,6 +26,7 @@ RUN \ # cleanup apt-get clean && \ rm -rf \ + /etc/default/plexmediaserver \ /tmp/* \ /var/lib/apt/lists/* \ /var/tmp/* diff --git a/root/etc/cont-init.d/50-plex-update b/root/etc/cont-init.d/50-plex-update index 2791d55..e36afb9 100644 --- a/root/etc/cont-init.d/50-plex-update +++ b/root/etc/cont-init.d/50-plex-update @@ -1,8 +1,12 @@ #!/usr/bin/with-contenv bash +# copy config on first run, regardless of update status +[[ ! -e /etc/default/plexmediaserver ]] && \ + cp /defaults/plexmediaserver /etc/default/plexmediaserver + # 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 @@ -61,39 +65,30 @@ fi INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver) # start update routine - -[[ "$PLEXPASS" ]] && \ - echo "PLEXPASS is deprecated, please use VERSION" - -if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is deprecated please use version latest"; fi - -if [[ "$VERSION" = latest || "$VERSION" = plexpass ]]; then - VERSION=$(curl -s "${PLEX_URL}/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu&X-Plex-Token=$PLEX_TOKEN"| cut -d "/" -f 5 ) - echo "Target version: $VERSION" -elif [[ "$VERSION" = public ]]; then - VERSION=$(curl -s "${PLEX_URL}/latest/1?channel=8&build=linux-ubuntu-x86_64&distro=ubuntu&X-Plex-Token="| cut -d "/" -f 5 ) - echo "Target version: $VERSION" +if [[ "$VERSION" = latest ]] || [[ "$VERSION" = plexpass ]] || [[ "$PLEXPASS" == "1" ]]; then +PLEX_TOKEN="${PLEX_TOKEN}" else - echo "Target version: $VERSION" +PLEX_TOKEN="" fi +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 ) +if [[ "$VERSION" == "$INSTALLED" ]]; then +echo "No update required" +exit 0 +fi + +echo "Atempting to upgrade to: $VERSION" last=130 -if [[ "$VERSION" != "$INSTALLED" ]]; then - echo "Upgrading from version: $INSTALLED to version: $VERSION" - while [[ $last -ne "0" ]]; do +while [[ $last -ne "0" ]]; do rm -f /tmp/plexmediaserver_*.deb curl -o /tmp/plexmediaserver_"${VERSION}"_amd64.deb -L \ "${PLEX_URL}/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb" last=$? - done - [[ ! -e /tmp/plexmediaserver_"${VERSION}"_amd64.deb ]] && \ - exit 0 +done apt-get remove --purge -y \ plexmediaserver - dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb - rm -f /tmp/plexmediaserver_*.deb -else - echo "No updates found!" -fi +dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb +rm -f /tmp/plexmediaserver_*.deb +# recopy config file in case update overwrites our copy cp -v /defaults/plexmediaserver /etc/default/plexmediaserver