2018-11-09 19:37:13 +01:00
|
|
|
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
|
2018-11-18 20:12:55 +01:00
|
|
|
BUILD_VERSION={version}
|
|
|
|
UPDATER={updater}
|
|
|
|
|
2018-11-09 19:37:13 +01:00
|
|
|
# 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
|
|
|
|
|
2018-11-18 20:12:55 +01:00
|
|
|
|
|
|
|
#BEGIN BUILTIN UPDATER
|
|
|
|
# Check for supported upgrade paths
|
|
|
|
if [ $1 = "upgrade" ] && [ "$UPDATER" = "BuiltIn" ] && [ -f /usr/lib/sonarr/bin/release_info ]; then
|
|
|
|
# If we allow the Built-In updater to upgrade from 3.0.1.123 to 3.0.2.500 and now apt is catching up to 3.0.2.425
|
|
|
|
# then we need to deal with that 500->425 'downgrade'.
|
|
|
|
# We do that by preserving the binaries and using those instead for postinst.
|
|
|
|
|
|
|
|
currentVersion=`cat /usr/lib/sonarr/bin/release_info | grep 'ReleaseVersion=' | cut -d= -f 2`
|
|
|
|
currentRelease=`echo "$currentVersion" | cut -d. -f1,2,3`
|
|
|
|
currentBuild=`echo "$currentVersion" | cut -d. -f4`
|
|
|
|
targetVersion=$BUILD_VERSION
|
|
|
|
targetRelease=`echo "$targetVersion" | cut -d. -f1,2,3`
|
|
|
|
targetBuild=`echo "$targetVersion" | cut -d. -f4`
|
|
|
|
|
|
|
|
if [ -d /usr/lib/sonarr/bin_patch ]; then
|
|
|
|
rm -rf /usr/lib/sonarr/bin_patch
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Check if the existing version is already an upgrade for the included build
|
|
|
|
if [ "$currentRelease" = "$targetRelease" ] && [ "$currentBuild" -gt "$targetBuild" ]; then
|
|
|
|
echo "Preserving $currentVersion from BuiltIn updater instead of downgrading to $targetVersion"
|
|
|
|
cp -r /usr/lib/sonarr/bin /usr/lib/sonarr/bin_patch
|
|
|
|
fi
|
|
|
|
fi
|
|
|
|
#END BUILTIN UPDATER
|
|
|
|
|
2018-11-09 19:37:13 +01:00
|
|
|
#DEBHELPER#
|
|
|
|
|
2018-11-18 20:12:55 +01:00
|
|
|
exit 0
|