mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-07-15 09:42:58 -07:00
PlexPass download now work again + bonus
KEEP option is deprecated because of the new TOKEN scheme used by plex.tv If you used KEEP=yes in the past, you would never get PlexPass unless the cookie file was lost. Since I don't track validity of token, it's better to remove keep completely. Also added support to avoid auto install if server is in-use (thanks @AltonV, @hakong and @sufr3ak for the tip) To enable the new feature, please set PLEXSERVER to the IP or DNS of your Plex Media Server (typically 127.0.0.1) The fixes #59
This commit is contained in:
parent
4837eded60
commit
67d780d5ae
2 changed files with 27 additions and 10 deletions
|
@ -32,6 +32,8 @@ You can point out a different file than ```.plexupdate``` by providing it as the
|
|||
|
||||
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
|
||||
- AUTOUPDATE
|
||||
Makes plexupdate.sh automatically update itself using git. Note! This will fail if git isn't available on the command line.
|
||||
- AUTOINSTALL
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
# 3 if page layout has changed.
|
||||
# 4 if download fails
|
||||
# 5 if version already installed
|
||||
# 6 if update was deferred due to usage
|
||||
#
|
||||
# All other return values not documented.
|
||||
#
|
||||
|
@ -41,6 +42,7 @@ fi
|
|||
EMAIL=
|
||||
PASS=
|
||||
DOWNLOADDIR="."
|
||||
PLEXSERVER=
|
||||
|
||||
#################################################################
|
||||
# Don't change anything below this point
|
||||
|
@ -48,7 +50,6 @@ DOWNLOADDIR="."
|
|||
|
||||
# Defaults
|
||||
# (aka "Advanced" settings, can be overriden with config file)
|
||||
KEEP=no
|
||||
FORCE=no
|
||||
PUBLIC=no
|
||||
AUTOINSTALL=no
|
||||
|
@ -138,7 +139,7 @@ cronexit() {
|
|||
}
|
||||
|
||||
usage() {
|
||||
echo "Usage: $(basename $0) [configfile] [-acfhkopqsSuU]"
|
||||
echo "Usage: $(basename $0) [configfile] [-acfhopqsSuU]"
|
||||
echo ""
|
||||
echo " configfile overrides the default ~/.plexupdate"
|
||||
echo " If used, it must be the FIRST option or it will be ignored"
|
||||
|
@ -149,7 +150,6 @@ usage() {
|
|||
echo " -f Force download even if it's the same version or file"
|
||||
echo " already exists (WILL NOT OVERWRITE)"
|
||||
echo " -h This help"
|
||||
echo " -k Reuse last authentication"
|
||||
echo " -l List available builds and distros"
|
||||
echo " -p Public Plex Media Server version"
|
||||
echo " -q Quiet mode. No stdout, only stderr and cronexit codes"
|
||||
|
@ -174,7 +174,6 @@ do
|
|||
(-C) echo "ERROR: CRON option has changed, please review README.md" 1>&2; cronexit 255;;
|
||||
(-d) AUTODELETE=yes;;
|
||||
(-f) FORCE=yes;;
|
||||
(-k) KEEP=yes;;
|
||||
(-l) LISTOPTS=yes;;
|
||||
(-p) PUBLIC=yes;;
|
||||
(-q) QUIET=yes;;
|
||||
|
@ -190,6 +189,11 @@ do
|
|||
shift
|
||||
done
|
||||
|
||||
if [ "${KEEP}" = "yes" ]; then
|
||||
echo "ERROR: KEEP is deprecated" >&2
|
||||
cronexit 1
|
||||
fi
|
||||
|
||||
# send all stdout to /dev/null
|
||||
if [ "${QUIET}" = "yes" ] || [ "${SILENT}" = "yes" ]; then
|
||||
exec 1> /dev/null
|
||||
|
@ -313,9 +317,7 @@ function cleanup {
|
|||
rm /tmp/postdata 2>/dev/null >/dev/null
|
||||
rm /tmp/raw 2>/dev/null >/dev/null
|
||||
rm /tmp/failcause 2>/dev/null >/dev/null
|
||||
if [ "${KEEP}" != "yes" ]; then
|
||||
rm /tmp/kaka 2>/dev/null >/dev/null
|
||||
fi
|
||||
rm /tmp/kaka 2>/dev/null >/dev/null
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
|
@ -329,8 +331,13 @@ trap cleanup EXIT
|
|||
# user[remember_me] 0
|
||||
# commit Sign in
|
||||
|
||||
# Load previous token if stored
|
||||
if [ -f /tmp/kaka_token ]; then
|
||||
TOKEN=$(cat /tmp/kaka_token)
|
||||
fi
|
||||
|
||||
# If user wants, we skip authentication, but only if previous auth exists
|
||||
if [ "${KEEP}" != "yes" -o ! -f /tmp/kaka ] && [ "${PUBLIC}" == "no" ]; then
|
||||
if [ "${PUBLIC}" == "no" ]; then
|
||||
echo -n "Authenticating..."
|
||||
|
||||
# Clean old session
|
||||
|
@ -435,7 +442,7 @@ if [[ $FILENAME == *$INSTALLED_VERSION* ]] && [ "${FORCE}" != "yes" ] && [ ! -z
|
|||
fi
|
||||
|
||||
if [ -f "${DOWNLOADDIR}/${FILENAME}" -a "${FORCE}" != "yes" ]; then
|
||||
echo "File already exists, won't download."
|
||||
echo "File already exists (${FILENAME}), won't download."
|
||||
if [ "${AUTOINSTALL}" != "yes" ]; then
|
||||
cronexit 2
|
||||
fi
|
||||
|
@ -457,6 +464,14 @@ if [ "${SKIP_DOWNLOAD}" == "no" ]; then
|
|||
echo "OK"
|
||||
fi
|
||||
|
||||
if [ ! "${PLEXSERVER}" = "" -a "${AUTOINSTALL}" == "yes" ]; then
|
||||
# Check if server is in-use before continuing (thanks @AltonV, @hakong and @sufr3ak)...
|
||||
if ! wget --no-check-certificate -q -O - https://${PLEXSERVER}:32400/status/sessions | grep -q '<MediaContainer size="0">' ; then
|
||||
echo "Server ${PLEXSERVER} is currently being used by one or more users, skipping installation. Please run again later"
|
||||
cronexit 6
|
||||
fi
|
||||
fi
|
||||
exit 255
|
||||
if [ "${AUTOINSTALL}" == "yes" ]; then
|
||||
sudo ${DISTRO_INSTALL} "${DOWNLOADDIR}/${FILENAME}"
|
||||
fi
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue