From 9fc45daa260a8125cc117394d902998abd367dc9 Mon Sep 17 00:00:00 2001 From: myellen Date: Wed, 28 Nov 2018 12:48:23 -0500 Subject: [PATCH 01/25] Update plex-core to support synology packages checks DISTRO variable in getPlexVersion and parseVersion --- plexupdate-core | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/plexupdate-core b/plexupdate-core index d0ec57e..eea5cd6 100755 --- a/plexupdate-core +++ b/plexupdate-core @@ -228,13 +228,17 @@ isNewerVersion() { parseVersion() { if [ "${REDHAT}" = "yes" ]; then cut -f2- -d- <<< "$1" | cut -f1-4 -d. + elif [ "${DISTRO}" = "synology" ]; then + cut -f2 -d- <<< "$1" else cut -f2 -d_ <<< "$1" fi } getPlexVersion() { - if [ "${REDHAT}" != "yes" ]; then + if [ "${DISTRO}" = "synology" ]; then + synopkg version "Plex Media Server" 2>/dev/null + elif [ "${REDHAT}" != "yes" ]; then dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null elif hash rpm 2>/dev/null; then local rpmtemp From 117f92269d8c796e2c6dc9ea957fa0dd9042b117 Mon Sep 17 00:00:00 2001 From: myellen Date: Wed, 28 Nov 2018 16:19:02 -0500 Subject: [PATCH 02/25] include build identifier in FILE_VERSION change cut to return field 2 and 3 instead of just 2 --- plexupdate-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate-core b/plexupdate-core index eea5cd6..5da6fa1 100755 --- a/plexupdate-core +++ b/plexupdate-core @@ -229,7 +229,7 @@ parseVersion() { if [ "${REDHAT}" = "yes" ]; then cut -f2- -d- <<< "$1" | cut -f1-4 -d. elif [ "${DISTRO}" = "synology" ]; then - cut -f2 -d- <<< "$1" + cut -f2-3 -d- <<< "$1" else cut -f2 -d_ <<< "$1" fi From 9124a438ce1fdf1e36c371632cd26e8b09b611e9 Mon Sep 17 00:00:00 2001 From: myellen Date: Tue, 12 Feb 2019 11:46:47 -0500 Subject: [PATCH 03/25] detect synology update plexupdate.sh to automatically determine if we're running on a synology --- plexupdate.sh | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/plexupdate.sh b/plexupdate.sh index 80002be..e59edea 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -307,6 +307,20 @@ if [ -z "${DISTRO_INSTALL}" ]; then else DISTRO_INSTALL="${REDHAT_INSTALL}" fi + elif [ -f /etc/synoinfo.conf ]; then + DISTRO="synology" + if [ "${PUBLIC}" = "yes" ]; then + if [ "${ARCH}" = "x86_64"]; then + BUILD="linux-ubuntu-x86_64" + elif [ "${ARCH}" = "x86"]; then + BUILD="linux-synology-i686" + elif [ "${ARCH}" = "armv7"]; then + BUILD="linux-synology-armv7" + fi + else + BUILD="linux-${ARCH}" + fi + DISTRO_INSTALL="synopkg install" else REDHAT=no DISTRO="debian" From 5bfb7d45e83081f1b9a6ed02b1f04538d1210dbc Mon Sep 17 00:00:00 2001 From: myellen Date: Tue, 12 Feb 2019 11:59:19 -0500 Subject: [PATCH 04/25] update installer.sh add ability to detect if running on synology in installer.sh --- extras/installer.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/extras/installer.sh b/extras/installer.sh index 5f0967a..672070d 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -42,6 +42,9 @@ check_distro() { elif hash apt-get 2>/dev/null; then DISTRO="debian" DISTRO_INSTALL="apt-get install" + elif [ -f /etc/synoinfo.conf ]; then + DISTRO="synology" + DISTRO_INSTALL="synopkg install" else DISTRO="unknown" fi From a5d183fe5fc6358cd0109daaf27decf625d56209 Mon Sep 17 00:00:00 2001 From: myellen Date: Sun, 12 May 2019 00:42:45 -0400 Subject: [PATCH 05/25] add spaces add spaces before closing brackets --- plexupdate.sh | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index e59edea..a64a116 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -310,11 +310,11 @@ if [ -z "${DISTRO_INSTALL}" ]; then elif [ -f /etc/synoinfo.conf ]; then DISTRO="synology" if [ "${PUBLIC}" = "yes" ]; then - if [ "${ARCH}" = "x86_64"]; then + if [ "${ARCH}" = "x86_64" ]; then BUILD="linux-ubuntu-x86_64" - elif [ "${ARCH}" = "x86"]; then + elif [ "${ARCH}" = "x86" ]; then BUILD="linux-synology-i686" - elif [ "${ARCH}" = "armv7"]; then + elif [ "${ARCH}" = "armv7" ]; then BUILD="linux-synology-armv7" fi else From b6fc5403f490ad4ea344ffa647c4a6afc8560029 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 5 Jun 2019 14:46:52 -0400 Subject: [PATCH 06/25] indent with tabs instead of spaces changed spaces to tabs --- plexupdate.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index a64a116..c6f8c26 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -308,14 +308,14 @@ if [ -z "${DISTRO_INSTALL}" ]; then DISTRO_INSTALL="${REDHAT_INSTALL}" fi elif [ -f /etc/synoinfo.conf ]; then - DISTRO="synology" - if [ "${PUBLIC}" = "yes" ]; then - if [ "${ARCH}" = "x86_64" ]; then - BUILD="linux-ubuntu-x86_64" + DISTRO="synology" + if [ "${PUBLIC}" = "yes" ]; then + if [ "${ARCH}" = "x86_64" ]; then + BUILD="linux-ubuntu-x86_64" elif [ "${ARCH}" = "x86" ]; then - BUILD="linux-synology-i686" + BUILD="linux-synology-i686" elif [ "${ARCH}" = "armv7" ]; then - BUILD="linux-synology-armv7" + BUILD="linux-synology-armv7" fi else BUILD="linux-${ARCH}" From ec89f905473c40c028b07b14b5e91672ee4fee50 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 5 Jun 2019 15:02:24 -0400 Subject: [PATCH 07/25] remove old build values remove check for plexpass version as now public versions also use new build versions. --- plexupdate.sh | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/plexupdate.sh b/plexupdate.sh index c6f8c26..12c562d 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -309,17 +309,7 @@ if [ -z "${DISTRO_INSTALL}" ]; then fi elif [ -f /etc/synoinfo.conf ]; then DISTRO="synology" - if [ "${PUBLIC}" = "yes" ]; then - if [ "${ARCH}" = "x86_64" ]; then - BUILD="linux-ubuntu-x86_64" - elif [ "${ARCH}" = "x86" ]; then - BUILD="linux-synology-i686" - elif [ "${ARCH}" = "armv7" ]; then - BUILD="linux-synology-armv7" - fi - else - BUILD="linux-${ARCH}" - fi + BUILD="linux-${ARCH}" DISTRO_INSTALL="synopkg install" else REDHAT=no From 70888ea8bd081cf738f74d0df3d4ad21bc561569 Mon Sep 17 00:00:00 2001 From: myellen Date: Wed, 5 Jun 2019 19:48:15 -0400 Subject: [PATCH 08/25] remove redundant line of code BUILD="linux-${ARCH}" is already done at line 56 Co-Authored-By: Alex Malinovich --- plexupdate.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 12c562d..2ad4731 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -309,7 +309,6 @@ if [ -z "${DISTRO_INSTALL}" ]; then fi elif [ -f /etc/synoinfo.conf ]; then DISTRO="synology" - BUILD="linux-${ARCH}" DISTRO_INSTALL="synopkg install" else REDHAT=no From 1aba28a7f0b681da9f70e3fe1dc47fd62c9a27b8 Mon Sep 17 00:00:00 2001 From: myellen Date: Wed, 5 Jun 2019 23:21:44 -0400 Subject: [PATCH 09/25] Add synology section to readme MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add link to "How to add Plex’s package signing public key to Synology NAS Package Center" --- README.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/README.md b/README.md index 1559db5..12a6579 100755 --- a/README.md +++ b/README.md @@ -19,6 +19,12 @@ If you'd ever like to change your configuration, just re-run the installer from If you have any trouble with the installer, or would just prefer to set plexupdate up manually, [read the guide](https://github.com/mrworf/plexupdate/wiki/Manually-installing-plexupdate). +## Synology Installation + +Before installing on a Synology NAS, you will need to follow the instructions in the Plex support article [How to add Plex’s package signing public key to Synology NAS Package Center](https://support.plex.tv/articles/205165858-how-to-add-plex-s-package-signing-public-key-to-synology-nas-package-center/). + +Then you can follow the regular installation instructions as normal. + # Advanced options There are a few additional options for the more enterprising user. Setting any of these to `yes` will enable the function. From 3e25035a19949f55eca4f2569ff612b66d884f63 Mon Sep 17 00:00:00 2001 From: Alex Malinovich Date: Wed, 5 Jun 2019 20:58:54 -0700 Subject: [PATCH 10/25] Remove REDHAT variable and use DISTRO instead --- plexupdate-core | 10 +++++----- plexupdate.sh | 8 +++----- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/plexupdate-core b/plexupdate-core index 5da6fa1..fedae8a 100755 --- a/plexupdate-core +++ b/plexupdate-core @@ -226,7 +226,7 @@ isNewerVersion() { } parseVersion() { - if [ "${REDHAT}" = "yes" ]; then + if [ "${DISTRO}" = "redhat" ]; then cut -f2- -d- <<< "$1" | cut -f1-4 -d. elif [ "${DISTRO}" = "synology" ]; then cut -f2-3 -d- <<< "$1" @@ -236,11 +236,11 @@ parseVersion() { } getPlexVersion() { - if [ "${DISTRO}" = "synology" ]; then - synopkg version "Plex Media Server" 2>/dev/null - elif [ "${REDHAT}" != "yes" ]; then + if [ "${DISTRO}" = "debian" ]; then dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null - elif hash rpm 2>/dev/null; then + elif [ "${DISTRO}" = "synology" ]; then + synopkg version "Plex Media Server" 2>/dev/null + elif [ "${DISTRO}" = "redhat" ]; then local rpmtemp if rpmtemp=$(rpm -q plexmediaserver); then parseVersion "$rpmtemp" diff --git a/plexupdate.sh b/plexupdate.sh index 2ad4731..5dc2e4e 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -300,7 +300,6 @@ if [ -z "${DISTRO_INSTALL}" ]; then if [ -z "${DISTRO}" ]; then # Detect if we're running on redhat instead of ubuntu if [ -f /etc/redhat-release ]; then - REDHAT=yes DISTRO="redhat" if ! hash dnf 2>/dev/null; then DISTRO_INSTALL="${REDHAT_INSTALL/dnf/yum}" @@ -311,7 +310,6 @@ if [ -z "${DISTRO_INSTALL}" ]; then DISTRO="synology" DISTRO_INSTALL="synopkg install" else - REDHAT=no DISTRO="debian" DISTRO_INSTALL="${DEBIAN_INSTALL}" fi @@ -427,7 +425,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 @@ -486,7 +484,7 @@ if [ -n "${PLEXSERVER}" -a "${AUTOINSTALL}" = "yes" ]; then fi if [ "${AUTOINSTALL}" = "yes" ]; then - if ! hash ldconfig 2>/dev/null && [ "${REDHAT}" = "no" ]; then + if ! hash ldconfig 2>/dev/null && [ "${DISTRO}" != "redhat" ]; then export PATH=$PATH:/sbin fi @@ -509,7 +507,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 From cc9ee5cf44f9289a71a43207729527b6bfbdd03e Mon Sep 17 00:00:00 2001 From: myellen Date: Thu, 13 Jun 2019 03:09:10 -0400 Subject: [PATCH 11/25] Add message to add plex certificate in error --- plexupdate.sh | 3 +++ 1 file changed, 3 insertions(+) diff --git a/plexupdate.sh b/plexupdate.sh index 5dc2e4e..84ce866 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -493,6 +493,9 @@ if [ "${AUTOINSTALL}" = "yes" ]; then if [ ${RET} -ne 0 ]; then # Clarify why this failed, so user won't be left in the dark error "Failed to install update. Command '${DISTRO_INSTALL} "${DOWNLOADDIR}/${FILENAME}"' returned error code ${RET}" + if [ "${DISTRO}" = "synology" -a ${RET} -eq 1 ]; then + info "On Synology devices, you need to add Plex's public key to Package Center. If you have not done so, follow the instructions at \033[0;34mhttps://support.plex.tv/articles/205165858-how-to-add-plex-s-package-signing-public-key-to-synology-nas-package-center/\033[0m" + fi exit ${RET} fi fi From cb33e7b67fa2c43a072935ab7f8a4c181cb2b2cb Mon Sep 17 00:00:00 2001 From: myellen Date: Thu, 13 Jun 2019 03:11:53 -0400 Subject: [PATCH 12/25] change info to echo -e --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 84ce866..7b87a89 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -494,7 +494,7 @@ if [ "${AUTOINSTALL}" = "yes" ]; then # Clarify why this failed, so user won't be left in the dark error "Failed to install update. Command '${DISTRO_INSTALL} "${DOWNLOADDIR}/${FILENAME}"' returned error code ${RET}" if [ "${DISTRO}" = "synology" -a ${RET} -eq 1 ]; then - info "On Synology devices, you need to add Plex's public key to Package Center. If you have not done so, follow the instructions at \033[0;34mhttps://support.plex.tv/articles/205165858-how-to-add-plex-s-package-signing-public-key-to-synology-nas-package-center/\033[0m" + echo -e "On Synology devices, you need to add Plex's public key to Package Center. If you have not done so, follow the instructions at \033[0;34mhttps://support.plex.tv/articles/205165858-how-to-add-plex-s-package-signing-public-key-to-synology-nas-package-center/\033[0m" fi exit ${RET} fi From 6f40555c9acd396a17d27d61b46a2966372e3c40 Mon Sep 17 00:00:00 2001 From: myellen Date: Thu, 13 Jun 2019 03:25:38 -0400 Subject: [PATCH 13/25] add synology handling to AUTOSTART --- plexupdate.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/plexupdate.sh b/plexupdate.sh index 7b87a89..88ee4eb 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -520,6 +520,8 @@ if [ "${AUTOSTART}" = "yes" ]; then service plexmediaserver start elif [ -x /etc/init.d/plexmediaserver ]; then /etc/init.d/plexmediaserver start + elif [ "${DISTRO}" = "synology" ]; then + synopkg start "Plex Media Server" else error "AUTOSTART was specified but no startup scripts were found for 'plexmediaserver'." exit 1 From 569adbb85746939c0d977f0fcd896fa202afe4d1 Mon Sep 17 00:00:00 2001 From: myellen Date: Thu, 13 Jun 2019 03:39:20 -0400 Subject: [PATCH 14/25] do not show plexpass password on entry use -s option "do not echo input coming from a terminal" to hide password --- plexupdate-core | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate-core b/plexupdate-core index fedae8a..7baeff1 100755 --- a/plexupdate-core +++ b/plexupdate-core @@ -51,7 +51,7 @@ getPlexToken() { fi done while true; do - read -e -p "PlexPass Password: " -i "$PASS" PASS + read -e -s -p "PlexPass Password: " -i "$PASS" PASS if [ -z "$PASS" ]; then info "Please provide a password" else From 335cf829573fa35f56a92effc92a570f0d567825 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 14 Jun 2019 11:53:17 -0500 Subject: [PATCH 15/25] remove color from error message --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 88ee4eb..5b03f3a 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -494,7 +494,7 @@ if [ "${AUTOINSTALL}" = "yes" ]; then # Clarify why this failed, so user won't be left in the dark error "Failed to install update. Command '${DISTRO_INSTALL} "${DOWNLOADDIR}/${FILENAME}"' returned error code ${RET}" if [ "${DISTRO}" = "synology" -a ${RET} -eq 1 ]; then - echo -e "On Synology devices, you need to add Plex's public key to Package Center. If you have not done so, follow the instructions at \033[0;34mhttps://support.plex.tv/articles/205165858-how-to-add-plex-s-package-signing-public-key-to-synology-nas-package-center/\033[0m" + error "On Synology devices, you need to add Plex's public key to Package Center. If you have not done so, follow the instructions at https://support.plex.tv/articles/205165858-how-to-add-plex-s-package-signing-public-key-to-synology-nas-package-center/" fi exit ${RET} fi From 2c91c80a5899c9c2c8e0fb37598887f6f362d1d4 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 14 Jun 2019 13:04:35 -0400 Subject: [PATCH 16/25] enable AUTOSTART for synology --- extras/installer.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/extras/installer.sh b/extras/installer.sh index 672070d..e7df4c8 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -186,6 +186,8 @@ configure_plexupdate() { [ -z "$DISTRO" ] && check_distro if [ "$DISTRO" == "redhat" ]; then AUTOSTART=yes + elif [ "$DISTRO" == "synology" ]; then + AUTOSTART=yes else AUTOSTART= fi From 848f56c9af8e387970fb6a4c3f5a6002179e29c1 Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 14 Jun 2019 21:51:30 -0400 Subject: [PATCH 17/25] dont repeat code --- extras/installer.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/extras/installer.sh b/extras/installer.sh index e7df4c8..fe249b2 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -184,9 +184,7 @@ configure_plexupdate() { AUTOINSTALL=yes [ -z "$DISTRO" ] && check_distro - if [ "$DISTRO" == "redhat" ]; then - AUTOSTART=yes - elif [ "$DISTRO" == "synology" ]; then + if [ "$DISTRO" == "redhat" -o "$DISTRO" == "synology" ]; then AUTOSTART=yes else AUTOSTART= From e5b65cec370f0fb598c810bd3ca6af822671121b Mon Sep 17 00:00:00 2001 From: Max Date: Fri, 14 Jun 2019 21:55:09 -0400 Subject: [PATCH 18/25] enable AUTODELETE by default --- extras/installer.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/installer.sh b/extras/installer.sh index fe249b2..d182187 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -182,7 +182,8 @@ configure_plexupdate() { if yesno "$AUTOINSTALL"; then AUTOINSTALL=yes - + AUTODELETE=yes + [ -z "$DISTRO" ] && check_distro if [ "$DISTRO" == "redhat" -o "$DISTRO" == "synology" ]; then AUTOSTART=yes From 508e7dd184a034cecf23ed9c553b776a9e079daa Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 19 Jun 2019 14:39:19 -0400 Subject: [PATCH 19/25] Update cron support Use new crontab file file in cron.d instead of cron.daily to support more devices --- extras/installer.sh | 39 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 37 insertions(+), 2 deletions(-) diff --git a/extras/installer.sh b/extras/installer.sh index d182187..4ea108b 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -4,7 +4,8 @@ ORIGIN_REPO="https://github.com/${GIT_OWNER:-mrworf}/plexupdate" FULL_PATH="/opt/plexupdate" CONFIGFILE="/etc/plexupdate.conf" CONFIGCRON="/etc/plexupdate.cron.conf" -CRONWRAPPER="/etc/cron.daily/plexupdate" +CRONWRAPPER="/etc/cron.d/plexupdate" +CRONWRAPPER_LEGACY="/etc/cron.daily/plexupdate" VERBOSE=yes #to be inherited by get-plex-token, do not save to config # default options @@ -240,6 +241,11 @@ configure_cron() { return 1 fi + if [ -f "CRONWRAPPER_LEGACY" -a ! -L "CRONWRAPPER_LEGACY" ]; then + echo "It seems like you have a custom cron job for plexupdate. Skipping cron job configuration." + return 1 + fi + [ -f "$CONFIGCRON" ] && source "$CONFIGCRON" echo @@ -278,7 +284,14 @@ configure_cron() { echo echo -n "Installing daily cron job... " - sudo ln -sf "${FULL_PATH}/extras/cronwrapper" "$CRONWRAPPER" + #changes go here + schedule=$(grep "cron.daily" crontab) + if [ -z "$schedule" ]; then + schedule="0 4 * * * " + else + schedule=${schedule%%root*} + fi + save_cronjob "${schedule}root $(which sh) ${FULL_PATH}/extras/cronwrapper" "$CRONWRAPPER" echo "done" elif [ -f "$CRONWRAPPER" -o -f "$CONFIGCRON" ]; then echo @@ -291,6 +304,28 @@ configure_cron() { fi echo done fi + + if [ -f "$CRONWRAPPER_LEGACY" ]; then + sudo rm "$CRONWRAPPER_LEGACY" || echo "Failed to remove old cron configuration, please check '$CRONWRAPPER_LEGACY'" + fi +} + +save_cronjob() { + CONFIGTEMP=$(mktemp /tmp/plexupdate.XXX) + echo "#minute hour mday month wday who command" >> $CONFIGTEMP + echo "$1" >> $CONFIGTEMP + + echo + echo -n "Writing cron job file '$2'... " + + # most likely writing to /etc, so we need sudo + sudo tee "$2" > /dev/null < "$CONFIGTEMP" + sudo chmod 640 "$2" + # only root can modify the config, but the user can still read it + sudo chown 0:$(id -g) "$2" + rm "$CONFIGTEMP" + + echo "done" } save_config() { From 35fea182304b5cdc10dda8b6379066266cc61ad8 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 19 Jun 2019 15:19:24 -0400 Subject: [PATCH 20/25] Add PATH variable to cron file --- extras/installer.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/extras/installer.sh b/extras/installer.sh index 4ea108b..9ed9816 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -287,7 +287,7 @@ configure_cron() { #changes go here schedule=$(grep "cron.daily" crontab) if [ -z "$schedule" ]; then - schedule="0 4 * * * " + schedule="0 4 * * * " else schedule=${schedule%%root*} fi @@ -312,6 +312,7 @@ configure_cron() { save_cronjob() { CONFIGTEMP=$(mktemp /tmp/plexupdate.XXX) + echo "$(grep "PATH=" /etc/crontab)" >> $CONFIGTEMP echo "#minute hour mday month wday who command" >> $CONFIGTEMP echo "$1" >> $CONFIGTEMP From e9cecfcc963e8feb1e8d3c50db1966dd3c9c7f9a Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 19 Jun 2019 15:25:41 -0400 Subject: [PATCH 21/25] remove duplicated code for saving config --- extras/installer.sh | 20 +++++++------------- 1 file changed, 7 insertions(+), 13 deletions(-) diff --git a/extras/installer.sh b/extras/installer.sh index 9ed9816..92fcf2e 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -316,17 +316,7 @@ save_cronjob() { echo "#minute hour mday month wday who command" >> $CONFIGTEMP echo "$1" >> $CONFIGTEMP - echo - echo -n "Writing cron job file '$2'... " - - # most likely writing to /etc, so we need sudo - sudo tee "$2" > /dev/null < "$CONFIGTEMP" - sudo chmod 640 "$2" - # only root can modify the config, but the user can still read it - sudo chown 0:$(id -g) "$2" - rm "$CONFIGTEMP" - - echo "done" + save_config_tmp "$CONFIGTEMP" "$2" } save_config() { @@ -337,15 +327,19 @@ save_config() { fi done + save_config_tmp "$CONFIGTEMP" "$2" +} + +save_config_tmp() { echo echo -n "Writing configuration file '$2'... " # most likely writing to /etc, so we need sudo - sudo tee "$2" > /dev/null < "$CONFIGTEMP" + sudo tee "$2" > /dev/null < "$1" sudo chmod 640 "$2" # only root can modify the config, but the user can still read it sudo chown 0:$(id -g) "$2" - rm "$CONFIGTEMP" + rm "$1" echo "done" } From fa31574de7da96168300fbc42e565d55a37cfe34 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 19 Jun 2019 15:27:11 -0400 Subject: [PATCH 22/25] remove comment --- extras/installer.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/extras/installer.sh b/extras/installer.sh index 92fcf2e..b72be64 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -284,7 +284,7 @@ configure_cron() { echo echo -n "Installing daily cron job... " - #changes go here + schedule=$(grep "cron.daily" crontab) if [ -z "$schedule" ]; then schedule="0 4 * * * " From 26c65ff71189a198125a81613d277d863c81c623 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 19 Jun 2019 15:33:59 -0400 Subject: [PATCH 23/25] Also copy MAILTO from crontab --- extras/installer.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/extras/installer.sh b/extras/installer.sh index b72be64..9545f16 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -312,6 +312,7 @@ configure_cron() { save_cronjob() { CONFIGTEMP=$(mktemp /tmp/plexupdate.XXX) + echo "$(grep "MAILTO=" /etc/crontab)" >> $CONFIGTEMP echo "$(grep "PATH=" /etc/crontab)" >> $CONFIGTEMP echo "#minute hour mday month wday who command" >> $CONFIGTEMP echo "$1" >> $CONFIGTEMP From a83f077d4ae0b18ab0b7ada14095c7c332d68fe8 Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 19 Jun 2019 15:48:37 -0400 Subject: [PATCH 24/25] move around cron file creation Easier to see what /etc/cron.d/plexupdate will look like --- extras/installer.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/extras/installer.sh b/extras/installer.sh index 9545f16..538726f 100755 --- a/extras/installer.sh +++ b/extras/installer.sh @@ -291,7 +291,7 @@ configure_cron() { else schedule=${schedule%%root*} fi - save_cronjob "${schedule}root $(which sh) ${FULL_PATH}/extras/cronwrapper" "$CRONWRAPPER" + save_cronjob "$schedule" "$CRONWRAPPER" echo "done" elif [ -f "$CRONWRAPPER" -o -f "$CONFIGCRON" ]; then echo @@ -315,7 +315,7 @@ save_cronjob() { echo "$(grep "MAILTO=" /etc/crontab)" >> $CONFIGTEMP echo "$(grep "PATH=" /etc/crontab)" >> $CONFIGTEMP echo "#minute hour mday month wday who command" >> $CONFIGTEMP - echo "$1" >> $CONFIGTEMP + echo "${1}root $(which sh) ${FULL_PATH}/extras/cronwrapper" >> $CONFIGTEMP save_config_tmp "$CONFIGTEMP" "$2" } From c2037952a6a3e00134bdb5956567164e808bf23e Mon Sep 17 00:00:00 2001 From: Max Date: Wed, 19 Jun 2019 16:11:24 -0400 Subject: [PATCH 25/25] suppress AUTOSTART warning for synology AUTOSTART is needed on synology --- plexupdate.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 5b03f3a..8d7ce37 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -510,7 +510,7 @@ if [ "${AUTODELETE}" = "yes" ]; then fi if [ "${AUTOSTART}" = "yes" ]; then - if [ "${DISTRO}" != "redhat" ]; then + if [ "${DISTRO}" != "redhat" -a "${DISTRO}" != "synology" ]; then warn "The AUTOSTART [-s] option may not be needed on your distribution." fi # Check for systemd