From ec8137e42dd62df2c4b9b6fd6245954e87a7deb4 Mon Sep 17 00:00:00 2001 From: Nicholas Sperling Date: Tue, 9 Apr 2019 09:56:52 -0400 Subject: [PATCH] Add --run-after and RUNAFTER parameter to run after successful install. --- plexupdate.sh | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plexupdate.sh b/plexupdate.sh index 946b90f..495688f 100755 --- a/plexupdate.sh +++ b/plexupdate.sh @@ -96,6 +96,7 @@ usage() { echo " --port Port for Plex Server. Used with --server" echo " --server Address of Plex Server" echo " --token Manually specify the token to use to download Plex Pass releases" + echo " --run-after Program to run after successful install." echo "" exit 0 } @@ -174,6 +175,7 @@ do (--server) shift; PLEXSERVER=$(trimQuotes ${1});; (--port) shift; PLEXPORT=$(trimQuotes ${1});; (--token) shift; TOKEN=$(trimQuotes ${1});; + (--run-after) shift; RUNAFTER=$(trimQuotes ${1});; (--help) usage;; (--notify-success) NOTIFY=yes;; @@ -500,9 +502,15 @@ if [ "${AUTOINSTALL}" = "yes" ]; then RET=$? 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}" + error "Failed to install update. Command '${DISTRO_INSTALL} \"${DOWNLOADDIR}/${FILENAME}\"' returned error code ${RET}" exit ${RET} fi + + if [ ! -z "${RUNAFTER}" ]; then + # RUNAFTER command has been set. Pass version number as a parameter. + verboseOutput "Successfully installed update. Running '${RUNAFTER} \"${FILE_VERSION}\"'" + ${RUNAFTER} "${FILE_VERSION}" + fi fi if [ "${AUTODELETE}" = "yes" ]; then