Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
9fc45da
Update plex-core to support synology packages
myellen Nov 28, 2018
117f922
include build identifier in FILE_VERSION
myellen Nov 28, 2018
9124a43
detect synology
myellen Feb 12, 2019
5bfb7d4
update installer.sh
myellen Feb 12, 2019
a5d183f
add spaces
myellen May 12, 2019
b6fc540
indent with tabs instead of spaces
myellen Jun 5, 2019
ec89f90
remove old build values
myellen Jun 5, 2019
70888ea
remove redundant line of code
myellen Jun 5, 2019
1aba28a
Add synology section to readme
myellen Jun 6, 2019
3e25035
Remove REDHAT variable and use DISTRO instead
demonbane Jun 6, 2019
cc9ee5c
Add message to add plex certificate in error
myellen Jun 13, 2019
cb33e7b
change info to echo -e
myellen Jun 13, 2019
6f40555
add synology handling to AUTOSTART
myellen Jun 13, 2019
569adbb
do not show plexpass password on entry
myellen Jun 13, 2019
335cf82
remove color from error message
myellen Jun 14, 2019
2c91c80
enable AUTOSTART for synology
myellen Jun 14, 2019
848f56c
dont repeat code
myellen Jun 15, 2019
e5b65ce
enable AUTODELETE by default
myellen Jun 15, 2019
508e7dd
Update cron support
myellen Jun 19, 2019
35fea18
Add PATH variable to cron file
myellen Jun 19, 2019
e9cecfc
remove duplicated code for saving config
myellen Jun 19, 2019
fa31574
remove comment
myellen Jun 19, 2019
26c65ff
Also copy MAILTO from crontab
myellen Jun 19, 2019
a83f077
move around cron file creation
myellen Jun 19, 2019
c203795
suppress AUTOSTART warning for synology
myellen Jun 19, 2019
388ff66
Compatibility with Synology DSM7
gapple Aug 6, 2021
ade4ddf
Merge remote-tracking branch 'origin/master' into dsm7
gapple Aug 6, 2021
23ce261
Update installer for Synology DSM7 support
gapple Aug 6, 2021
86c1d9b
Adjust version number parsing for Synology DSM7
gapple Aug 16, 2021
1557355
Detect Synology 7.2+
gapple Nov 5, 2024
4cd0d0e
Fix DSM 7 minor version check
gapple Nov 5, 2024
1da06d8
Update version check for Synology 7.2+
gapple Nov 5, 2024
42efb94
Additional Synology 72 support
gapple Nov 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
53 changes: 47 additions & 6 deletions extras/installer.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -42,6 +43,15 @@ 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"
if grep -q "major=\"7\"" /etc/VERSION; then
DISTRO="synology-dsm72"
if grep -q "minor=\"[01]\"" /etc/VERSION; then
DISTRO="synology-dsm7"
fi
fi
else
DISTRO="unknown"
fi
Expand Down Expand Up @@ -179,9 +189,10 @@ configure_plexupdate() {

if yesno "$AUTOINSTALL"; then
AUTOINSTALL=yes

AUTODELETE=yes

[ -z "$DISTRO" ] && check_distro
if [ "$DISTRO" == "redhat" ]; then
if [ "$DISTRO" == "redhat" -o $(echo "${DISTRO}" | cut -c -8) = "synology" ]; then
AUTOSTART=yes
else
AUTOSTART=
Expand Down Expand Up @@ -236,6 +247,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

if [ -f "$CONFIGCRON" ]; then
#this is redundant since null is evaluated as yes anyway, but including for readability
CRON=yes
Expand Down Expand Up @@ -279,7 +295,14 @@ configure_cron() {

echo
echo -n "Installing daily cron job... "
sudo ln -sf "${FULL_PATH}/extras/cronwrapper" "$CRONWRAPPER"

schedule=$(grep "cron.daily" crontab)
if [ -z "$schedule" ]; then
schedule="0 4 * * * "
else
schedule=${schedule%%root*}
fi
save_cronjob "$schedule" "$CRONWRAPPER"
echo "done"
elif [ -f "$CRONWRAPPER" -o -f "$CONFIGCRON" ]; then
echo
Expand All @@ -292,6 +315,20 @@ 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 "$(grep "MAILTO=" /etc/crontab)" >> $CONFIGTEMP
echo "$(grep "PATH=" /etc/crontab)" >> $CONFIGTEMP
echo "#minute hour mday month wday who command" >> $CONFIGTEMP
echo "${1}root $(which sh) ${FULL_PATH}/extras/cronwrapper" >> $CONFIGTEMP

save_config_tmp "$CONFIGTEMP" "$2"
}

save_config() {
Expand All @@ -302,15 +339,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"
}
Expand Down
16 changes: 12 additions & 4 deletions plexupdate-core
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -226,17 +226,25 @@ 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"
elif [ $(echo "${DISTRO}" | cut -c -13) = "synology-dsm7" ]; then
cut -f2 -d- <<< "$1"
else
cut -f2 -d_ <<< "$1"
fi
}

getPlexVersion() {
if [ "${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 [ $(echo "${DISTRO}" | cut -c -13) = "synology-dsm7" ]; then
synopkg version "PlexMediaServer" 2>/dev/null | cut -f1 -d-
elif [ "${DISTRO}" = "redhat" ]; then
local rpmtemp
if rpmtemp=$(rpm -q plexmediaserver); then
parseVersion "$rpmtemp"
Expand Down
30 changes: 23 additions & 7 deletions plexupdate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -304,15 +304,22 @@ 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}"
else
DISTRO_INSTALL="${REDHAT_INSTALL}"
fi
elif [ -f /etc/synoinfo.conf ]; then
DISTRO="synology"
DISTRO_INSTALL="synopkg install"
if grep -q "major=\"7\"" /etc/VERSION; then
DISTRO="synology-dsm72"
if grep -q "minor=\"[01]\"" /etc/VERSION; then
DISTRO="synology-dsm7"
fi
fi
else
REDHAT=no
DISTRO="debian"
DISTRO_INSTALL="${DEBIAN_INSTALL}"
fi
Expand Down Expand Up @@ -428,7 +435,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

Expand Down Expand Up @@ -487,7 +494,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

Expand All @@ -496,6 +503,11 @@ 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 [ ${RET} -eq 1 ]; then
if [ "${DISTRO}" = "synology" ]; then
error "On Synology DSM6 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
fi
exit ${RET}
fi
fi
Expand All @@ -510,11 +522,15 @@ if [ "${AUTODELETE}" = "yes" ]; then
fi

if [ "${AUTOSTART}" = "yes" ]; then
if [ "${REDHAT}" = "no" ]; then
if [ "${DISTRO}" != "redhat" -a $(echo "${DISTRO}" | cut -c -8) != "synology"]; then
warn "The AUTOSTART [-s] option may not be needed on your distribution."
fi
# Check for systemd
if hash systemctl 2>/dev/null; then

if [ "${DISTRO}" = "synology" ]; then
synopkg start "Plex Media Server"
elif [ $(echo "${DISTRO}" | cut -c -13) = "synology-dsm7" ]; then
synopkg start "PlexMediaServer"
elif hash systemctl 2>/dev/null; then
systemctl start "$SYSTEMDUNIT"
elif hash service 2>/dev/null; then
service plexmediaserver start
Expand Down