still working on update script

This commit is contained in:
sparklyballs 2016-08-22 20:41:24 +01:00
parent da12aa2d63
commit 78f96a9629

View file

@ -15,8 +15,8 @@ cat > "${NOVERSION_SET}" <<-EOFVERSION
EOFVERSION EOFVERSION
# test for no version set or opt out for autoupdates # test for no version set or opt out for autoupdates
if [ -z "$VERSION" -o "$VERSION" == "0" -o ! -z "$ADVANCED_DISABLEUPDATES" ]; then if [[ -z "$VERSION" ]] || [[ "$VERSION" == "0" ]] || [[ ! -z "$ADVANCED_DISABLEUPDATES" ]]; then
echo "$(cat /tmp/no-version.nfo)" printf "%s\n\n\n" "$(</tmp/no-version.nfo)"
exit 0 exit 0
fi fi
@ -37,10 +37,8 @@ if [ ! -e "/config/Library/Application Support/Plex Media Server/Preferences.xml
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
# preference file found, possibly first startup. # # preference file found, possibly first startup. #
##################################################### #####################################################
EOFTOKEN EOFTOKEN
echo "$(cat /tmp/no-token.nfo)" printf "%s\n\n\n" "$(</tmp/no-token.nfo)"
exit 0 exit 0
fi fi
@ -54,17 +52,14 @@ if [ -z "$PLEX_TOKEN" ]; then
cat >> "${NOTOKEN_SET}" <<-EOFTOKEN cat >> "${NOTOKEN_SET}" <<-EOFTOKEN
# plex token found in the preference file # # plex token found in the preference file #
##################################################### #####################################################
EOFTOKEN EOFTOKEN
echo "$(cat /tmp/no-token.nfo)" printf "%s\n\n\n" "$(</tmp/no-token.nfo)"
exit 0 exit 0
fi fi
# determine installed version of plex # determine installed version of plex
INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver) INSTALLED=$(dpkg-query -W -f='${Version}' plexmediaserver)
# start update routine # start update routine
[[ "$PLEXPASS" ]] && \ [[ "$PLEXPASS" ]] && \
@ -74,12 +69,12 @@ if [[ -z $VERSION && "$PLEXPASS" == "1" || $VERSION = "plexpass" ]]; then echo "
if [[ "$VERSION" = latest || "$VERSION" = plexpass ]]; then 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 ) 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 set to: latest\plexpass" echo "Target version: $VERSION"
elif [[ "$VERSION" = public ]]; then 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 ) 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 set to: public" echo "Target version: $VERSION"
else else
echo "Target version: $VERSION set to: manual" echo "Target version: $VERSION"
fi fi
last=130 last=130
@ -96,9 +91,9 @@ if [[ "$VERSION" != "$INSTALLED" ]]; then
apt-get remove --purge -y \ apt-get remove --purge -y \
plexmediaserver plexmediaserver
dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb dpkg -i /tmp/plexmediaserver_"${VERSION}"_amd64.deb
rm -f /tmp/plexmediaserver_*.deb
else else
echo "No need to update!" echo "No updates found!"
fi fi
cp -v /defaults/plexmediaserver /etc/default/plexmediaserver cp -v /defaults/plexmediaserver /etc/default/plexmediaserver