Add port variable (#125)

This commit is contained in:
Jon 2016-10-28 00:33:12 -04:00 committed by Henric Andersson
commit c8b6d0a7b3
2 changed files with 11 additions and 5 deletions

View file

@ -46,6 +46,8 @@ There are also a few additional options for the more enterprising user. Setting
- PLEXSERVER
If set, and combined with AUTOINSTALL, the script will automatically check if the server is in-use and defer 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
- PLEXPORT
Sets the port to use along with PLEXSERVER
- AUTOUPDATE
Makes plexupdate.sh automatically update itself using git. Note! This will fail if git isn't available on the command line.
- AUTOINSTALL
@ -88,6 +90,8 @@ Several new command line options are available. They can be specified in any ord
This is the folder that the files will be downloaded to.
- ```--server <Plex server address>```
This is the address that Plex Media Server is on. Setting this will enable a check to see if users are on the server prior to the software being updated.
- ```--port <Plex server port>```
This is the port that Plex Media Server uses.
- ```--saveconfig```
Saves the configuration as it is currently. This will take whatever is in the config file, plus whatever is specified on the command line and will save the config file with that information. Any information in the config file that plexupdate.sh does not understand or use WILL BE LOST.

View file

@ -112,6 +112,7 @@ EMAIL=
PASS=
DOWNLOADDIR="."
PLEXSERVER=
PLEXPORT=32400
#################################################################
# Don't change anything below this point
@ -193,7 +194,7 @@ usage() {
}
running() {
local DATA="$(wget --no-check-certificate -q -O - https://$1:32400/status/sessions?X-Plex-Token=$2)"
local DATA="$(wget --no-check-certificate -q -O - https://$1:$3/status/sessions?X-Plex-Token=$2)"
local RET=$?
if [ ${RET} -eq 0 ]; then
if [ -z "${DATA}" ]; then
@ -240,7 +241,7 @@ fi
# Parse commandline
ALLARGS=( "$@" )
optstring="acCdfFhlpPqrSsuU -l config:,dldir:,email:,pass:,server:,saveconfig"
optstring="acCdfFhlpPqrSsuU -l config:,dldir:,email:,pass:,server:,port:,saveconfig"
getopt -T >/dev/null
if [ $? -eq 4 ]; then
optstring="-o $optstring"
@ -276,6 +277,7 @@ do
(--email) shift; EMAIL_CL="$1"; EMAIL_CL=$(trimQuotes ${EMAIL_CL});;
(--pass) shift; PASS_CL="$1"; PASS_CL=$(trimQuotes ${PASS_CL});;
(--server) shift; PLEXSERVER_CL="$1"; PLEXSERVER_CL=$(trimQuotes ${PLEXSERVER_CL});;
(--port) shift; PLEXPORT_CL="$1"; PLEXPORT_CL=$(trimQuotes ${PLEXPORT_CL});;
(--saveconfig) SAVECONFIG=yes;;
(--) ;;
@ -347,7 +349,7 @@ fi
# any values in the configuration file. As a result, we need to check if they've been set on the command line
# and overwrite the values that may have been loaded with the config file
for VAR in AUTOINSTALL CRON AUTODELETE DOWNLOADDIR EMAIL PASS FORCE FORCEALL PUBLIC QUIET AUTOSTART AUTOUPDATE PLEXSERVER
for VAR in AUTOINSTALL CRON AUTODELETE DOWNLOADDIR EMAIL PASS FORCE FORCEALL PUBLIC QUIET AUTOSTART AUTOUPDATE PLEXSERVER PLEXPORT
do
VAR2="$VAR""_CL"
if [ ! -z ${!VAR2} ]; then
@ -360,7 +362,7 @@ done
if [ "${SAVECONFIG}" = "yes" ]; then
echo "# Config file for plexupdate" >${CONFIGFILE:="${HOME}/.plexupdate"}
for VAR in AUTOINSTALL CRON AUTODELETE DOWNLOADDIR EMAIL PASS FORCE FORCEALL PUBLIC QUIET AUTOSTART AUTOUPDATE PLEXSERVER
for VAR in AUTOINSTALL CRON AUTODELETE DOWNLOADDIR EMAIL PASS FORCE FORCEALL PUBLIC QUIET AUTOSTART AUTOUPDATE PLEXSERVER PLEXPORT
do
if [ ! -z ${!VAR} ]; then
@ -715,7 +717,7 @@ fi
if [ ! -z "${PLEXSERVER}" -a "${AUTOINSTALL}" = "yes" ]; then
# Check if server is in-use before continuing (thanks @AltonV, @hakong and @sufr3ak)...
if running ${PLEXSERVER} ${TOKEN} ; then
if running ${PLEXSERVER} ${TOKEN} ${PLEXPORT}; then
errorLog "Server ${PLEXSERVER} is currently being used by one or more users, skipping installation. Please run again later"
cronexit 6
fi