1
0
Fork 0
mirror of https://github.com/Sonarr/Sonarr synced 2024-12-22 07:43:01 +00:00

Also deal with migrations where the user installed using a different user.

This commit is contained in:
Taloth Saldono 2018-12-30 15:27:41 +01:00
parent 54160850b2
commit 8f4067adbb

View file

@ -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"