diff --git a/extras/.installer.sh.swp b/extras/.installer.sh.swp new file mode 100644 index 0000000..9562561 Binary files /dev/null and b/extras/.installer.sh.swp differ diff --git a/extras/installer.sh b/extras/installer.sh index 712555b..b94bbae 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -34,6 +34,7 @@ install() { sleep 1 [ -z "$DISTRO_INSTALL" ] && check_distro + DISTRO_INSTALL="${DISTRO_INSTALL} install" if [ $EUID -ne 0 ]; then sudo $DISTRO_INSTALL $1 || abort "Failed while trying to install '$1'. Please install it manually and try again." @@ -42,24 +43,6 @@ install() { 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() { case "$1" in "") diff --git a/plexupdate-core b/plexupdate-core index 334e909..aea1ff5 100755 --- a/plexupdate-core +++ b/plexupdate-core @@ -12,10 +12,6 @@ URL_LOGIN='https://plex.tv/users/sign_in.json' URL_DOWNLOAD='https://plex.tv/api/downloads/1.json?channel=plexpass' 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="" #URL for new version check @@ -176,6 +172,28 @@ getLocalSHA() { 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 running() { # If a server is unclaimed, it probably doesn't have TLS enabled either @@ -226,7 +244,7 @@ isNewerVersion() { } parseVersion() { - if [ "${REDHAT}" = "yes" ]; then + if [ "${DISTRO}" = "redhat" ]; then cut -f2- -d- <<< "$1" | cut -f1-4 -d. else cut -f2 -d_ <<< "$1" @@ -234,7 +252,7 @@ parseVersion() { } getPlexVersion() { - if [ "${REDHAT}" != "yes" ]; then + if [ "${DISTRO}" != "redhat" ]; then dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null elif hash rpm 2>/dev/null; then local rpmtemp diff --git a/plexupdate.sh b/plexupdate.sh index c9d46ca..7eff8ea 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -297,21 +297,12 @@ fi if [ -z "${DISTRO_INSTALL}" ]; then if [ -z "${DISTRO}" -a -z "${BUILD}" ]; then - # Detect if we're running on redhat instead of ubuntu - if [ -f /etc/redhat-release ]; then - REDHAT=yes - BUILD="linux-ubuntu-${ARCH}" - DISTRO="redhat" - if ! hash dnf 2>/dev/null; then - DISTRO_INSTALL="${REDHAT_INSTALL/dnf/yum}" - else - DISTRO_INSTALL="${REDHAT_INSTALL}" - fi + check_distro + BUILD="linux-ubuntu-${ARCH}" + if [ "${FORCE}" = "yes" ]; then + DISTRO_INSTALL="${DISTRO INSTALL} reinstall" else - REDHAT=no - BUILD="linux-ubuntu-${ARCH}" - DISTRO="ubuntu" - DISTRO_INSTALL="${DEBIAN_INSTALL}" + DISTRO_INSTALL="${DISTRO_INSTALL} install" fi elif [ -z "${DISTRO}" -o -z "${BUILD}" ]; then 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}")" 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." fi @@ -510,7 +501,7 @@ if [ "${AUTODELETE}" = "yes" ]; then fi if [ "${AUTOSTART}" = "yes" ]; then - if [ "${REDHAT}" = "no" ]; then + if [ "${DISTRO}" != "redhat" ]; then warn "The AUTOSTART [-s] option may not be needed on your distribution." fi # Check for systemd