mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-14 02:26:56 -07:00
commit
815e53122b
2 changed files with 13 additions and 21 deletions
|
@ -180,36 +180,29 @@ getLocalSHA() {
|
|||
running() {
|
||||
# If a server is unclaimed, it probably doesn't have TLS enabled either
|
||||
local DATA
|
||||
# get Plex sessions
|
||||
DATA="$(wget -q -O - http://$1:$2/status/sessions)"
|
||||
local RET=$?
|
||||
# and live TV/DVR sessions
|
||||
DATA+="$(wget -q -O - http://$1:$2/livetv/sessions)"
|
||||
|
||||
if [ ${RET} -eq 6 ]; then
|
||||
# Server may be claimed, in which case we should use TLS and pass a token
|
||||
getPlexToken
|
||||
DATA="$(wget --no-check-certificate -q -O - https://$1:$2/status/sessions?X-Plex-Token=$TOKEN)"
|
||||
RET=$?
|
||||
DATA+="$(wget --no-check-certificate -q -O - https://$1:$2/livetv/sessions?X-Plex-Token=$TOKEN)"
|
||||
fi
|
||||
|
||||
if [ ${RET} -eq 0 ]; then
|
||||
if [ -z "${DATA}" ]; then
|
||||
# Odd, but usually means noone is watching
|
||||
return 1
|
||||
fi
|
||||
echo "${DATA}" | grep -q '<MediaContainer size="0">'
|
||||
if [ $? -eq 1 ]; then
|
||||
# not found means that one or more medias are being played
|
||||
return 0
|
||||
fi
|
||||
return 1
|
||||
elif [ ${RET} -eq 4 ]; then
|
||||
# No response, assume not running
|
||||
return 1
|
||||
else
|
||||
# We do not know what this means...
|
||||
warn "Unknown response (${RET}) from server >>>"
|
||||
warn "${DATA}"
|
||||
return 0
|
||||
# Get a total count of active media (MediaContainer size), then deduct one for every paused stream.
|
||||
# If all streams are paused, we consider the server to not be active.
|
||||
local mediacount="$(awk -F'"' '/<MediaContainer size="[0-9]+">/ {count+=$2}; /<Player[^>]* state="paused"/ {count--}; END {print count}' <<< ${DATA})"
|
||||
[ $mediacount -gt 0 ] && return 0
|
||||
fi
|
||||
|
||||
# if we don't know for sure that Plex is busy, assume that it's not so the update can proceed
|
||||
return 1
|
||||
}
|
||||
|
||||
verifyToken() {
|
||||
|
|
|
@ -72,8 +72,7 @@ usage() {
|
|||
echo ""
|
||||
echo " -a Auto install if download was successful (requires root)"
|
||||
echo " -d Auto delete after auto install"
|
||||
echo " -f Force download even if it's the same version or file"
|
||||
echo " already exists unless checksum passes"
|
||||
echo " -f Force download/update even if the newest release is already installed"
|
||||
echo " -h This help"
|
||||
echo " -l List available builds and distros"
|
||||
echo " -p Public Plex Media Server version"
|
||||
|
@ -452,7 +451,7 @@ if [[ $FILENAME == *$INSTALLED_VERSION* ]] && [ "${FORCE}" != "yes" ] && [ ! -z
|
|||
exit 0
|
||||
fi
|
||||
|
||||
if [ -f "${DOWNLOADDIR}/${FILENAME}" -a "${FORCE}" != "yes" ]; then
|
||||
if [ -f "${DOWNLOADDIR}/${FILENAME}" ]; then
|
||||
if sha1sum --status -c "${FILE_SHA}"; then
|
||||
info "File already exists (${FILENAME}), won't download."
|
||||
if [ "${AUTOINSTALL}" != "yes" ]; then
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue