Skip to content

Commit

Permalink
Merge pull request #88 from demonbane/cron-changes
Browse files Browse the repository at this point in the history
Make -c useful again
  • Loading branch information
mrworf committed Aug 16, 2016
2 parents 3bca4b4 + 2ef53f8 commit 482f1d2
Show file tree
Hide file tree
Showing 2 changed files with 96 additions and 85 deletions.
32 changes: 13 additions & 19 deletions README.md
Expand Up @@ -13,43 +13,43 @@ It's fairly easy, but let's take it step by step (if it seems too much, skip to

####Using wget and unzip

You can either download it as a [zip file](https://github.com/mrworf/plexupdate/archive/master.zip) and unzip it on your server.
Download it as a [zip file](https://github.com/mrworf/plexupdate/archive/master.zip) and unzip it on your server.
```
wget https://github.com/mrworf/plexupdate/archive/master.zip && unzip master.zip && mv plexupdate-master plexupdate && rm master.zip
```
Note that unzip is requered (`sudo apt-get install unzip`).

####Using git to clone (Recommended)
Using git is way eaiser and recommended, if you ask me.
Using git is way easier and recommended, if you ask me.
```
git clone https://github.com/mrworf/plexupdate.git
```
Note that git is requered (`sudo apt-get install git-all`)

The main benefit with git clone is that you can update to latest version very easily. *Said in another way*: Auto update only works, if you've done a git clone.
The main benefit with git clone is that you can update to latest version very easily. If you want to use the auto update feature, you must be using a git clone.

## 2. Setting it up

plexupdate.sh looks for a file named `.plexupdate` located in your home directory. Please note that I'm referring to the home directory of the user who is running the plexupdate.sh ... If that user is someone else (root for instance) you'll need to make sure that user has the config file set up properly as well.

The contents of this file usually is
The contents of this file are usually:

```
EMAIL="my.email@plex-server.com"
PASS="my-secret-plex-password"
DOWNLOADDIR="/a/folder/to/save/the/files/in"
```

Obviously you need to change these three so they match your account information. And if you don't put anything as a `DOWNLOADDIR`, the tool will use the folder you're executing the script from. So take care.
Obviously you need to change these so they match your account information. And if you don't put anything as a `DOWNLOADDIR`, the tool will use the folder you're executing the script from. So take care.

## 3. Advanced options

You can point out a different file than ```.plexupdate``` by providing it as the last argument to the script. It HAS to be the LAST argument, or it will be ignored. Any options set by the config file can be overriden with commandline options.
You can point out a different file than ```.plexupdate``` by providing it as the last argument to the script. It HAS to be the LAST argument, or it will be ignored. Any options set by the config file can be overriden with command-line options.

There are also a few additional options for the more enterprising user. Setting any of these to `yes` will enable the function.

- PLEXSERVER
If set, and combined with AUTOINSTALL, the script will automatically check if server is in-use and deferr the update. Great for crontab users. PLEXSERVER should be set to the IP/DNS of your Plex Media Server, which typically is 127.0.0.1
If set, and combined with AUTOINSTALL, the script will automatically check if the server is in-use and deferr the update. Great for crontab users. PLEXSERVER should be set to the IP/DNS of your Plex Media Server, which typically is 127.0.0.1
- AUTOUPDATE
Makes plexupdate.sh automatically update itself using git. Note! This will fail if git isn't available on the command line.
- AUTOINSTALL
Expand All @@ -59,11 +59,11 @@ There are also a few additional options for the more enterprising user. Setting
- PUBLIC
The default behavior of plexupdate.sh is to download the PlexPass edition of Plex Media Center. Setting this option to `yes` will make it download the public version instead. If this is yes, then `EMAIL` and `PASS` is no longer needed.
- FORCE
Normally plexupdate.sh will avoid downloading a file it already has or if it's the same as the installed version, but this allows you to override.
Normally plexupdate.sh will avoid downloading a file it already has or if it's the same as the installed version. Using this option will force it to download again and, if you have AUTOINSTALL set, reinstall it.
- PRINT_URL
Authenticate, fetch the download URL, print it, and then exit.
- DISTRO_INSTALL
The commandline used to install packages, only change if you need special options. Natively supports Debian and Redhat, so need to set this for these systems.
The command used to install packages, only change if you need special options. Natively supports Debian and Redhat, so you don't need to set this for these systems.
NOTE! If you define this, you MUST define DISTRO and BUILD
- DISTRO and BUILD
Override which version to download, use -l option to see what you can select.
Expand All @@ -72,15 +72,9 @@ Most of these options can be specified on the command-line as well, this is just

### Using it from CRON

It seems quite popular to run this via crontab, which is fine. But the behavior of the script has been somewhat, shall we say, annoying.
If you want to use plexupdate as either a cron job or as a [systemd job](https://github.com/mrworf/plexupdate/wiki/Running-plexupdate-daily-as-a-systemd-timer), the -c option should do what you want. All non-error exit codes will be set to 0 and no output will be printed to stdout unless something has actually been done. (a new version was downloaded, installed, etc)

Starting today, the ```-C``` option is deprecated and will give an error to check the docs. The new version is ```-c``` and will make sure that only fatal errors are reported back via the exit code. No more 2, 3, 4 or 5 exitcodes. They are converted into 0. Combining this option with ```-q``` will hide any and all non-essential output from the script as well. Only error messages are emitted, so if it fails, you'll know why.

Take a look at the Wiki, and find the article called [Running plexupdate daily as a systemd timer](https://github.com/mrworf/plexupdate/wiki/Running-plexupdate-daily-as-a-systemd-timer).

## 4. Command-line

I'm going to be lazy, just run the tool with `-h` and you'll find out what you can do. It will basically be a mirror of what section 3 just stated :-)
If you don't even want to know when something has been done, you can combine this with the -q option and you will only receive output in the event of an error. Everything else will just silenty finish without producing any output.

# Running it

Expand Down Expand Up @@ -112,6 +106,6 @@ The username and password for http://plex.tv

## My password is rejected even though correct

If you use certain characters, such as dollar sign, in your password, bash will interpret that as a reference to a variable. To resolve this, enclose your password with single quotes instead of the normal quotes.
If you use certain characters (such as `$`) in your password, bash will interpret that as a reference to a variable. To resolve this, enclose your password within single quotes (`'`) instead of the normal quotes (`"`).

Ie, `PASS="MyP4$$w0rD"` will not work, but changing to it to `PASS='MyP4$$w0rD'` will
i.e. `PASS="MyP4$$w0rD"` will not work, but changing to it to `PASS='MyP4$$w0rD'` will

0 comments on commit 482f1d2

Please sign in to comment.