Created
November 25, 2020 11:14
-
-
Save vchatela/b5a0fce0cb48eff6deecf328c3d54846 to your computer and use it in GitHub Desktop.
Fork of https://github.com/martinorob/plexupdate/ to add renew of HTTPS cert after upgrade
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Script to automagically update Plex Media Server on Synology NAS | |
# | |
# Must be run as root. | |
# | |
# @author @martinorob https://github.com/martinorob | |
# https://github.com/martinorob/plexupdate/ | |
# @vchatela: I have added the renew of the plex certificate for HTTPS after upgrade | |
mkdir -p /tmp/plex/ > /dev/null 2>&1 | |
token=$(cat /volume1/Plex/Library/Application\ Support/Plex\ Media\ Server/Preferences.xml | grep -oP 'PlexOnlineToken="\K[^"]+') | |
url=$(echo "https://plex.tv/api/downloads/5.json?channel=plexpass&X-Plex-Token=$token") | |
jq=$(curl -s ${url}) | |
newversion=$(echo $jq | jq -r .nas.Synology.version) | |
echo New Ver: $newversion | |
curversion=$(synopkg version "Plex Media Server") | |
echo Cur Ver: $curversion | |
if [ "$newversion" != "$curversion" ] | |
then | |
echo New Vers Available | |
/usr/syno/bin/synonotify PKGHasUpgrade '{"[%HOSTNAME%]": $(hostname), "[%OSNAME%]": "Synology", "[%PKG_HAS_UPDATE%]": "Plex", "[%COMPANY_NAME%]": "Synology"}' | |
CPU=$(uname -m) | |
url=$(echo "${jq}" | jq -r '.nas.Synology.releases[] | select(.build=="linux-'"${CPU}"'") | .url') | |
/bin/wget $url -P /tmp/plex/ | |
/usr/syno/bin/synopkg install /tmp/plex/*.spk | |
sleep 30 | |
/usr/syno/bin/synopkg start "Plex Media Server" | |
rm -rf /tmp/plex/* | |
echo "Renew Plex Cert" | |
/volume1/tools/plex/force_renew_plex_cert.sh | |
else | |
echo No New Ver | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment