5 Ubuntu: Run plexupdate.sh from cron
Henric Andersson edited this page 2016-12-11 14:07:44 -08:00

Deprecated

Please use installer.sh found under extras/ which will do this for you and also guide you through the process so you get automatic updates, etc.


Some assumptions, which MUST be replaced with correct values for your system:

  1. Your username on your machine is john
  2. You want to download and install the latest plex every week if one is available
  3. You don't want to keep the downloaded packages
  4. Your account on https://plex.tv is:
    • email: john.doe@void.com
    • password: aw3$0m3!

If I see issues filed where part of the problem is that you copy-n-pasted without reading, I'll close the issue with a link to the wiki.

PLEASE READ THE ENTIRE ARTICLE AND MAKE APPROPRIATE CHANGES, THANK YOU

Step 1: Download plexupdate

If you don't have git installed, do so now by issuing sudo apt-get install git

Next, make a copy of the latest version into your home directory

cd ~
git clone https://github.com/mrworf/plexupdate.git

Step 2: Configuration

Let's create your config file for plexupdate.sh

nano -w ~/plexupdate.conf

Copy-n-paste the next section (but make necessary changes for your own login and download directory):

USER='john.doe@void.com'
PASS='aw3$0m3!'
DOWNLOADDIR='/home/john/'
AUTOINSTALL=yes
AUTODELETE=yes
AUTOUPDATE=yes
CRON=yes

Hit CTRL-X and answer yes to save the changes as /home/john/plexupdate.conf.

Creating a cron script

To run plexupdate.sh on a schedule, we have to create the cronjob. On ubuntu, this is fairly easy. I'm going to suggest you run the update on a weekly schedule to avoid hammering every day. Feel free to change weekly to any of the other /etc/cron.* however, avoid /etc/cron.d, since it's something else.

Anyway, to open a new file as root:

sudo nano -w /etc/cron.weekly/plexupdate

In this file, you write:

#!/bin/sh

/home/john/plexupdate/plexupdate.sh --config /home/john/plexupdate.conf
exit $?

Hit CTRL-X and answer yes to save the changes. Next, make the file executable:

sudo chmod +x /etc/cron.weekly/plexupdate

The resulting script is run on a weekly basis and by virtue of running via cron, it's ROOT by default, so no need to sudo or otherwise do special tricks. The exit $? simply passes on the exit code from plexupdate.sh to cron.

Notes

  1. Do not forget to change username from john to whatever you're logging in as
  2. Enter you own plexpass credentials, these are obviously fake :-)
  3. This works on ubuntu, might need slight tweaks for other distros (feel free to add new sections describing how)
  4. All paths should be absolute in the configuration file AND in the cron script, or you'll run into issues.