mirror of
https://github.com/mrworf/plexupdate.git
synced 2025-08-19 12:59:40 -07:00
Move all distro checking logic to plexupdate-core
This commit is contained in:
parent
0065210791
commit
fd540b0325
4 changed files with 32 additions and 40 deletions
BIN
extras/.installer.sh.swp
Normal file
BIN
extras/.installer.sh.swp
Normal file
Binary file not shown.
|
@ -34,6 +34,7 @@ install() {
|
||||||
sleep 1
|
sleep 1
|
||||||
|
|
||||||
[ -z "$DISTRO_INSTALL" ] && check_distro
|
[ -z "$DISTRO_INSTALL" ] && check_distro
|
||||||
|
DISTRO_INSTALL="${DISTRO_INSTALL} 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."
|
||||||
|
@ -42,24 +43,6 @@ install() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
check_distro() {
|
|
||||||
if [ -f /etc/redhat-release ] && hash dnf 2>/dev/null; then
|
|
||||||
DISTRO="redhat"
|
|
||||||
DISTRO_INSTALL="dnf -y install"
|
|
||||||
elif [ -f /etc/redhat-release ] && hash yum 2>/dev/null; then
|
|
||||||
DISTRO="redhat" #or CentOS but functionally the same
|
|
||||||
DISTRO_INSTALL="yum -y install"
|
|
||||||
elif hash apt 2>/dev/null; then
|
|
||||||
DISTRO="debian" #or Ubuntu
|
|
||||||
DISTRO_INSTALL="apt install"
|
|
||||||
elif hash apt-get 2>/dev/null; then
|
|
||||||
DISTRO="debian"
|
|
||||||
DISTRO_INSTALL="apt-get install"
|
|
||||||
else
|
|
||||||
DISTRO="unknown"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
yesno() {
|
yesno() {
|
||||||
case "$1" in
|
case "$1" in
|
||||||
"")
|
"")
|
||||||
|
|
|
@ -12,10 +12,6 @@
|
||||||
URL_LOGIN='https://plex.tv/users/sign_in.json'
|
URL_LOGIN='https://plex.tv/users/sign_in.json'
|
||||||
URL_DOWNLOAD='https://plex.tv/api/downloads/1.json?channel=plexpass'
|
URL_DOWNLOAD='https://plex.tv/api/downloads/1.json?channel=plexpass'
|
||||||
URL_DOWNLOAD_PUBLIC='https://plex.tv/api/downloads/1.json'
|
URL_DOWNLOAD_PUBLIC='https://plex.tv/api/downloads/1.json'
|
||||||
|
|
||||||
# Default options for package managers, override if needed
|
|
||||||
REDHAT_INSTALL="dnf -y install"
|
|
||||||
DEBIAN_INSTALL="dpkg -i"
|
|
||||||
DISTRO_INSTALL=""
|
DISTRO_INSTALL=""
|
||||||
|
|
||||||
#URL for new version check
|
#URL for new version check
|
||||||
|
@ -176,6 +172,28 @@ getLocalSHA() {
|
||||||
sha1sum "$1" | cut -f1 -d" "
|
sha1sum "$1" | cut -f1 -d" "
|
||||||
}
|
}
|
||||||
|
|
||||||
|
check_distro() {
|
||||||
|
if hash dnf 2>/dev/null; then
|
||||||
|
DISTRO=redhat
|
||||||
|
DISTRO_INSTALL="dnf -y"
|
||||||
|
elif hash yum 2>/dev/null; then
|
||||||
|
DISTRO=redhat
|
||||||
|
DISTRO_INSTALL="yum -y"
|
||||||
|
elif hash zypper 2>/dev/null; then
|
||||||
|
DISTRO=redhat
|
||||||
|
DISTRO_INSTALL="zypper -y"
|
||||||
|
elif hash apt 2>/dev/null; then
|
||||||
|
DISTRO=ubuntu
|
||||||
|
DISTRO_INSTALL="apt"
|
||||||
|
elif hash apt-get 2>/dev/null; then
|
||||||
|
DISTRO=ubuntu
|
||||||
|
DISTRO_INSTALL="apt-get -y"
|
||||||
|
else
|
||||||
|
error "Unable to determine distribution, aborting."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# RNNG
|
# RNNG
|
||||||
running() {
|
running() {
|
||||||
# If a server is unclaimed, it probably doesn't have TLS enabled either
|
# If a server is unclaimed, it probably doesn't have TLS enabled either
|
||||||
|
@ -226,7 +244,7 @@ isNewerVersion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
parseVersion() {
|
parseVersion() {
|
||||||
if [ "${REDHAT}" = "yes" ]; then
|
if [ "${DISTRO}" = "redhat" ]; then
|
||||||
cut -f2- -d- <<< "$1" | cut -f1-4 -d.
|
cut -f2- -d- <<< "$1" | cut -f1-4 -d.
|
||||||
else
|
else
|
||||||
cut -f2 -d_ <<< "$1"
|
cut -f2 -d_ <<< "$1"
|
||||||
|
@ -234,7 +252,7 @@ parseVersion() {
|
||||||
}
|
}
|
||||||
|
|
||||||
getPlexVersion() {
|
getPlexVersion() {
|
||||||
if [ "${REDHAT}" != "yes" ]; then
|
if [ "${DISTRO}" != "redhat" ]; then
|
||||||
dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null
|
dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null
|
||||||
elif hash rpm 2>/dev/null; then
|
elif hash rpm 2>/dev/null; then
|
||||||
local rpmtemp
|
local rpmtemp
|
||||||
|
|
|
@ -297,21 +297,12 @@ fi
|
||||||
|
|
||||||
if [ -z "${DISTRO_INSTALL}" ]; then
|
if [ -z "${DISTRO_INSTALL}" ]; then
|
||||||
if [ -z "${DISTRO}" -a -z "${BUILD}" ]; then
|
if [ -z "${DISTRO}" -a -z "${BUILD}" ]; then
|
||||||
# Detect if we're running on redhat instead of ubuntu
|
check_distro
|
||||||
if [ -f /etc/redhat-release ]; then
|
BUILD="linux-ubuntu-${ARCH}"
|
||||||
REDHAT=yes
|
if [ "${FORCE}" = "yes" ]; then
|
||||||
BUILD="linux-ubuntu-${ARCH}"
|
DISTRO_INSTALL="${DISTRO INSTALL} reinstall"
|
||||||
DISTRO="redhat"
|
|
||||||
if ! hash dnf 2>/dev/null; then
|
|
||||||
DISTRO_INSTALL="${REDHAT_INSTALL/dnf/yum}"
|
|
||||||
else
|
|
||||||
DISTRO_INSTALL="${REDHAT_INSTALL}"
|
|
||||||
fi
|
|
||||||
else
|
else
|
||||||
REDHAT=no
|
DISTRO_INSTALL="${DISTRO_INSTALL} install"
|
||||||
BUILD="linux-ubuntu-${ARCH}"
|
|
||||||
DISTRO="ubuntu"
|
|
||||||
DISTRO_INSTALL="${DEBIAN_INSTALL}"
|
|
||||||
fi
|
fi
|
||||||
elif [ -z "${DISTRO}" -o -z "${BUILD}" ]; then
|
elif [ -z "${DISTRO}" -o -z "${BUILD}" ]; then
|
||||||
error "You must define both DISTRO and BUILD"
|
error "You must define both DISTRO and BUILD"
|
||||||
|
@ -428,7 +419,7 @@ INSTALLED_VERSION="$(getPlexVersion)" || warn "Unable to detect installed versio
|
||||||
FILE_VERSION="$(parseVersion "${FILENAME}")"
|
FILE_VERSION="$(parseVersion "${FILENAME}")"
|
||||||
verboseOutput INSTALLED_VERSION FILE_VERSION
|
verboseOutput INSTALLED_VERSION FILE_VERSION
|
||||||
|
|
||||||
if [ "${REDHAT}" = "yes" -a "${AUTOINSTALL}" = "yes" -a "${AUTOSTART}" = "no" ]; then
|
if [ "${DISTRO}" = "redhat" -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
|
||||||
|
|
||||||
|
@ -510,7 +501,7 @@ if [ "${AUTODELETE}" = "yes" ]; then
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "${AUTOSTART}" = "yes" ]; then
|
if [ "${AUTOSTART}" = "yes" ]; then
|
||||||
if [ "${REDHAT}" = "no" ]; then
|
if [ "${DISTRO}" != "redhat" ]; then
|
||||||
warn "The AUTOSTART [-s] option may not be needed on your distribution."
|
warn "The AUTOSTART [-s] option may not be needed on your distribution."
|
||||||
fi
|
fi
|
||||||
# Check for systemd
|
# Check for systemd
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue