This commit is contained in:
myellen 2020-04-23 11:50:40 -04:00 committed by GitHub
commit da33facded
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 66 additions and 15 deletions

View file

@ -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). 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 Plexs 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 # Advanced options
There are a few additional options for the more enterprising user. Setting any of these to `yes` will enable the function. There are a few additional options for the more enterprising user. Setting any of these to `yes` will enable the function.

View file

@ -4,7 +4,8 @@ ORIGIN_REPO="https://github.com/${GIT_OWNER:-mrworf}/plexupdate"
FULL_PATH="/opt/plexupdate" FULL_PATH="/opt/plexupdate"
CONFIGFILE="/etc/plexupdate.conf" CONFIGFILE="/etc/plexupdate.conf"
CONFIGCRON="/etc/plexupdate.cron.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 VERBOSE=yes #to be inherited by get-plex-token, do not save to config
# default options # default options
@ -42,6 +43,9 @@ check_distro() {
elif hash apt-get 2>/dev/null; then elif hash apt-get 2>/dev/null; then
DISTRO="debian" DISTRO="debian"
DISTRO_INSTALL="apt-get install" DISTRO_INSTALL="apt-get install"
elif [ -f /etc/synoinfo.conf ]; then
DISTRO="synology"
DISTRO_INSTALL="synopkg install"
else else
DISTRO="unknown" DISTRO="unknown"
fi fi
@ -179,9 +183,10 @@ configure_plexupdate() {
if yesno "$AUTOINSTALL"; then if yesno "$AUTOINSTALL"; then
AUTOINSTALL=yes AUTOINSTALL=yes
AUTODELETE=yes
[ -z "$DISTRO" ] && check_distro [ -z "$DISTRO" ] && check_distro
if [ "$DISTRO" == "redhat" ]; then if [ "$DISTRO" == "redhat" -o "$DISTRO" == "synology" ]; then
AUTOSTART=yes AUTOSTART=yes
else else
AUTOSTART= AUTOSTART=
@ -236,6 +241,11 @@ configure_cron() {
return 1 return 1
fi 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" [ -f "$CONFIGCRON" ] && source "$CONFIGCRON"
echo echo
@ -274,7 +284,14 @@ configure_cron() {
echo echo
echo -n "Installing daily cron job... " 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" echo "done"
elif [ -f "$CRONWRAPPER" -o -f "$CONFIGCRON" ]; then elif [ -f "$CRONWRAPPER" -o -f "$CONFIGCRON" ]; then
echo echo
@ -287,6 +304,20 @@ configure_cron() {
fi fi
echo done echo done
fi 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() { save_config() {
@ -297,15 +328,19 @@ save_config() {
fi fi
done done
save_config_tmp "$CONFIGTEMP" "$2"
}
save_config_tmp() {
echo echo
echo -n "Writing configuration file '$2'... " echo -n "Writing configuration file '$2'... "
# most likely writing to /etc, so we need sudo # 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" sudo chmod 640 "$2"
# only root can modify the config, but the user can still read it # only root can modify the config, but the user can still read it
sudo chown 0:$(id -g) "$2" sudo chown 0:$(id -g) "$2"
rm "$CONFIGTEMP" rm "$1"
echo "done" echo "done"
} }

View file

@ -51,7 +51,7 @@ getPlexToken() {
fi fi
done done
while true; do while true; do
read -e -p "PlexPass Password: " -i "$PASS" PASS read -e -s -p "PlexPass Password: " -i "$PASS" PASS
if [ -z "$PASS" ]; then if [ -z "$PASS" ]; then
info "Please provide a password" info "Please provide a password"
else else
@ -226,17 +226,21 @@ isNewerVersion() {
} }
parseVersion() { parseVersion() {
if [ "${REDHAT}" = "yes" ]; then if [ "${DISTRO}" = "redhat" ]; then
cut -f2- -d- <<< "$1" | cut -f1-4 -d. cut -f2- -d- <<< "$1" | cut -f1-4 -d.
elif [ "${DISTRO}" = "synology" ]; then
cut -f2-3 -d- <<< "$1"
else else
cut -f2 -d_ <<< "$1" cut -f2 -d_ <<< "$1"
fi fi
} }
getPlexVersion() { getPlexVersion() {
if [ "${REDHAT}" != "yes" ]; then if [ "${DISTRO}" = "debian" ]; then
dpkg-query --showformat='${Version}' --show plexmediaserver 2>/dev/null 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 local rpmtemp
if rpmtemp=$(rpm -q plexmediaserver); then if rpmtemp=$(rpm -q plexmediaserver); then
parseVersion "$rpmtemp" parseVersion "$rpmtemp"

View file

@ -304,15 +304,16 @@ if [ -z "${DISTRO_INSTALL}" ]; then
if [ -z "${DISTRO}" ]; then if [ -z "${DISTRO}" ]; then
# Detect if we're running on redhat instead of ubuntu # Detect if we're running on redhat instead of ubuntu
if [ -f /etc/redhat-release ]; then if [ -f /etc/redhat-release ]; then
REDHAT=yes
DISTRO="redhat" DISTRO="redhat"
if ! hash dnf 2>/dev/null; then if ! hash dnf 2>/dev/null; then
DISTRO_INSTALL="${REDHAT_INSTALL/dnf/yum}" DISTRO_INSTALL="${REDHAT_INSTALL/dnf/yum}"
else else
DISTRO_INSTALL="${REDHAT_INSTALL}" DISTRO_INSTALL="${REDHAT_INSTALL}"
fi fi
elif [ -f /etc/synoinfo.conf ]; then
DISTRO="synology"
DISTRO_INSTALL="synopkg install"
else else
REDHAT=no
DISTRO="debian" DISTRO="debian"
DISTRO_INSTALL="${DEBIAN_INSTALL}" DISTRO_INSTALL="${DEBIAN_INSTALL}"
fi fi
@ -428,7 +429,7 @@ INSTALLED_VERSION="$(getPlexVersion)" || warn "Unable to detect installed versio
FILE_VERSION="$(parseVersion "${FILENAME}")" FILE_VERSION="$(parseVersion "${FILENAME}")"
verboseOutput INSTALLED_VERSION FILE_VERSION 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." warn "Your distribution may require the use of the AUTOSTART [-s] option for the service to start after the upgrade completes."
fi fi
@ -487,7 +488,7 @@ if [ -n "${PLEXSERVER}" -a "${AUTOINSTALL}" = "yes" ]; then
fi fi
if [ "${AUTOINSTALL}" = "yes" ]; then 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 export PATH=$PATH:/sbin
fi fi
@ -496,6 +497,9 @@ if [ "${AUTOINSTALL}" = "yes" ]; then
if [ ${RET} -ne 0 ]; then if [ ${RET} -ne 0 ]; then
# Clarify why this failed, so user won't be left in the dark # 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}" error "Failed to install update. Command '${DISTRO_INSTALL} "${DOWNLOADDIR}/${FILENAME}"' returned error code ${RET}"
if [ "${DISTRO}" = "synology" -a ${RET} -eq 1 ]; then
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} exit ${RET}
fi fi
fi fi
@ -510,7 +514,7 @@ if [ "${AUTODELETE}" = "yes" ]; then
fi fi
if [ "${AUTOSTART}" = "yes" ]; then if [ "${AUTOSTART}" = "yes" ]; then
if [ "${REDHAT}" = "no" ]; then if [ "${DISTRO}" != "redhat" -a "${DISTRO}" != "synology" ]; then
warn "The AUTOSTART [-s] option may not be needed on your distribution." warn "The AUTOSTART [-s] option may not be needed on your distribution."
fi fi
# Check for systemd # Check for systemd
@ -520,6 +524,8 @@ if [ "${AUTOSTART}" = "yes" ]; then
service plexmediaserver start service plexmediaserver start
elif [ -x /etc/init.d/plexmediaserver ]; then elif [ -x /etc/init.d/plexmediaserver ]; then
/etc/init.d/plexmediaserver start /etc/init.d/plexmediaserver start
elif [ "${DISTRO}" = "synology" ]; then
synopkg start "Plex Media Server"
else else
error "AUTOSTART was specified but no startup scripts were found for 'plexmediaserver'." error "AUTOSTART was specified but no startup scripts were found for 'plexmediaserver'."
exit 1 exit 1