mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-20 21:33:16 -07:00
Make CHECKUPDATE check all program files
This commit is contained in:
parent
8383048c01
commit
9de0320185
2 changed files with 27 additions and 28 deletions
|
@ -19,7 +19,7 @@ DEBIAN_INSTALL="dpkg -i"
|
||||||
DISTRO_INSTALL=""
|
DISTRO_INSTALL=""
|
||||||
|
|
||||||
#URL for new version check
|
#URL for new version check
|
||||||
UPSTREAM_GIT_URL="https://raw.githubusercontent.com/${GIT_OWNER:-mrworf}/plexupdate/${BRANCHNAME:-master}/plexupdate.sh"
|
UPSTREAM_GIT_URL="https://raw.githubusercontent.com/${GIT_OWNER:-mrworf}/plexupdate/${BRANCHNAME:-master}"
|
||||||
|
|
||||||
#Files "owned" by plexupdate, for autoupdate
|
#Files "owned" by plexupdate, for autoupdate
|
||||||
PLEXUPDATE_FILES="plexupdate.sh plexupdate-core extras/installer.sh extras/cronwrapper"
|
PLEXUPDATE_FILES="plexupdate.sh plexupdate-core extras/installer.sh extras/cronwrapper"
|
||||||
|
@ -165,6 +165,15 @@ trimQuotes() {
|
||||||
echo $__buffer
|
echo $__buffer
|
||||||
}
|
}
|
||||||
|
|
||||||
|
getRemoteSHA() {
|
||||||
|
(wget -q "$1" -O - 2>/dev/null || return 1) | sha1sum | cut -f1 -d" "
|
||||||
|
}
|
||||||
|
|
||||||
|
getLocalSHA() {
|
||||||
|
[ -f "$1" ] || return 1
|
||||||
|
sha1sum "$1" | cut -f1 -d" "
|
||||||
|
}
|
||||||
|
|
||||||
# RNNG
|
# RNNG
|
||||||
running() {
|
running() {
|
||||||
local DATA="$(wget --no-check-certificate -q -O - https://$1:$3/status/sessions?X-Plex-Token=$2)"
|
local DATA="$(wget --no-check-certificate -q -O - https://$1:$3/status/sessions?X-Plex-Token=$2)"
|
||||||
|
|
|
@ -72,8 +72,7 @@ CHECKONLY=no
|
||||||
|
|
||||||
FILE_SHA=$(mktemp /tmp/plexupdate.sha.XXXX)
|
FILE_SHA=$(mktemp /tmp/plexupdate.sha.XXXX)
|
||||||
FILE_WGETLOG=$(mktemp /tmp/plexupdate.wget.XXXX)
|
FILE_WGETLOG=$(mktemp /tmp/plexupdate.wget.XXXX)
|
||||||
FILE_LOCAL=$(mktemp /tmp/plexupdate.local.XXXX)
|
SCRIPT_PATH="$(dirname "$0")"
|
||||||
FILE_REMOTE=$(mktemp /tmp/plexupdate.remote.XXXX)
|
|
||||||
|
|
||||||
######################################################################
|
######################################################################
|
||||||
|
|
||||||
|
@ -109,16 +108,14 @@ usage() {
|
||||||
exit 0
|
exit 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! source "$(dirname "$0")"/plexupdate-core; then
|
if ! source "${SCRIPT_PATH}/plexupdate-core"; then
|
||||||
echo "ERROR: plexupdate-core can't be found. Please redownload plexupdate and try again." >2
|
echo "ERROR: plexupdate-core can't be found. Please redownload plexupdate and try again." >2
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Setup an exit handler so we cleanup
|
# Setup an exit handler so we cleanup
|
||||||
cleanup() {
|
cleanup() {
|
||||||
for F in "${FILE_SHA}" "${FILE_LOCAL}" "${FILE_REMOTE}" "${FILE_WGETLOG}"; do
|
rm "${FILE_SHA}" "${FILE_WGETLOG}" &> /dev/null
|
||||||
rm "$F" 2>/dev/null >/dev/null
|
|
||||||
done
|
|
||||||
}
|
}
|
||||||
trap cleanup EXIT
|
trap cleanup EXIT
|
||||||
|
|
||||||
|
@ -144,7 +141,7 @@ done
|
||||||
# We have to double-check that both files exist before trying to stat them. This is going away soon.
|
# We have to double-check that both files exist before trying to stat them. This is going away soon.
|
||||||
if [ -z "${CONFIGFILE}" -a -f ~/.plexupdate -a ! -f /etc/plexupdate.conf ] || \
|
if [ -z "${CONFIGFILE}" -a -f ~/.plexupdate -a ! -f /etc/plexupdate.conf ] || \
|
||||||
([ -f "${CONFIGFILE}" -a -f ~/.plexupdate ] && [ `stat -Lc %i "${CONFIGFILE}"` == `stat -Lc %i ~/.plexupdate` ]); then
|
([ -f "${CONFIGFILE}" -a -f ~/.plexupdate ] && [ `stat -Lc %i "${CONFIGFILE}"` == `stat -Lc %i ~/.plexupdate` ]); then
|
||||||
warn ".plexupdate has been deprecated. Please run $(dirname "$0")/extras/installer.sh to update your configuration."
|
warn ".plexupdate has been deprecated. Please run ${SCRIPT_PATH}/extras/installer.sh to update your configuration."
|
||||||
if [ -t 1 ]; then
|
if [ -t 1 ]; then
|
||||||
for i in `seq 1 5`; do echo -n .\ ; sleep 1; done
|
for i in `seq 1 5`; do echo -n .\ ; sleep 1; done
|
||||||
echo .
|
echo .
|
||||||
|
@ -235,7 +232,7 @@ if [ "${AUTOUPDATE}" = "yes" ]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
pushd "$(dirname "$0")" >/dev/null
|
pushd "${SCRIPT_PATH}" >/dev/null
|
||||||
|
|
||||||
if [ ! -d .git ]; then
|
if [ ! -d .git ]; then
|
||||||
warn "This is not a git repository. Auto-update only works if you've done a git clone"
|
warn "This is not a git repository. Auto-update only works if you've done a git clone"
|
||||||
|
@ -334,24 +331,18 @@ else
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${CHECKUPDATE}" = "yes" -a "${AUTOUPDATE}" = "no" ]; then
|
if [ "${CHECKUPDATE}" = "yes" -a "${AUTOUPDATE}" = "no" ]; then
|
||||||
(wget -q "$UPSTREAM_GIT_URL" -O - 2>/dev/null || echo ERROR) | sha1sum >"${FILE_REMOTE}" 2>/dev/null
|
pushd "${SCRIPT_PATH}" > /dev/null
|
||||||
ERR1=$?
|
for filename in $PLEXUPDATE_FILES; do
|
||||||
(cat "$0" 2>/dev/null || echo ERROR) | sha1sum >"${FILE_LOCAL}" 2>/dev/null
|
[ -f "$filename" ] || error "Update check failed. '$filename' could not be found"
|
||||||
ERR2=$?
|
|
||||||
if [ $ERR1 -ne 0 -o $ERR2 -ne 0 ]; then
|
REMOTE_SHA=$(getRemoteSHA "$UPSTREAM_GIT_URL/$filename") || error "Update check failed. Unable to fetch '$UPSTREAM_GIT_URL/$filename'."
|
||||||
error "When checking for version, was unable to confirm version of script"
|
LOCAL_SHA=$(getLocalSHA "$filename")
|
||||||
else
|
if [ "$REMOTE_SHA" != "$LOCAL_SHA" ]; then
|
||||||
# "709c7506b17090bce0d1e2464f39f4a434cf25f1" is the hash for "ERROR" :)
|
info "Newer version of this script is available at https://github.com/${GIT_OWNER:-mrworf}/plexupdate"
|
||||||
if grep -sq "709c7506b17090bce0d1e2464f39f4a434cf25f1" "${FILE_LOCAL}" ; then
|
break
|
||||||
error "When checking for version, was unable to validate local copy"
|
|
||||||
elif grep -sq "709c7506b17090bce0d1e2464f39f4a434cf25f1" "${FILE_REMOTE}" ; then
|
|
||||||
error "When checking for version, was was unable to validate remote copy"
|
|
||||||
elif ! diff "${FILE_LOCAL}" "${FILE_REMOTE}" >/dev/null 2>/dev/null ; then
|
|
||||||
info "Newer version of this script is available at https://github.com/mrworf/plexupdate"
|
|
||||||
fi
|
fi
|
||||||
fi
|
done
|
||||||
rm "${FILE_LOCAL}" 2>/dev/null >/dev/null
|
popd > /dev/null
|
||||||
rm "${FILE_REMOTE}" 2>/dev/null >/dev/null
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${PUBLIC}" = "no" -a -z "$TOKEN" ]; then
|
if [ "${PUBLIC}" = "no" -a -z "$TOKEN" ]; then
|
||||||
|
@ -476,8 +467,7 @@ if [ "${SKIP_DOWNLOAD}" = "no" ]; then
|
||||||
info "File downloaded"
|
info "File downloaded"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
sha1sum --status -c "${FILE_SHA}"
|
if sha1sum --status -c "${FILE_SHA}"; then
|
||||||
if [ $? -ne 0 ]; then
|
|
||||||
error "Downloaded file corrupt. Try again."
|
error "Downloaded file corrupt. Try again."
|
||||||
exit 4
|
exit 4
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue