From 1ed525723552dfb71b037c1332967be46d0c1825 Mon Sep 17 00:00:00 2001 From: sparklyballs Date: Mon, 22 Aug 2016 12:44:21 +0100 Subject: [PATCH] more tidying --- Dockerfile | 15 +++++++------ root/etc/cont-init.d/20-dbus | 13 +++++++---- root/etc/cont-init.d/30-plex-update | 34 +++++++++++++++++------------ 3 files changed, 37 insertions(+), 25 deletions(-) diff --git a/Dockerfile b/Dockerfile index d5e53b8..94a1db4 100644 --- a/Dockerfile +++ b/Dockerfile @@ -17,21 +17,22 @@ RUN \ dbus \ wget && \ -# cleanup - apt-get clean && \ - rm -rf /tmp/* /var/lib/apt/lists/* /var/tmp/* - # install plex -RUN \ curl -o \ /tmp/plexmediaserver.deb -L \ "${PLEX_WWW}" && \ dpkg -i /tmp/plexmediaserver.deb && \ - rm -f /tmp/* + +# cleanup + apt-get clean && \ + rm -rf \ + /tmp/* \ + /var/lib/apt/lists/* \ + /var/tmp/* # add local files COPY root/ / # ports and volumes -VOLUME /config /transcode EXPOSE 32400 32400/udp 32469 32469/udp 5353/udp 1900/udp +VOLUME /config /transcode diff --git a/root/etc/cont-init.d/20-dbus b/root/etc/cont-init.d/20-dbus index fcda4ba..ef94cef 100644 --- a/root/etc/cont-init.d/20-dbus +++ b/root/etc/cont-init.d/20-dbus @@ -1,9 +1,14 @@ #!/usr/bin/with-contenv bash -[[ -e /var/run/dbus/pid ]] && rm -f /var/run/dbus/pid - +# make folders mkdir -p /var/run/dbus -chown messagebus:messagebus /var/run/dbus + +# delete existing pid if found +[[ -e /var/run/dbus/pid ]] && \ + rm -f /var/run/dbus/pid + +# permissions +chown messagebus:messagebus \ + /var/run/dbus dbus-uuidgen --ensure sleep 1 - diff --git a/root/etc/cont-init.d/30-plex-update b/root/etc/cont-init.d/30-plex-update index 04b761a..2d04886 100644 --- a/root/etc/cont-init.d/30-plex-update +++ b/root/etc/cont-init.d/30-plex-update @@ -1,10 +1,12 @@ #!/usr/bin/with-contenv bash # opt out for autoupdates -[ "$ADVANCED_DISABLEUPDATES" ] && exit 0 +[ "$ADVANCED_DISABLEUPDATES" ] && \ + exit 0 # set header for no preferences/token message -[[ -e /tmp/no-token.nfo ]] && rm /tmp/no-token.nfo +[[ -e /tmp/no-token.nfo ]] && \ + rm /tmp/no-token.nfo NOTOKEN_SET='/tmp/no-token.nfo' cat > "${NOTOKEN_SET}" <<-EOFTOKEN @@ -28,8 +30,8 @@ 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 @@ -39,7 +41,7 @@ cat >> "${NOTOKEN_SET}" <<-EOFTOKEN EOFTOKEN -less /tmp/no-token.nfo +echo "$(cat /tmp/no-token.nfo)" exit 0 fi @@ -49,7 +51,8 @@ INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver) # start update routine -[ "$PLEXPASS" ] && echo "PLEXPASS is deprecated, please use VERSION" +[ "$PLEXPASS" ] && \ + echo "PLEXPASS is deprecated, please use VERSION" if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "VERSION=plexpass is depricated please use version latest"; fi @@ -67,18 +70,21 @@ fi last=130 if [[ "$VERSION" == "" ]]; then - echo "VERSION variable not set, current installed version $INSTALLED" + echo "VERSION variable not set, current installed version $INSTALLED" elif [[ "$VERSION" != "$INSTALLED" ]]; then - echo "Upgrading from version: $INSTALLED to version: $VERSION" - while [[ $last -ne "0" ]]; do + echo "Upgrading from version: $INSTALLED to version: $VERSION" + 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=$? + "${PLEX_URL}/plex-media-server/$VERSION/plexmediaserver_${VERSION}_amd64.deb" + last=$? done - [[ ! -e /tmp/plexmediaserver_"${VERSION}"_amd64.deb ]] && exit 0 - apt-get remove --purge -y plexmediaserver - dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb + [[ ! -e /tmp/plexmediaserver_"${VERSION}"_amd64.deb ]] && \ + exit 0 + apt-get remove --purge -y \ + plexmediaserver + dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb + else echo "No need to update!" fi