From 8f4067adbba9def6c29b81baf58c53b327782a81 Mon Sep 17 00:00:00 2001 From: Taloth Saldono Date: Sun, 30 Dec 2018 15:27:41 +0100 Subject: [PATCH] Also deal with migrations where the user installed using a different user. --- distribution/debian/postinst | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/distribution/debian/postinst b/distribution/debian/postinst index 481b1601f..b22fb25df 100644 --- a/distribution/debian/postinst +++ b/distribution/debian/postinst @@ -21,13 +21,25 @@ if ! getent passwd "$USER" >/dev/null; then fi if [ $1 = "configure" ]; then - # Migrate old Sonarr v3 alpha data dir + # Migrate old Sonarr v3 alpha data dir from /var/opt/sonarr or user home if [ -d "/var/opt/sonarr" ] && [ "$CONFDIR" != "/var/opt/sonarr" ] && [ ! -d "$CONFDIR" ]; then - if [ ! -f "/var/opt/sonarr/sonarr.db" ] && [ -f "/var/opt/sonarr/.config/Sonarr/sonarr.db" ]; then - mv "/var/opt/sonarr/.config/Sonarr" "$CONFDIR" - rm -rf "/var/opt/sonarr" + varoptRoot="/var/opt/sonarr" + varoptAppData="$varoptRoot/.config/Sonarr" + sonarrUserHome=`getent passwd $USER | cut -d ':' -f 6` + sonarrAppData="$sonarrUserHome/.config/Sonarr" + if [ ! -f "$varoptRoot/sonarr.db" ]; then + # Handle /var/opt/sonarr/sonarr.db + mv "$varoptRoot" "$CONFDIR" + elif [ -f "$varoptAppData/sonarr.db" ]; then + # Handle /var/opt/sonarr/.config/Sonarr/sonarr.db + mv "$varoptAppData" "$CONFDIR" + rm -rf "$varoptRoot" + elif [ -f "$sonarrAppData/sonarr.db" ]; then + # Handle ~/.config/Sonarr/sonarr.db + mv "$sonarrAppData" "$CONFDIR" + rm -rf "$sonarrAppData" else - mv "/var/opt/sonarr" "$CONFDIR" + mv "$varoptRoot" "$CONFDIR" fi chown -R $USER:$GROUP "$CONFDIR" chmod -R 775 "$CONFDIR"