mrworf / plexupdate Goto Github PK
View Code? Open in Web Editor NEWPlex Update script to simplify the life of Linux Plex Media Server users.
License: GNU General Public License v2.0
Plex Update script to simplify the life of Linux Plex Media Server users.
License: GNU General Public License v2.0
when I run
/plexupdate.sh -p -c -a 2>&1 1>/var/log/plexupdate
no new update are found. But on my server I got a message which say new update available!
I'm on the Plexpass channel..
Hello,
I'm using commit # 482f1d2.
When my PMS server is stopped, I still get the following error. Any ideas?
My service
root@plex:~/plexupdate# bash plexupdate.sh
Auto updating...OK
Authenticating...OK
Finding download URL to download...OK
File already exists (plexmediaserver_1.1.1.2675-d00866c_amd64.deb), won't download.
Server 127.0.0.1 is currently being used by one or more users, skipping installation. Please run again later
It looks like the download page for Plex has changed.
I used -x in the bash script to see the whole thing. I'm pasting it below.
+ echo -n 'Finding download URL to download...'
Finding download URL to download...++ grep -m1 -ioe 'https://[^\"]*'
++ grep -i '"build":"64"'
++ grep -i '"distro":"ubuntu"'
++ grep -ioe '"label"[^}]*'
++ wget --load-cookies /tmp/kaka --save-cookies /tmp/kaka --keep-session-cookies 'https://plex.tv/api/downloads/1.json?channel=plexpass' -O -
+ DOWNLOAD=
+ '[' no = no ']'
+ echo -e OK
OK
+ '[' '' == '' ']'
+ echo 'ERROR: Unable to retrieve the URL needed for download (Query DISTRO: ubuntu, BUILD: 64)'
ERROR: Unable to retrieve the URL needed for download (Query DISTRO: ubuntu, BUILD: 64)
+ exit 3
+ cleanup
+ rm /tmp/postdata
+ rm /tmp/raw
+ rm /tmp/failcause
+ '[' no '!=' yes ']'
+ rm /tmp/kaka
I would like to update Plex automatically on my Ubuntu server 14.04 from cron so for that your script comes in perfectly.
However I edited Plex' config file (/etc/default/plexmediaserver) to run Plex as a different user and that results in dpkg interrupting the installation process.
I ran your script as:
$ sudo plexupdate.sh -a -d -p -u
And I get the following message from dpkg:
Configuration file '/etc/default/plexmediaserver'
==> Modified (by you or by a script) since installation.
==> Package distributor has shipped an updated version.
What would you like to do about it ? Your options are:
Y or I : install the package maintainer's version
N or O : keep your currently-installed version
D : show the differences between the versions
Z : start a shell to examine the situation
The default action is to keep your current version.
*** plexmediaserver (Y/I/N/O/D/Z) [default=N] ?
I looked through the dpkg command line options hoping I could add one on line 333 of your script as to automatically skip the manual confirmation but I didn't find anything useful.
Is it possible for you to update the script so fully unattended Plex updates are possible in my situation as well? Or can you give me recommendations for it?
Thanks!
When the autoupdate option (-u) is used the script keeps looking for updates in loop forever.
It would be nice if plugins are moved to the new directory plugin directory, or reinstalled from a git repository.
While running the script as root on debian the following issue comes up:
./plexupdate.sh: line 505: sudo: command not found
If I go into line 505 and remove the sudo the download works...
Debian GNU/Linux 8
Not an issue really, just thought i'd throw in a timer and service unit here. Do what you want with it. People also need to change the path and maybe user depending on how it's run.
/etc/systemd/system/plexupdate.service
[Unit]
Description=plexupdate
After=network.target
[Service]
ExecStart=/root/plexupdate/plexupdate.sh -a -c -d -p -s -u
/etc/systemd/system/plexupdate.timer
[Unit]
Description=Run the plex updater daily
[Timer]
OnCalendar=daily
Persistent=true
[Install]
WantedBy=timers.target
systemctl daemon-reload
systemctl enable plexupdate.timer
Now bring the systemd hate and tell me it's simpler in cron! ๐ ng:
sudo ./plexupdate.sh .plexupdate -f
Authenticating...OK
Finding download URL to download...OK
Your OS reports the latest version of Plex (1.0.1.2396-c094d0d) is already installed. Use -f to force download.
My .plexupdate file contains:
DOWNLOADDIR="/data/plexmediaserver/Library/Application Support/Plex Media Server"
When I try to run plexupdate I'm getting:
Error: Download directory does not exist or is not a directory
I noticed you committed a change recently for checking the download directory. On line 136 you are doing eval pushd. I tried this command by itself in the bash prompt with my directory and got this:
bash> eval pushd "/data/plexmediaserver/Library/Application Support/Plex Media Server"
-bash: pushd: /data/plexmediaserver/Library/Application: No such file or directory
I then tried the same command but without the eval part and it worked fine. So I tried removing the eval command on line 136 so it just says pushd and the script ran fine for me. Not sure exactly what is happening, but I think it has to do with spaces being in my path. Why is the eval there and is it necessary? The script only runs for me if it's not there.
When running the update, I would get cannot delete directory; not empty, when it tries to presumably replace the bundles with updated info. Is this normal?
root@cinaplex:# /root/plexupdate.sh#
Authenticating...OK
Finding download URL for 64-bit...OK
Sorry, page layout must have changed, I'm unable to retrieve the URL needed for download
root@cinaplex:
So after the script has been running fine for like the last month this is suddenly happening. The login page didn't change as suggested though. Any ideas?
first run:
./plexupdate.sh -p -C
Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes.
Downloading release "plexmediaserver-1.0.0.2261-a17e99e.i386.rpm"...OK
second run:.
/plexupdate.sh -p -C
Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes.
There is also a exit 2 as the return status.
Expected output should be nothing and return code of 0.
The AUTOSTART exit 2 should likely be a function of either AUTOINSTALL or AUTOUPDATE set to "yes" instead.
Basically creates the option for using this script as a cron checker for updates that only notifies when there is an update.
Thanks
PJ
Just opening this as an issue before sending in a PR to see if there are any objections. -S seems completely unnecessary for experienced users, and dangerous for inexperienced ones. If you know what you're doing, ./plexupdate.sh -q 2>/dev/null
does exactly the same thing. If you don't know what you're doing, -S only serves to hide all possible output from you which seems like a terrible idea.
It looks like it was added in #53 with the comment "Added a silent mode argument (because why not?)", which just seems like the worst possible reason to ever add anything to a piece of software.
The package (64-bit) downloaded fine, but returned "ERROR: dpkg: error processing /root/plexmediaserver_0.9.16.4.1911-ee6e505_amd64.deb"
Apparently, my server has an ARM processor and the dpkg didn't like it.
See here --> [img]http://i.imgur.com/S4PMZbV.png[/img]
I am on Ubuntu 14.04.2 when running the script with sudo sh plexupdate.sh i get:
plexupdate.sh: 92: [: no: unexpected operator
plexupdate.sh: 121: [: unexpected operator
plexupdate.sh: 126: [: no: unexpected operator
plexupdate.sh: 149: plexupdate.sh: Syntax error: Bad for loop variable
I've added the .plexupdate file under my home dir with my login details
Is there anything i can do?
Thanks
First to say, that this script is awesome and it makes plex on linux so much easier, thanks
I have updated my Linux server updated to Ubuntu 15.04.
I understand that Canonical changed the boot and service management.
And when running the script, im getting errors
stop: Unable to connect to Upstart: Failed to connect to socket /com/ubuntu/upstart: Connection refused
Installing new version of config file /etc/default/plexmediaserver ...
Failed to execute operation: File exists
dpkg: error processing package plexmediaserver (--install):
subprocess installed post-installation script returned error exit status 1
Errors were encountered while processing:
plexmediaserver
First, great script. :) Just a note that "rpm -i" should be "rpm -u" (to upgrade the RPM) for an auto-upgrade. Though, it's probably best to use "yum localinstall $RPM" instead so that it can decide the correct action and pull any dependencies too.
Something is wrong with the plexpass authentication. Posts at the end of this thread explain that the new website has changed something and with the current script setup the failed authentication just returns the non plex pass version.
When grepping the raw data for 'Sign In</title' this will always not find it since that text string doesn't exist on the new website.
Better to search for 'Logout' to verify login success.
It looks like KEEP
has been rendered useless since 170db36. Since /tmp/kaka
is deleted on exit, there's really no option to keep your session anymore. I personally don't care all that much, so just removing it altogether would work. If you want to have it work I'm happy to send in a PR since I've already dug into the code to see why it's not working in the first place.
When using the AUTOUPDATE functionality, setting AUTOUPDATE=yes
I recieve the following error:
Auto updating...OK
plexupdate.sh: line 124: plexupdate.sh: command not found
I'm using Ubuntu 14.04 64bit.
I'd love to see a basic function in the beginning that would check the web version against the current version to see if an update is needed.
CURRENTVER=export LD_LIBRARY_PATH=/usr/lib/plexmediaserver; /usr/lib/plexmediaserver/Plex\ Media\ Server --version | awk -F[v-] '{print($2)}'
would give the numeric string of the version.
I tried the script on both of my Ubuntu boxes this evening. Note: Script worked fine last upgrade.
I checked GIT for an update, then ran the script this evening. (although in briefly looking at the code, it's got an auto-updater now?)
All it seemed to do is download the upgrade file, but didn't go any further. No error message, until I thought I'd made a mistake and tried it again. Then it was kind of upset that the file to download was already there. :)
Is there a possibility to make this script auto updating, for example every time the user runs the script it will download a new version if available. Could be directly from github.
I'm not into bash script or Linux programming, but I can take a look if I can make a start.
ERROR: RELEASE keyword is deprecated, use DISTRO and BUILD
Ubuntu 16.04
All of a sudden started getting this error. Any ideas?
Thanks for the useful update script!
First of all I want to say I absolutely love you script. It has made updating Plex on my server a breeze.
I am wondering if it would be possible to add a progress bar when the PMS file is downloading?
Is the username and password for the server that pms is being installed on?
I tried following the guide and found a few issues. Everything is working now but it may help for those in the future who try installing it.
In 2. setting it up you have it set to email and pass, but in TL;DR, you have user and pass. User and pass wont work if the user has the only accept email option enabled.
Second thing, wget https://github.com/mrworf/plexupdate/blob/master/plexupdate.sh downloads the html page, not the actual code.
https://raw.githubusercontent.com/mrworf/plexupdate/master/plexupdate.sh would be the right link instead.
The new site layout seems to have broken everything, not really unexpected though.
When running the script, I get:
bash: ./plexupdate.sh: /bin/bash^M: bad interpreter: No such file or directory
I had to install package tofrodos and run the fromdos utility.
TIP: Don't write linux scripts on windows? :)
It seems the script is stuck at auto updating, I always get "Auto updating...OK" out from the script, multiple times after each other (seems like it never moves on to the next phase).
Playing around with some stuff I first thought it was because I had my config and log file moved into the same folder, but when I remove the location of my .plexupdate file from the command, it seems to be working just fine again.
Also disabling Auto update in the config file, and specifying the config's location does work.
EDIT: After some more investigating, it seems that the problem originates from here: https://github.com/mrworf/plexupdate/blob/master/plexupdate.sh#L233
this is the log I get when I print out the ALLARGS variable:
Auto updating...OK
../.plexupdate
Auto updating...OK
../.plexupdate -U
Auto updating...OK
../.plexupdate -U -U
Auto updating...OK
../.plexupdate -U -U -U
Auto updating...OK
../.plexupdate -U -U -U -U
Auto updating...OK
../.plexupdate -U -U -U -U -U
I get this error whenever I update using plexupdate.sh (obviously the hex value in the Plug-ins-a17e99e changes with each version.) I have a YouTube plugin that for some reason never seems to be moved when I perform an update. This is an Ubuntu PMS install and the permissions seem to match all the other plugins folders and I'm using sudo when running it.
I can manually go in an do something like:
sudo mv /usr/lib/plexmediaserver/Resources/Plug-ins-a17e99e/* /usr/lib/plexmediaserver/Resources/Plug-ins-c093d0d/
and it moves fine, I can then safely delete /usr/lib/plexmediaserver/Resources/Plug-ins-a17e99e
Since the error appears to be from dpkg, I'm not sure why some plugins seem to be moved while this youtube one doesn't. Any ideas?
I should mention that PMS is successfully updated, but since that YouTube plugin isn't moved over, it stops showing up under Channels after I update PMS (until I manually move it.)
root@plex-tv:/opt/plexupdate# ./plexupdate.sh -f
Auto updating...OK
Authenticating...OK
Finding download URL to download...OK
sha1sum: plexmediaserver_1.1.2.2680-09e98fb_amd64.deb: No such file or directory
Note! File exists but fails checksum. Redownloading.
Downloading release "plexmediaserver_1.1.2.2680-09e98fb_amd64.deb"...OK
sha1sum: plexmediaserver_1.1.2.2680-09e98fb_amd64.deb: No such file or directory
Downloaded file corrupt. Try again.
root@plex-tv:~/plex_files# sha1sum plexmediaserver_1.1.2.2680-09e98fb_amd64.deb; cat plexmediaserver_1.1.2.2680-09e98fb_amd64.deb.sha
f255a394d5df653bb555a79285cfda66feb7025c plexmediaserver_1.1.2.2680-09e98fb_amd64.deb
f255a394d5df653bb555a79285cfda66feb7025c plexmediaserver_1.1.2.2680-09e98fb_amd64.deb
root@plex-tv:~/plex_files# sha1sum --status -c /root/plex_files/plexmediaserver_1.1.2.2680-09e98fb_amd64.deb.sha
root@plex-tv:~/plex_files# echo $?
0
Seems that the new checksum addition doesn't work right.
It downloads the correct checksum file but fails to find the correct file.
echo "${CHECKSUM} ${FILENAME}" >${DOWNLOADDIR}/${FILENAME}.sha
I think this is because ${DOWNLOADDIR}/${FILENAME} is necessary.
echo "${CHECKSUM} ${DOWNLOADDIR}/${FILENAME}" >${DOWNLOADDIR}/${FILENAME}.sha
root@plex-tv:/opt/plexupdate# /opt/plexupdate/plexupdate.sh
Authenticating...OK
Finding download URL to download...OK
Your OS reports the latest version of Plex (1.1.2.2680-09e98fb) is already installed. Use -f to force download.
root@plex-tv:/opt/plexupdate# /opt/plexupdate/plexupdate.sh -f
Authenticating...OK
Finding download URL to download...OK
File exists and checksum passes, won't redownload.
DATA: '<?xml version="1.0" encoding="UTF-8"?>
<MediaContainer size="0">
</MediaContainer>'
(Reading database ... 36667 files and directories currently installed.)
Preparing to unpack .../plexmediaserver_1.1.2.2680-09e98fb_amd64.deb ...
Removed symlink /etc/systemd/system/multi-user.target.wants/plexmediaserver.service.
Unpacking plexmediaserver (1.1.2.2680-09e98fb) over (1.1.2.2680-09e98fb) ...
Setting up plexmediaserver (1.1.2.2680-09e98fb) ...
Processing triggers for mime-support (3.58) ...
Processing triggers for systemd (215-17+deb8u4) ...
Hi all,
I am having problems with the configuration - i have the download folder set as ~/Downloads (the folder does exist), however I'm getting the error message - "Error: Download directory does not exist or is not a directory"
Hello!
I am getting Error: Username and/or password incorrect when using your script.
My password has all the crazy characters in it ($, @, &, !, %), so I did some testing and it seems like the URL encode (?) can't handle $ (dollar signs), because when I remove that it works perfectly.
A quick fix for me would be to remove the dollar signs from my password, but I am wondering if there is any other way to do it
Ubuntu 14.10 (Linux server 3.16.0-43-generic)
This is an error not caused by the script itself, but by how wget and/or the shell treats this value.
The typical error an end-user sees is this:
$ ./plexupdate.sh
Authenticating...OK
Finding download URL for 64-bit...OK
!! Download failed with code 1, "~/.plexupdates/plexmediaserver_0.9.12.12.1459-49fe448_amd64.deb: No such file or directory"
This can be reproduced independently from the script itself:
# quoted with ~, fails
$ wget -O "~/.plexdownloads/test1.deb"
https://downloads.plex.tv/plex-media-server/0.9.12.11.1406-8403350/plexmediaserver_0.9.12.11.1406-8403350_amd64.deb
# unquoted with ~, succeeds
$ wget -O ~/.plexdownloads/test2.deb
https://downloads.plex.tv/plex-media-server/0.9.12.11.1406-8403350/plexmediaserver_0.9.12.11.1406-8403350_amd64.deb
# expanded ~ with quotes, succeeds
$ wget -O "/home/user/.plexdownloads/test3.deb"
https://downloads.plex.tv/plex-media-server/0.9.12.11.1406-8403350/plexmediaserver_0.9.12.11.1406-8403350_amd64.deb
Since we really want to be quoting our strings, the remaining option is to expand the DOWNLOADDIR-variable ourselves, and for now that is also a reasonable manual workaround, but it should be documented.
For the future, the script should be able to apply this workaround itself.
Running as superuser is required to actually install updates in CentOS, but when this is done the script looks in the home directory of root rather than of the current user.
I created the .plexupdate file with my login/passwd for plex.tv but seems like it keeps trying public deb package and not plex pass version.
I'm currently using a wrapper script to validate that Plex is not in use before running this script. I utilize the plexwatch tool, but it would be cool if this had something built in. I may have modified your original script as well, to make it work smoother with the wrapper. Will check if you're interested
I think plex team had made some modification on the plex pass web site:
now the release value must be set to RELEASE="64 bit" instead of 64-bit
regards
Great work on the script, just fantastic! I may be running this wrong but yum waits for you to accept the install before it will update the RPM package.
OS: CentOS 6.6
Scenario: Run .sh script with -a option
Issue: Script will download and hang on yum install screen. Waiting for you press "y/n" to accept the new RPM install.
Workaround: Modify line #285
From: sudo yum localinstall "${DOWNLOADDIR}/${FILENAME}"
To: sudo yum -y localinstall "${DOWNLOADDIR}/${FILENAME}"
The -y option auto accepts yum messages.
Thanks for your script, very useful !
Trying to update with my login/pwd in script just downloads plexmediaserver_0.9.12.4.1192-9a47d21_amd64.deb while plexmediaserver_0.9.12.7 is available for plexpass users.
Debian 8
plexupdate says my server is in use so it can't bother to AUTOINSTALL.
root@plex-cinema:/opt/plexupdate# ./plexupdate.sh
Authenticating...OK
Finding download URL to download...OK
File already exists (plexmediaserver_1.0.3.2461-35f0caa_amd64.deb), won't download.
Server 127.0.0.1 is currently being used by one or more users, skipping installation. Please run again later
I confirm it is not in use.
plexupdate runs a wget to my PLEXSERVER, but the server is rejecting the request due to invalid credentials.
root@plex-cinema:/opt/plexupdate# ./plexupdate.sh
Authenticating...OK
Finding download URL to download...OK
File already exists (plexmediaserver_1.0.3.2461-35f0caa_amd64.deb), won't download.
--2016-07-29 21:31:06-- https://127.0.0.1:32400/status/sessions
Connecting to 127.0.0.1:32400... connected.
The certificate's owner does not match hostname โ127.0.0.1โ
HTTP request sent, awaiting response... 401 Unauthorized
Username/Password Authentication Failed.
Server 127.0.0.1 is currently being used by one or more users, skipping installation. Please run again later
From Plex
Jul 29, 2016 21:38:05.927 [0x7fc1167ff700] DEBUG - Request: [::ffff:127.0.0.1:50380] GET /status/sessions (12 live) TLS
Jul 29, 2016 21:38:05.930 [0x7fc1237ff700] DEBUG - Completed: [::ffff:127.0.0.1:50380] 401 GET /status/sessions (12 live) TLS 2ms 260 bytes
I have: PlexPass, 127.0.0.1 and LAN subnet entered in "List of networks that are allowed without auth", I have Home setup.
It could very well be because Home is setup; and if that's the case, maybe do a RESULTCODE for 401 and warn about Home; if it is Home, then I will just disable the check and do it live ๐ I'm unwilling to disable Home right now to confirm though.
I also found these when I was making the output more verbose, but probably resulted from making some commands more verbose.
./plexupdate.sh: line 373: [: -eq: unary operator expected
./plexupdate.sh: line 376: [: -ne: unary operator expected
If you're using a .plexupdate
configuration file in your home directory and that file specifies the release with RELEASE=
, then be sure to change it from RELEASE=64-bit
to RELEASE=64
. Otherwise you'll get the error Sorry, page layout must have changed, I'm unable to retrieve the URL needed for download
.
Thanks for a great script, however there are other distributions besides Ubuntu, yet it still downloads the deb-file when ran on CentOS.
Unfortunately just replacing .deb with .rpm didn't work as the naming convention is slightly different for CentOS/RHEL and my sed-mojo is not strong enough to overcome the problem.
Here's what I get when replacing .deb with .rpm:
Authenticating...OK
Finding download URL for 64-bit...OK
Downloading release "plexmediaserver-0.9.9.10.458-008ea34.x86_64.rpm"...
!! Download failed with code 8, "--2014-05-20 14:14:36-- http://downloads.plexapp.com/plex-media-server/0.9.9.10.458-008ea34/plexmediaserver-0.9.9.10.458-008ea34.x86_64.rpm%0Ahttp://downloads.plexapp.com/plex-media-server/0.9.9.10.458-008ea34/plexmediaserver-0.9.9.10.458-008ea34.x86_64.rpm
Resolving downloads.plexapp.com... 64.71.188.199
Connecting to downloads.plexapp.com|64.71.188.199|:80... connected.
HTTP request sent, awaiting response... 404 Not Found
2014-05-20 14:14:36 ERROR 404: Not Found."
PS. I think you can check wherever the script is running on CentOS/RHEL/OUL by checking if the file /etc/redhat-release exists.
Ran the script with AUTOINSTALL=yes but got stuck waiting to replace plexmediaserver.conf
Configuration file '/etc/init/plexmediaserver.conf'
==> File on system created by you or by a script.
==> File also in package provided by package maintainer.
Perhaps
Dpkg::Options {
"--force-confdef";
"--force-confold";
};
or similar, https://debian-handbook.info/browse/stable/sect.automatic-upgrades.html
I'm struggling to understand what scenario -c is actually meant for.
Every cron implementation I've used just ignores exit codes completely, so -c would seem to have nothing at all to do with "cron". It looks like it was mostly meant to reconcile what @hakong wanted in #62 (which doesn't seem directly cron related to me) vs #73.
What I'm wanting to accomplish (without adding yet another command line option) is just a cron mode that only produces output when something has changed. If you have the latest version, no output. If you don't have the latest version, produce output on STDOUT. If there's an error (regardless of if there's a new version or not) produce output on STDERR.
This way, -q and -S actually become useful modifiers to -c, whereas they currently largely replace it. (running with -cq is functionally identical to running with -q inside cron).
I'm happy to send in a PR for this functionality, I just wanted to bring this up ahead of time to make sure that I'm not stepping on any toes by doing so (or missing something obvious).
I made a .plexupdate file with my info in it but i keep getting this:
plexupdate.sh: 92: [: no: unexpected operator
plexupdate.sh: 121: [: [email protected]: unexpected operator
plexupdate.sh: 126: [: no: unexpected operator
plexupdate.sh: 149: plexupdate.sh: Syntax error: Bad for loop variable
Any ideas?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.