From 4e91d842a111df0a362d29eb27b55e272074e437 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 14:49:51 -0500 Subject: [PATCH 01/16] Adding -r parameter for autostart of service This will be an optional parameter that will be useful for RHEL/CentOS, and potentially other distributions. --- plexupdate.sh | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/plexupdate.sh b/plexupdate.sh index 63e9e93..7e7f1b6 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -55,6 +55,7 @@ PUBLIC=no AUTOINSTALL=no AUTODELETE=no AUTOUPDATE=no +AUTOSTART=no # Sanity, make sure wget is in our path... wget >/dev/null 2>/dev/null @@ -88,6 +89,7 @@ do (-p) PUBLIC=yes;; (-u) AUTOUPDATE=yes;; (-U) AUTOUPDATE=no;; + (-r) AUTOSTART=no;; (--) ;; (-*) echo "Error: unrecognized option $1" 1>&2; exit 1;; (*) break;; @@ -310,4 +312,12 @@ if [ "${AUTODELETE}" == "yes" ]; then fi fi +if [ "${AUTOSTART}" == "yes" ]; then + if [ "${AUTOSTART}" == "yes" ]; then + service plexmediaserver start + else + echo "Will not attempt to auto start plexmediaserver service without [-r] restart" + fi +fi + exit 0 From adc53be37d4b0a00704e00f94a6f28c9c89f6da3 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 17:04:54 -0500 Subject: [PATCH 02/16] Fixed AUTOSTART parameter default value --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 7e7f1b6..e3ae6c3 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -89,7 +89,7 @@ do (-p) PUBLIC=yes;; (-u) AUTOUPDATE=yes;; (-U) AUTOUPDATE=no;; - (-r) AUTOSTART=no;; + (-r) AUTOSTART=yes;; (--) ;; (-*) echo "Error: unrecognized option $1" 1>&2; exit 1;; (*) break;; From d75c8c20cb5a37d14f3d47bba1e992a748927ef3 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 17:23:23 -0500 Subject: [PATCH 03/16] Update plexupdate.sh --- plexupdate.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/plexupdate.sh b/plexupdate.sh index e3ae6c3..1a6cf7f 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -320,4 +320,5 @@ if [ "${AUTOSTART}" == "yes" ]; then fi fi +echo $REDHAT exit 0 From 32b53de62ae018c167c3c44edd97081f560658a5 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 17:46:40 -0500 Subject: [PATCH 04/16] AUTOSTART [-s] cleanup Changed AUTOSTART to [-s], which makes more sense. Added RedHat/CentOS warning to suggest using -s Cleaned AUTOSTART segment and added a warning when this option is being used but may not be needed. --- plexupdate.sh | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 1a6cf7f..42e42df 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -89,7 +89,7 @@ do (-p) PUBLIC=yes;; (-u) AUTOUPDATE=yes;; (-U) AUTOUPDATE=no;; - (-r) AUTOSTART=yes;; + (-s) AUTOSTART=yes;; (--) ;; (-*) echo "Error: unrecognized option $1" 1>&2; exit 1;; (*) break;; @@ -263,6 +263,7 @@ SKIP_DOWNLOAD="no" # Installed version detection (only supported for deb based systems, feel free to submit rpm equivalent) if [ "${REDHAT}" != "yes" ]; then + echo "Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes." INSTALLED_VERSION=$(dpkg-query -s plexmediaserver 2>/dev/null | grep -Po 'Version: \K.*') else INSTALLED_VERSION=$(rpm -qv plexmediaserver 2>/dev/null) @@ -299,7 +300,7 @@ if [ "${AUTOINSTALL}" == "yes" ]; then if [ "${REDHAT}" == "yes" ]; then sudo yum -y install "${DOWNLOADDIR}/${FILENAME}" else - sudo dpkg -i "${DOWNLOADDIR}/${FILENAME}" + sudo dpkg -i "${DOWNLOADDIR}/${FILENAME}" if [ "${AUTOINSTALL}" == "yes" ]; then fi fi @@ -313,12 +314,11 @@ if [ "${AUTODELETE}" == "yes" ]; then fi if [ "${AUTOSTART}" == "yes" ]; then - if [ "${AUTOSTART}" == "yes" ]; then - service plexmediaserver start - else - echo "Will not attempt to auto start plexmediaserver service without [-r] restart" + if [ "${REDHAT}" == "no" ]; if [ "${AUTOINSTALL}" == "yes" ]; then + then + echo "The AUTOSTART [-s] option may not be needed on your distribution." fi + service plexmediaserver start fi -echo $REDHAT exit 0 From c2727b9485f186f3fb7919759a68fb3ba470fafc Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 17:53:51 -0500 Subject: [PATCH 05/16] Fixed Typo --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 42e42df..40e5406 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -300,7 +300,7 @@ if [ "${AUTOINSTALL}" == "yes" ]; then if [ "${REDHAT}" == "yes" ]; then sudo yum -y install "${DOWNLOADDIR}/${FILENAME}" else - sudo dpkg -i "${DOWNLOADDIR}/${FILENAME}" if [ "${AUTOINSTALL}" == "yes" ]; then + sudo dpkg -i "${DOWNLOADDIR}/${FILENAME}" fi fi From 9cb98c2853a4d58ac98ddd7df9d2893dde541365 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 17:55:27 -0500 Subject: [PATCH 06/16] Removed mistake mistake --- plexupdate.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 40e5406..e130c82 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -315,7 +315,6 @@ fi if [ "${AUTOSTART}" == "yes" ]; then if [ "${REDHAT}" == "no" ]; if [ "${AUTOINSTALL}" == "yes" ]; then - then echo "The AUTOSTART [-s] option may not be needed on your distribution." fi service plexmediaserver start From 3408308c9d0a951fdf992eea640c157dbbf9e6bc Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 17:58:29 -0500 Subject: [PATCH 07/16] Removed redundant if, added sudo to service cmd --- plexupdate.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index e130c82..36c362a 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -314,10 +314,10 @@ if [ "${AUTODELETE}" == "yes" ]; then fi if [ "${AUTOSTART}" == "yes" ]; then - if [ "${REDHAT}" == "no" ]; if [ "${AUTOINSTALL}" == "yes" ]; then + if [ "${REDHAT}" == "no" ]; then echo "The AUTOSTART [-s] option may not be needed on your distribution." fi - service plexmediaserver start + sudo service plexmediaserver start fi exit 0 From b08b63c39ee1987b4616c4a8de0f866b00c48888 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 19:51:39 -0500 Subject: [PATCH 08/16] Added check for root in AUTOSTART The script never should get to the point of trying to restart a reinstalled service if it wasn't installed with sudo, but it's a good idea to have this check regardless. --- plexupdate.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plexupdate.sh b/plexupdate.sh index 36c362a..f540ccc 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -320,4 +320,18 @@ if [ "${AUTOSTART}" == "yes" ]; then sudo service plexmediaserver start fi +if [ "${AUTOSTART}" == "yes" then + if [ "${REDHAT}" == "no" ]; then + echo "The AUTOSTART [-s] option may not be needed on your distribution." + fi + id | grep 'uid=0(' 2>&1 >/dev/null + if [ $? -ne 0 ]; then + echo "Error: You need to be root to use autoinstall option." + exit 1 + elif [ "${REDHAT}" == "no" ]; then + echo "The AUTOSTART [-s] option may not be needed on your distribution." + fi + sudo service plexmediaserver start +fi + exit 0 From a619b1221e7bd6943d03a204ac5038803bd4ac04 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 19:53:36 -0500 Subject: [PATCH 09/16] Removed then on elif --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index f540ccc..f3891dd 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -328,7 +328,7 @@ if [ "${AUTOSTART}" == "yes" then if [ $? -ne 0 ]; then echo "Error: You need to be root to use autoinstall option." exit 1 - elif [ "${REDHAT}" == "no" ]; then + elif [ "${REDHAT}" == "no" ]; echo "The AUTOSTART [-s] option may not be needed on your distribution." fi sudo service plexmediaserver start From b10ecd84c388e8f684806859b7ab250f9cb5f25a Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 19:54:56 -0500 Subject: [PATCH 10/16] Update plexupdate.sh --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index f3891dd..6ea385d 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -328,7 +328,7 @@ if [ "${AUTOSTART}" == "yes" then if [ $? -ne 0 ]; then echo "Error: You need to be root to use autoinstall option." exit 1 - elif [ "${REDHAT}" == "no" ]; + elif [ "${REDHAT}" == "no" ] echo "The AUTOSTART [-s] option may not be needed on your distribution." fi sudo service plexmediaserver start From e3a9c963eed102dd1304ea16fa19821e086d07f1 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 19:56:57 -0500 Subject: [PATCH 11/16] Update plexupdate.sh --- plexupdate.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 6ea385d..e845e81 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -328,7 +328,8 @@ if [ "${AUTOSTART}" == "yes" then if [ $? -ne 0 ]; then echo "Error: You need to be root to use autoinstall option." exit 1 - elif [ "${REDHAT}" == "no" ] + fi + if [ "${REDHAT}" == "no" ]; then echo "The AUTOSTART [-s] option may not be needed on your distribution." fi sudo service plexmediaserver start From 6ccfc08bd242c5c5e36040a4af669f4c0b717860 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 19:58:21 -0500 Subject: [PATCH 12/16] Update plexupdate.sh --- plexupdate.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index e845e81..68306b5 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -320,7 +320,7 @@ if [ "${AUTOSTART}" == "yes" ]; then sudo service plexmediaserver start fi -if [ "${AUTOSTART}" == "yes" then +if [ "${AUTOSTART}" == "yes"]; then if [ "${REDHAT}" == "no" ]; then echo "The AUTOSTART [-s] option may not be needed on your distribution." fi @@ -328,8 +328,7 @@ if [ "${AUTOSTART}" == "yes" then if [ $? -ne 0 ]; then echo "Error: You need to be root to use autoinstall option." exit 1 - fi - if [ "${REDHAT}" == "no" ]; then + elif [ "${REDHAT}" == "no" ]; then echo "The AUTOSTART [-s] option may not be needed on your distribution." fi sudo service plexmediaserver start From e2481e64428a9e582960ee0678d4c89357e86710 Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 22:13:11 -0500 Subject: [PATCH 13/16] Update plexupdate.sh --- plexupdate.sh | 2 -- 1 file changed, 2 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 68306b5..c3d050e 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -328,8 +328,6 @@ if [ "${AUTOSTART}" == "yes"]; then if [ $? -ne 0 ]; then echo "Error: You need to be root to use autoinstall option." exit 1 - elif [ "${REDHAT}" == "no" ]; then - echo "The AUTOSTART [-s] option may not be needed on your distribution." fi sudo service plexmediaserver start fi From 859be63643925b240a466206d20124b2932d9d5d Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 22:14:28 -0500 Subject: [PATCH 14/16] Update plexupdate.sh --- plexupdate.sh | 7 ------- 1 file changed, 7 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index c3d050e..8db9181 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -313,13 +313,6 @@ if [ "${AUTODELETE}" == "yes" ]; then fi fi -if [ "${AUTOSTART}" == "yes" ]; then - if [ "${REDHAT}" == "no" ]; then - echo "The AUTOSTART [-s] option may not be needed on your distribution." - fi - sudo service plexmediaserver start -fi - if [ "${AUTOSTART}" == "yes"]; then if [ "${REDHAT}" == "no" ]; then echo "The AUTOSTART [-s] option may not be needed on your distribution." From bed1a7bdef02cc98de1b847dfd82ec808c6da5eb Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 22:44:02 -0500 Subject: [PATCH 15/16] That space has been hiding from me.... --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 8db9181..3f10b88 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -313,7 +313,7 @@ if [ "${AUTODELETE}" == "yes" ]; then fi fi -if [ "${AUTOSTART}" == "yes"]; then +if [ "${AUTOSTART}" == "yes" ]; then if [ "${REDHAT}" == "no" ]; then echo "The AUTOSTART [-s] option may not be needed on your distribution." fi From 4c48237be5440573da37cfe7b7e52dea98eef97b Mon Sep 17 00:00:00 2001 From: Devin Slick Date: Fri, 23 Oct 2015 22:48:50 -0500 Subject: [PATCH 16/16] Clean up the if statements in AUTOSTART --- plexupdate.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index 3f10b88..b1fadb4 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -314,13 +314,12 @@ if [ "${AUTODELETE}" == "yes" ]; then fi if [ "${AUTOSTART}" == "yes" ]; then - if [ "${REDHAT}" == "no" ]; then - echo "The AUTOSTART [-s] option may not be needed on your distribution." - fi id | grep 'uid=0(' 2>&1 >/dev/null if [ $? -ne 0 ]; then echo "Error: You need to be root to use autoinstall option." exit 1 + elif [ "${REDHAT}" == "no" ]; then + echo "The AUTOSTART [-s] option may not be needed on your distribution." fi sudo service plexmediaserver start fi