From 653588d43cff70c7be483c0149cc413945610993 Mon Sep 17 00:00:00 2001 From: Henric Andersson Date: Fri, 6 Nov 2015 08:55:56 -0800 Subject: [PATCH 1/5] Auto update now handles some more obscure situations Launch plexupdate using "bash plexupdate.sh" will not cause the autoupdate function to fail anymore. Also tries to handle the error if it would fail. --- plexupdate.sh | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 2adcf1c..35ec95a 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -121,7 +121,16 @@ if [ "${AUTOUPDATE}" == "yes" ]; then fi echo "OK" popd >/dev/null - $0 ${ALLARGS} -U + if ! type "$0" 2>/dev/null >/dev/null ; then + if [ -f "$0" ]; then + /bin/bash "$0" ${ALLARGS} -U + else + echo "Error: Unable to relaunch, couldn't find $0" + exit 1 + fi + else + "$0" ${ALLARGS} -U + fi exit $? fi From 5ac1aec075b66981e21cc0307f88d957d7311ac0 Mon Sep 17 00:00:00 2001 From: martijndierckx Date: Sat, 13 Feb 2016 17:08:00 +0100 Subject: [PATCH 2/5] made root check case-insensitive running the script via sudo, kept returning the 'run as root' error. Reason: id returned 'UID=0(root) GID=0(root) groepen=0(root)', while the lower case version was expected --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 35ec95a..62aa46e 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -141,7 +141,7 @@ if [ "${EMAIL}" == "" -o "${PASS}" == "" ] && [ "${PUBLIC}" == "no" ]; then fi if [ "${AUTOINSTALL}" == "yes" -o "${AUTOSTART}" == "yes" ]; then - id | grep 'uid=0(' 2>&1 >/dev/null + id | grep -i 'uid=0(' 2>&1 >/dev/null if [ $? -ne 0 ]; then echo "Error: You need to be root to use autoinstall/autostart option." exit 1 From 17851c65074e1a9bd0b1984fbf4d4231fa07f6dd Mon Sep 17 00:00:00 2001 From: Henric Andersson Date: Fri, 19 Feb 2016 07:45:34 -0800 Subject: [PATCH 3/5] Redid the release detection to be language agnostic Seems like some versions of wget will happily ask for a localized version of the webpage, causing the processing to fail. Now we look for something which remains static regardless of langauge. --- plexupdate.sh | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 62aa46e..0ad6973 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -48,7 +48,7 @@ DOWNLOADDIR="." # Defaults # (aka "Advanced" settings, can be overriden with config file) -RELEASE="64-bit" +RELEASE="64" KEEP=no FORCE=no PUBLIC=no @@ -85,7 +85,7 @@ do (-d) AUTODELETE=yes;; (-f) FORCE=yes;; (-k) KEEP=yes;; - (-o) RELEASE="32-bit";; + (-o) RELEASE="32";; (-p) PUBLIC=yes;; (-u) AUTOUPDATE=yes;; (-U) AUTOUPDATE=no;; @@ -157,12 +157,14 @@ if [ -z "${DOWNLOADDIR}" ]; then fi # Detect if we're running on redhat instead of ubuntu -REDHAT=no; -PKGEXT='.deb' - if [ -f /etc/redhat-release ]; then REDHAT=yes; PKGEXT='.rpm' + RELEASE="Fedora${RELEASE}" +else + REDHAT=no; + PKGEXT='.deb' + RELEASE="Ubuntu${RELEASE}" fi # Useful functions @@ -253,7 +255,7 @@ fi # Extract the URL for our release echo -n "Finding download URL for ${RELEASE}..." -DOWNLOAD=$(wget --load-cookies /tmp/kaka --save-cookies /tmp/kaka --keep-session-cookies "${URL_DOWNLOAD}" -O - 2>/dev/null | grep "${PKGEXT}" | grep -m 1 "${RELEASE}" | sed "s/.*href=\"\([^\"]*\\${PKGEXT}\)\"[^>]*>${RELEASE}.*/\1/" ) +DOWNLOAD=$(wget --load-cookies /tmp/kaka --save-cookies /tmp/kaka --keep-session-cookies "${URL_DOWNLOAD}" -O - 2>/dev/null | grep "${PKGEXT}" | grep -m 1 "${RELEASE}" | sed "s/.*href=\"\([^\"]*\\${PKGEXT}\)\"[^>]*>.*/\1/" ) echo -e "OK" if [ "${DOWNLOAD}" == "" ]; then From 2080649d80cd6a150e26a245efad6fb3a31c3747 Mon Sep 17 00:00:00 2001 From: Henric Andersson Date: Fri, 19 Feb 2016 16:58:52 -0800 Subject: [PATCH 4/5] Now detects legacy settings and converts If you used RELEASE= in the settings file, the change to link detection will cause issues, this new version will warn AND change it back to something useful. --- plexupdate.sh | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/plexupdate.sh b/plexupdate.sh index 0ad6973..6a448d2 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -69,6 +69,17 @@ if [ -f ~/.plexupdate ]; then source ~/.plexupdate fi +if [ "${RELEASE}" = "64-bit" ]; then + echo "WARNING: RELEASE=64-bit is deprecated, use RELEASE=64 instead" + RELEASE="64" +elif [ "${RELEASE}" = "32-bit" ]; then + echo "WARNING: RELEASE=32-bit is deprecated, use RELEASE=32 instead" + RELEASE="32" +elif [ "${RELEASE}" != "64" -a "${RELEASE}" != "32" ]; then + echo "ERROR: Use of RELEASE=${RELEASE} will no longer work" + exit 255 +fi + # Current pages we need - Do not change unless Plex.tv changes again URL_LOGIN=https://plex.tv/users/sign_in URL_DOWNLOAD=https://plex.tv/downloads?channel=plexpass From ab740b9eada0b68d9981cca8534836dbd653a7b3 Mon Sep 17 00:00:00 2001 From: Guillaume Boudreau Date: Tue, 1 Mar 2016 08:40:50 -0500 Subject: [PATCH 5/5] Use absolute path to /sbin/service Sometimes, when using sudo or cron, /sbin might not be in the user's PATH, and thus we need to specify its full path when AUTOSTARTing it. --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 6a448d2..4b00161 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -345,7 +345,7 @@ if [ "${AUTOSTART}" == "yes" ]; then if [ -f "/bin/systemctl" ]; then systemctl start plexmediaserver.service else - service plexmediaserver start + /sbin/service plexmediaserver start fi fi