From 9e909cafdd21c2f1df78d8bd88acfa22f1963d98 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Fri, 9 Nov 2018 19:37:13 +0100 Subject: [PATCH] Added check in preinst to cancel install if NzbDrone is still running. --- distribution/debian/postrm | 18 ++++++++++++++++++ distribution/debian/preinst | 24 ++++++++++++++++++++++++ 2 files changed, 42 insertions(+) create mode 100644 distribution/debian/postrm create mode 100644 distribution/debian/preinst diff --git a/distribution/debian/postrm b/distribution/debian/postrm new file mode 100644 index 000000000..789d5b978 --- /dev/null +++ b/distribution/debian/postrm @@ -0,0 +1,18 @@ +#!/bin/sh +set -e + +if [ "$1" = "abort-install" ]; then + # preinst was aborted, possibly due to NzbDrone still running. + # Nothing to do here + : +fi + +# Purge the entire sonarr configuration directory. +# TODO: Maybe move a minimal backup to tmp? +if [ "$1" = "purge" ]; then + if [ -d "/var/opt/sonarr" ]; then + rm -rf /var/opt/sonarr + fi +fi + +#DEBHELPER# diff --git a/distribution/debian/preinst b/distribution/debian/preinst new file mode 100644 index 000000000..de128138b --- /dev/null +++ b/distribution/debian/preinst @@ -0,0 +1,24 @@ +#!/bin/sh +set -e + +# Deal with existing nzbdrone installs +# +# Any existing nzbdrone package would already be in de deconfigured stage, so the binaries are gone. +# However the process might still be running since those are not part of the nzbdrone package. +# If the user manually installed nzbdrone then the process might still be running too. + +if [ $1 = "install" ]; then + psNzbDrone=`ps aux | grep mono.*NzbDrone\\\\.exe || true` + if [ ! -z "$psNzbDrone" ]; then + # TODO: Perform operations to detect auto-migration capabilities. + + # Return failure, which causes postrm abort-install to be called. + echo "ps: $psNzbDrone" + echo "Error: An existing Sonarr v2 (NzbDrone) process is running. Remove the NzbDrone auto-startup prior to installing sonarr." + exit 1 + fi +fi + +#DEBHELPER# + +exit 0 \ No newline at end of file