mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-20 13:23:21 -07:00
Merge 180fc1687f
into 92c151dd7d
This commit is contained in:
commit
deedfe7e07
3 changed files with 69 additions and 24 deletions
|
@ -24,6 +24,8 @@ install() {
|
||||||
|
|
||||||
if [ $EUID -ne 0 ]; then
|
if [ $EUID -ne 0 ]; then
|
||||||
sudo $DISTRO_INSTALL $1 || abort "Failed while trying to install '$1'. Please install it manually and try again."
|
sudo $DISTRO_INSTALL $1 || abort "Failed while trying to install '$1'. Please install it manually and try again."
|
||||||
|
else
|
||||||
|
$DISTRO_INSTALL $1 || abort "Failed while trying to install '$1'. Please install it manually and try again."
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -112,12 +114,12 @@ install_plexupdate() {
|
||||||
echo -n "'$FULL_PATH' doesn't exist, attempting to create... "
|
echo -n "'$FULL_PATH' doesn't exist, attempting to create... "
|
||||||
if ! mkdir -p "$FULL_PATH" 2>/dev/null; then
|
if ! mkdir -p "$FULL_PATH" 2>/dev/null; then
|
||||||
sudo mkdir -p "$FULL_PATH" || abort "failed, cannot continue"
|
sudo mkdir -p "$FULL_PATH" || abort "failed, cannot continue"
|
||||||
sudo chown $(id -un):$(id -gn) "$FULL_PATH" || abort "failed, cannot continue"
|
sudo chown $(id -u):$(id -g) "$FULL_PATH" || abort "failed, cannot continue"
|
||||||
fi
|
fi
|
||||||
echo "done"
|
echo "done"
|
||||||
elif [ ! -w "$FULL_PATH" ]; then
|
elif [ ! -w "$FULL_PATH" ]; then
|
||||||
echo -n "'$FULL_PATH' exists, but you don't have permission to write to it. Changing owner... "
|
echo -n "'$FULL_PATH' exists, but you don't have permission to write to it. Changing owner... "
|
||||||
sudo chown $(id -un):$(id -gn) "$FULL_PATH" || abort "failed, cannot continue"
|
sudo chown $(id -u):$(id -g) "$FULL_PATH" || abort "failed, cannot continue"
|
||||||
echo "done"
|
echo "done"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -302,7 +304,7 @@ save_config() {
|
||||||
sudo tee "$2" > /dev/null < "$CONFIGTEMP"
|
sudo tee "$2" > /dev/null < "$CONFIGTEMP"
|
||||||
sudo chmod 640 "$2"
|
sudo chmod 640 "$2"
|
||||||
# only root can modify the config, but the user can still read it
|
# only root can modify the config, but the user can still read it
|
||||||
sudo chown 0:$(id -gn) "$2"
|
sudo chown 0:$(id -g) "$2"
|
||||||
rm "$CONFIGTEMP"
|
rm "$CONFIGTEMP"
|
||||||
|
|
||||||
echo "done"
|
echo "done"
|
||||||
|
|
|
@ -210,6 +210,53 @@ verifyToken() {
|
||||||
wget -qO /dev/null "https://plex.tv/api/resources?X-Plex-Token=${TOKEN}"
|
wget -qO /dev/null "https://plex.tv/api/resources?X-Plex-Token=${TOKEN}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
isNewerVersion() {
|
||||||
|
# Returns true ONLY if 1 > 2.
|
||||||
|
[ -z "$1" ] && return 1
|
||||||
|
[ -z "$2" ] && return
|
||||||
|
[ "$1" = "$2" ] && return 1
|
||||||
|
if hash dpkg 2>/dev/null; then
|
||||||
|
dpkg --compare-versions "$1" gt "$2"
|
||||||
|
elif sort -V --version &>/dev/null; then
|
||||||
|
[ "$(printf "$1\n$2" | sort -Vr | head -n1)" = "$1" ]
|
||||||
|
else
|
||||||
|
# sort has had -V since at least 2009, so nobody should ever see this
|
||||||
|
warn "Unable to compare version numbers, assuming '$1' is newer."
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
parseVersion() {
|
||||||
|
if [ "${REDHAT}" = "yes" ]; then
|
||||||
|
cut -f2- -d- <<< "$1" | cut -f1-4 -d.
|
||||||
|
else
|
||||||
|
cut -f2 -d_ <<< "$1"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlexVersion() {
|
||||||
|
if [ "${REDHAT}" != "yes" ]; then
|
||||||
|
dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null
|
||||||
|
elif hash rpm 2>/dev/null; then
|
||||||
|
local rpmtemp
|
||||||
|
if rpmtemp=$(rpm -q plexmediaserver); then
|
||||||
|
parseVersion "$rpmtemp"
|
||||||
|
else
|
||||||
|
return 1
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
error "Unknown OS, exiting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
|
verboseOutput() {
|
||||||
|
if [ "$VERBOSE" = "yes" ]; then
|
||||||
|
for i in $@; do
|
||||||
|
info "$i=${!i}"
|
||||||
|
done
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Shared functions
|
# Shared functions
|
||||||
|
|
||||||
# SHARED
|
# SHARED
|
||||||
|
|
|
@ -228,8 +228,13 @@ if [ "${AUTOUPDATE}" = "yes" ]; then
|
||||||
elif ! git diff --quiet; then
|
elif ! git diff --quiet; then
|
||||||
warn "You have made changes to the plexupdate files, cannot auto update"
|
warn "You have made changes to the plexupdate files, cannot auto update"
|
||||||
else
|
else
|
||||||
|
if [ -z "${BRANCHNAME}" ]; then
|
||||||
|
BRANCHNAME="$(git symbolic-ref -q --short HEAD)"
|
||||||
|
elif [ "${BRANCHNAME}" != "$(git symbolic-ref -q --short HEAD)" ]; then
|
||||||
|
git checkout "${BRANCHNAME}"
|
||||||
|
fi
|
||||||
# Force FETCH_HEAD to point to the correct branch (for older versions of git which don't default to current branch)
|
# Force FETCH_HEAD to point to the correct branch (for older versions of git which don't default to current branch)
|
||||||
if git fetch origin ${BRANCHNAME:-master} --quiet && ! git diff --quiet FETCH_HEAD; then
|
if git fetch origin ${BRANCHNAME} --quiet && ! git diff --quiet FETCH_HEAD; then
|
||||||
info "Auto-updating..."
|
info "Auto-updating..."
|
||||||
|
|
||||||
# Use an associative array to store permissions. If you're running bash < 4, the declare will fail and we'll
|
# Use an associative array to store permissions. If you're running bash < 4, the declare will fail and we'll
|
||||||
|
@ -385,11 +390,7 @@ RELEASE=$(grep -ioe '"label"[^}]*' <<<"${wgetresults}" | grep -i "\"distro\":\"$
|
||||||
DOWNLOAD=$(echo ${RELEASE} | grep -m1 -ioe 'https://[^\"]*')
|
DOWNLOAD=$(echo ${RELEASE} | grep -m1 -ioe 'https://[^\"]*')
|
||||||
CHECKSUM=$(echo ${RELEASE} | grep -ioe '\"checksum\"\:\"[^\"]*' | sed 's/\"checksum\"\:\"//')
|
CHECKSUM=$(echo ${RELEASE} | grep -ioe '\"checksum\"\:\"[^\"]*' | sed 's/\"checksum\"\:\"//')
|
||||||
|
|
||||||
if [ "$VERBOSE" = "yes" ]; then
|
verboseOutput RELEASE DOWNLOAD CHECKSUM
|
||||||
for i in RELEASE DOWNLOAD CHECKSUM; do
|
|
||||||
info "$i=${!i}"
|
|
||||||
done
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ -z "${DOWNLOAD}" ]; then
|
if [ -z "${DOWNLOAD}" ]; then
|
||||||
if [ "$DISTRO" = "ubuntu" -a "$BUILD" = "linux-ubuntu-armv7l" ]; then
|
if [ "$DISTRO" = "ubuntu" -a "$BUILD" = "linux-ubuntu-armv7l" ]; then
|
||||||
|
@ -423,30 +424,25 @@ fi
|
||||||
# By default, try downloading
|
# By default, try downloading
|
||||||
SKIP_DOWNLOAD="no"
|
SKIP_DOWNLOAD="no"
|
||||||
|
|
||||||
# Installed version detection
|
INSTALLED_VERSION="$(getPlexVersion)" || warn "Unable to detect installed version, first time?"
|
||||||
if [ "${REDHAT}" != "yes" ]; then
|
FILE_VERSION="$(parseVersion "${FILENAME}")"
|
||||||
INSTALLED_VERSION=$(dpkg-query -s plexmediaserver 2>/dev/null | grep -Po 'Version: \K.*')
|
verboseOutput INSTALLED_VERSION FILE_VERSION
|
||||||
else
|
|
||||||
if [ "${AUTOINSTALL}" = "yes" -a "${AUTOSTART}" = "no" ]; then
|
if [ "${REDHAT}" = "yes" -a "${AUTOINSTALL}" = "yes" -a "${AUTOSTART}" = "no" ]; then
|
||||||
warn "Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes."
|
warn "Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes."
|
||||||
fi
|
fi
|
||||||
INSTALLED_VERSION=$(rpm -qv plexmediaserver 2>/dev/null)
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [ "${CHECKONLY}" = "yes" ]; then
|
if [ "${CHECKONLY}" = "yes" ]; then
|
||||||
if [ -z "${INSTALLED_VERSION}" ]; then
|
if [ -n "${INSTALLED_VERSION}" ] && isNewerVersion "$FILE_VERSION" "$INSTALLED_VERSION"; then
|
||||||
warn "Unable to detect installed version, first time?"
|
info "Your OS reports Plex $INSTALLED_VERSION installed, newer version is available (${FILE_VERSION})"
|
||||||
elif [[ $FILENAME != *$INSTALLED_VERSION* ]]; then
|
|
||||||
AVAIL="$(echo "${FILENAME}" | sed -nr 's/^[^0-9]+([0-9]+\.[0-9]+\.[0-9]+\.[0-9]+\-[^_]+).*/\1/pg')"
|
|
||||||
info "Your OS reports Plex $INSTALLED_VERSION installed, newer version is available (${AVAIL})"
|
|
||||||
exit 7
|
exit 7
|
||||||
else
|
elif [ -n "${INSTALLED_VERSION}" ]; then
|
||||||
info "You are running the latest version of Plex (${INSTALLED_VERSION})"
|
info "You are running the latest version of Plex (${INSTALLED_VERSION})"
|
||||||
fi
|
fi
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ $FILENAME == *$INSTALLED_VERSION* ]] && [ "${FORCE}" != "yes" ] && [ ! -z "${INSTALLED_VERSION}" ]; then
|
if ! isNewerVersion "$FILE_VERSION" "$INSTALLED_VERSION" && [ "${FORCE}" != "yes" ]; then
|
||||||
info "Your OS reports the latest version of Plex ($INSTALLED_VERSION) is already installed. Use -f to force download."
|
info "Your OS reports the latest version of Plex ($INSTALLED_VERSION) is already installed. Use -f to force download."
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue